activerecord-jdbc-alt-adapter 70.0.0.rc2-java → 70.2.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61ee665d7dfe0dc2b0a84c5c2014ba1c4427dfb63a52a0992eee1ba8449360c0
4
- data.tar.gz: fdd181f5107c6af495b97f3d67bc5031fd9b9c0a9e454ea6e0fc06e280a544dd
3
+ metadata.gz: d657378f80f357a04e2fdad85beaced7e0e8588bf516a4cfea0d2960dee6f517
4
+ data.tar.gz: 713a05c4a59bdc8c6a767f5c7043f7f6b51130d231364e3ee11b0df537cdf6a1
5
5
  SHA512:
6
- metadata.gz: 16c1ca8af769eec8eaab04650e6293f0b0e8cfdc20ae77bb5c2d37c276f5104ed3e42da35a1397215f4d8925bd192e87a18c163cdbdb03578573baa181d7550b
7
- data.tar.gz: e200993abec93188a25038d74a3641d83e16cd11d87b10fba1051d51e2e61622dca977edad111c965215e731f51d013bec95bdf42ef73f6c98067a118acf9117
6
+ metadata.gz: cb38c344bcf3b01e991a5b026c01d250ea9fd82441373ee3095b9bc2f63e139370f9be4adad65863988119eabbcea80b0a1083909d4eaec61af17d42a42e9ee2
7
+ data.tar.gz: 6b9e80af6e0bd15a0aa1eab237e1d0f8a5bc5752f1d22fb6ab2100c755d34f1c25f1853105a82eb58bb7ad7f08652213e9f8b147a2728062103d98007aa3510c
@@ -20,6 +20,54 @@ permissions:
20
20
  contents: read
21
21
 
22
22
  jobs:
23
+ test-arjdbc-mssql:
24
+
25
+ name: ARJDBC Tests (mssql)
26
+ runs-on: ubuntu-latest
27
+ strategy:
28
+ fail-fast: false
29
+ matrix:
30
+ ruby-version: ['jruby-9.4.2.0']
31
+ db: ['mssql']
32
+ test_targets: ['test_mssql']
33
+
34
+ services:
35
+ mssql:
36
+ image: mcr.microsoft.com/mssql/server:2019-latest
37
+ env:
38
+ ACCEPT_EULA: Y
39
+ MSSQL_SA_PASSWORD: Password12!
40
+ ports:
41
+ - 1433:1433
42
+ options: >-
43
+ --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P \"Password12!\" -l 30 -Q \"SELECT 1\""
44
+ --health-start-period 10s
45
+ --health-interval 10s
46
+ --health-timeout 5s
47
+ --health-retries 10
48
+
49
+ env:
50
+ DB: ${{ matrix.db }}
51
+ JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M"
52
+ SQLUSER: SA
53
+ SQLPASS: Password12!
54
+
55
+ steps:
56
+ - uses: actions/checkout@v3
57
+ - name: Set up Ruby
58
+ uses: ruby/setup-ruby@v1
59
+ with:
60
+ ruby-version: ${{ matrix.ruby-version }}
61
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
62
+ - name: Setup database
63
+ run: /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password12!" -Q "CREATE DATABASE arjdbc_test;"
64
+ - name: Build
65
+ run: |
66
+ rake jar
67
+ - name: Run tests
68
+ run: |
69
+ bundle exec rake ${{ matrix.test_targets }}
70
+
23
71
  test-rails-pgsql:
24
72
 
25
73
  name: Rails Tests (Postgres)
@@ -27,7 +75,7 @@ jobs:
27
75
  strategy:
28
76
  fail-fast: false
29
77
  matrix:
30
- ruby-version: [ 'jruby-head' ]
78
+ ruby-version: [ 'jruby-9.4.2.0' ]
31
79
  db: [ 'postgresql' ]
32
80
  test_targets: [ "rails:test_postgresql" ]
33
81
  ar_version: ["7-0-stable"]
@@ -78,7 +126,7 @@ jobs:
78
126
  strategy:
79
127
  fail-fast: false
80
128
  matrix:
81
- ruby-version: ['jruby-head']
129
+ ruby-version: ['jruby-9.4.2.0']
82
130
  db: ['postgresql']
83
131
  test_targets: ["db:postgresql test_postgresql"]
84
132
  prepared_statements: ['false', 'true']
@@ -51,6 +51,16 @@ module Arel
51
51
  end
52
52
  end
53
53
 
54
+ # Override the default in arel ToSql class
55
+ def visit_Arel_Nodes_NullsFirst(o, collector)
56
+ visit o.expr, collector
57
+ end
58
+
59
+ # Override the default in arel ToSql class
60
+ def visit_Arel_Nodes_NullsLast(o, collector)
61
+ visit o.expr, collector
62
+ end
63
+
54
64
  def visit_Arel_Nodes_Grouping(o, collector)
55
65
  remove_invalid_ordering_from_select_statement(o.expr)
56
66
  super
@@ -10,6 +10,8 @@ module ArJdbc
10
10
  NO_BINDS = [].freeze
11
11
 
12
12
  def exec_insert(sql, name = nil, binds = NO_BINDS, pk = nil, sequence_name = nil)
13
+ sql = transform_query(sql)
14
+
13
15
  if preventing_writes?
14
16
  raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
15
17
  end
@@ -31,6 +33,8 @@ module ArJdbc
31
33
  # It appears that at this point (AR 5.0) "prepare" should only ever be true
32
34
  # if prepared statements are enabled
33
35
  def exec_query(sql, name = nil, binds = NO_BINDS, prepare: false, async: false)
36
+ sql = transform_query(sql)
37
+
34
38
  if preventing_writes? && write_query?(sql)
35
39
  raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
36
40
  end
@@ -52,6 +56,8 @@ module ArJdbc
52
56
  end
53
57
 
54
58
  def exec_update(sql, name = nil, binds = NO_BINDS)
59
+ sql = transform_query(sql)
60
+
55
61
  if preventing_writes?
56
62
  raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
57
63
  end
@@ -70,6 +76,8 @@ module ArJdbc
70
76
  alias :exec_delete :exec_update
71
77
 
72
78
  def execute(sql, name = nil, async: false)
79
+ sql = transform_query(sql)
80
+
73
81
  if preventing_writes? && write_query?(sql)
74
82
  raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
75
83
  end
Binary file
@@ -472,7 +472,7 @@ module ActiveRecord
472
472
  # NOTE: This is ready, all implemented in the java part of adapter,
473
473
  # it uses MSSQLColumn, SqlTypeMetadata, etc.
474
474
  def column_definitions(table_name)
475
- log('JDBC: GETCOLUMNS', 'SCHEMA') { @connection.columns(table_name) }
475
+ log('JDBC: GETCOLUMNS', 'SCHEMA') { @connection.columns(table_name, nil, default_schema) }
476
476
  rescue => e
477
477
  # raise translate_exception_class(e, nil)
478
478
  # FIXME: this breaks one arjdbc test but fixes activerecord tests
@@ -80,7 +80,7 @@ ArJdbc::ConnectionMethods.module_eval do
80
80
  url << "lockTimeout=#{config[:lock_timeout].to_i};"
81
81
  url << "encrypt=#{config[:encrypt]};" if config.key?(:encrypt)
82
82
  url << "trustServerCertificate=#{config[:trust_server_certificate]};" if config.key?(:trust_server_certificate)
83
- app = config[:appname] || config[:application]
83
+ app = config[:application_name] || config[:appname] || config[:application]
84
84
  url << "applicationName=#{app};" if app
85
85
  isc = config[:integrated_security] # Win only - needs sqljdbc_auth.dll
86
86
  url << "integratedSecurity=#{isc};" unless isc.nil?
@@ -126,51 +126,52 @@ ArJdbc::ConnectionMethods.module_eval do
126
126
 
127
127
  private
128
128
 
129
- @@mysql_encodings = nil
129
+ MYSQL_ENCODINGS = {
130
+ "big5" => "Big5",
131
+ "dec8" => nil,
132
+ #"cp850" => "Cp850",
133
+ "hp8" => nil,
134
+ #"koi8r" => "KOI8-R",
135
+ "latin1" => "Cp1252",
136
+ "latin2" => "ISO8859_2",
137
+ "swe7" => nil,
138
+ "ascii" => "US-ASCII",
139
+ "ujis" => "EUC_JP",
140
+ "sjis" => "SJIS",
141
+ "hebrew" => "ISO8859_8",
142
+ "tis620" => "TIS620",
143
+ "euckr" => "EUC_KR",
144
+ #"koi8u" => "KOI8-R",
145
+ "gb2312" => "EUC_CN",
146
+ "greek" => "ISO8859_7",
147
+ "cp1250" => "Cp1250",
148
+ "gbk" => "GBK",
149
+ #"latin5" => "ISO-8859-9",
150
+ "armscii8" => nil,
151
+ "ucs2" => "UnicodeBig",
152
+ "cp866" => "Cp866",
153
+ "keybcs2" => nil,
154
+ "macce" => "MacCentralEurope",
155
+ "macroman" => "MacRoman",
156
+ #"cp852" => "CP852",
157
+ #"latin7" => "ISO-8859-13",
158
+ "cp1251" => "Cp1251",
159
+ "cp1256" => "Cp1256",
160
+ "cp1257" => "Cp1257",
161
+ "binary" => false,
162
+ "geostd8" => nil,
163
+ "cp932" => "Cp932",
164
+ #"eucjpms" => "eucJP-ms"
165
+ "utf8" => "UTF-8",
166
+ "utf8mb4" => false,
167
+ "utf16" => false,
168
+ "utf32" => false,
169
+ }
170
+
130
171
 
131
172
  # @see https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-charsets.html
132
173
  def convert_mysql_encoding(encoding) # to charset-name (characterEncoding=...)
133
- ( @@mysql_encodings ||= {
134
- "big5" => "Big5",
135
- "dec8" => nil,
136
- #"cp850" => "Cp850",
137
- "hp8" => nil,
138
- #"koi8r" => "KOI8-R",
139
- "latin1" => "Cp1252",
140
- "latin2" => "ISO8859_2",
141
- "swe7" => nil,
142
- "ascii" => "US-ASCII",
143
- "ujis" => "EUC_JP",
144
- "sjis" => "SJIS",
145
- "hebrew" => "ISO8859_8",
146
- "tis620" => "TIS620",
147
- "euckr" => "EUC_KR",
148
- #"koi8u" => "KOI8-R",
149
- "gb2312" => "EUC_CN",
150
- "greek" => "ISO8859_7",
151
- "cp1250" => "Cp1250",
152
- "gbk" => "GBK",
153
- #"latin5" => "ISO-8859-9",
154
- "armscii8" => nil,
155
- "ucs2" => "UnicodeBig",
156
- "cp866" => "Cp866",
157
- "keybcs2" => nil,
158
- "macce" => "MacCentralEurope",
159
- "macroman" => "MacRoman",
160
- #"cp852" => "CP852",
161
- #"latin7" => "ISO-8859-13",
162
- "cp1251" => "Cp1251",
163
- "cp1256" => "Cp1256",
164
- "cp1257" => "Cp1257",
165
- "binary" => false,
166
- "geostd8" => nil,
167
- "cp932" => "Cp932",
168
- #"eucjpms" => "eucJP-ms"
169
- "utf8" => "UTF-8",
170
- "utf8mb4" => false,
171
- "utf16" => false,
172
- "utf32" => false,
173
- } )[ encoding ]
174
+ MYSQL_ENCODINGS[ encoding ]
174
175
  end
175
176
 
176
177
  end
@@ -21,6 +21,7 @@ require 'arjdbc/abstract/transaction_support'
21
21
  require 'arjdbc/postgresql/base/array_decoder'
22
22
  require 'arjdbc/postgresql/base/array_encoder'
23
23
  require 'arjdbc/postgresql/name'
24
+ require 'active_model'
24
25
 
25
26
  module ArJdbc
26
27
  # Strives to provide Rails built-in PostgreSQL adapter (API) compatibility.
@@ -24,7 +24,14 @@ ArJdbc::ConnectionMethods.module_eval do
24
24
  port = config[:port] ||= ( ENV['PGPORT'] || 5432 )
25
25
  database = config[:database] || config[:dbname] || ENV['PGDATABASE']
26
26
 
27
- config[:url] ||= "jdbc:postgresql://#{host}:#{port}/#{database}"
27
+ app = config[:application_name] || config[:appname] || config[:application]
28
+
29
+ config[:url] ||= if app
30
+ "jdbc:postgresql://#{host}:#{port}/#{database}?ApplicationName=#{app}"
31
+ else
32
+ "jdbc:postgresql://#{host}:#{port}/#{database}"
33
+ end
34
+
28
35
  config[:url] << config[:pg_params] if config[:pg_params]
29
36
 
30
37
  config[:username] ||= ( config[:user] || ENV['PGUSER'] || ENV_JAVA['user.name'] )
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
-
3
2
  require 'thread'
4
3
 
5
4
  module ArJdbc
@@ -91,8 +90,23 @@ module ArJdbc
91
90
  end
92
91
 
93
92
  def get_oid_type(oid, fmod, column_name, sql_type = '') # :nodoc:
94
- if !type_map.key?(oid)
95
- load_additional_types([oid])
93
+ # Note: type_map is storing a bunch of oid type prefixed with a namespace even
94
+ # if they are not namespaced (e.g. ""."oidvector"). builtin types which are
95
+ # common seem to not be prefixed (e.g. "varchar"). OID numbers are also keys
96
+ # but JDBC never returns those. So the current scheme is to check with
97
+ # what we got and that covers number and plain strings and otherwise we will
98
+ # wrap with the namespace form.
99
+ found = type_map.key?(oid)
100
+
101
+ if !found
102
+ key = oid.kind_of?(String) && oid != "oid" ? "\"\".\"#{oid}\"" : oid
103
+ found = type_map.key?(key)
104
+
105
+ if !found
106
+ load_additional_types([oid])
107
+ else
108
+ oid = key
109
+ end
96
110
  end
97
111
 
98
112
  type_map.fetch(oid, fmod, sql_type) {
@@ -207,7 +221,6 @@ module ArJdbc
207
221
  initializer = ArjdbcTypeMapInitializer.new(type_map)
208
222
  load_types_queries(initializer, oids) do |query|
209
223
  execute_and_clear(query, "SCHEMA", []) do |records|
210
- #puts "RECORDS: #{records.to_a}"
211
224
  initializer.run(records)
212
225
  end
213
226
  end
@@ -224,8 +237,6 @@ module ArJdbc
224
237
  yield query + "WHERE t.oid IN (%s)" % oids.join(", ")
225
238
  else
226
239
  in_list = oids.map { |e| %Q{'#{e}'} }.join(", ")
227
- #puts caller[0..40]
228
- puts "IN_LIST = #{in_list}"
229
240
  yield query + "WHERE t.typname IN (%s)" % in_list
230
241
  end
231
242
  else
@@ -756,6 +756,29 @@ module ActiveRecord::ConnectionAdapters
756
756
  # Note: This is not an override of ours but a moved line from AR Sqlite3Adapter to register ours vs our copied module (which would be their class).
757
757
  # ActiveSupport.run_load_hooks(:active_record_sqlite3adapter, SQLite3Adapter)
758
758
 
759
+ # DIFFERENCE: FQN
760
+ class SQLite3Integer < ::ActiveRecord::Type::Integer # :nodoc:
761
+ private
762
+ def _limit
763
+ # INTEGER storage class can be stored 8 bytes value.
764
+ # See https://www.sqlite.org/datatype3.html#storage_classes_and_datatypes
765
+ limit || 8
766
+ end
767
+ end
768
+
769
+ # DIFFERENCE: FQN
770
+ ::ActiveRecord::Type.register(:integer, SQLite3Integer, adapter: :sqlite3)
771
+
772
+ class << self
773
+ private
774
+ def initialize_type_map(m)
775
+ super
776
+ register_class_with_limit m, %r(int)i, SQLite3Integer
777
+ end
778
+ end
779
+
780
+ TYPE_MAP = ActiveRecord::Type::TypeMap.new.tap { |m| initialize_type_map(m) }
781
+
759
782
  private
760
783
 
761
784
  # because the JDBC driver doesn't like multiple SQL statements in one JDBC statement
@@ -763,6 +786,10 @@ module ActiveRecord::ConnectionAdapters
763
786
  total_sql
764
787
  end
765
788
 
789
+ def type_map
790
+ TYPE_MAP
791
+ end
792
+
766
793
  # combine
767
794
  def write_query?(sql) # :nodoc:
768
795
  return sql.any? { |stmt| super(stmt) } if sql.kind_of? Array
@@ -770,23 +797,5 @@ module ActiveRecord::ConnectionAdapters
770
797
  rescue ArgumentError # Invalid encoding
771
798
  !READ_QUERY.match?(sql.b)
772
799
  end
773
-
774
- def initialize_type_map(m = type_map)
775
- super
776
- register_class_with_limit m, %r(int)i, SQLite3Integer
777
- end
778
-
779
- # DIFFERENCE: FQN
780
- class SQLite3Integer < ::ActiveRecord::Type::Integer # :nodoc:
781
- private
782
- def _limit
783
- # INTEGER storage class can be stored 8 bytes value.
784
- # See https://www.sqlite.org/datatype3.html#storage_classes_and_datatypes
785
- limit || 8
786
- end
787
- end
788
-
789
- # DIFFERENCE: FQN
790
- ::ActiveRecord::Type.register(:integer, SQLite3Integer, adapter: :sqlite3)
791
800
  end
792
801
  end
@@ -25,7 +25,7 @@ module ArJdbc
25
25
  rescue ActiveRecord::StatementInvalid => e
26
26
  case e.message
27
27
  when /database .* already exists/i
28
- raise ActiveRecord::Tasks::DatabaseAlreadyExists
28
+ raise ActiveRecord::DatabaseAlreadyExists
29
29
  else
30
30
  raise
31
31
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ArJdbc
4
- VERSION = '70.0.0.rc2'
4
+ VERSION = '70.2.0'
5
5
  end
@@ -2736,7 +2736,7 @@ public class RubyJdbcConnection extends RubyObject {
2736
2736
  }
2737
2737
  else { // e.g. `BigDecimal '42.00000000000000000001'`
2738
2738
  statement.setBigDecimal(index,
2739
- RubyBigDecimal.newInstance(context, context.runtime.getModule("BigDecimal"), value).getValue());
2739
+ RubyBigDecimal.newInstance(context, context.runtime.getModule("BigDecimal"), value, RubyFixnum.newFixnum(context.runtime, Integer.MAX_VALUE)).getValue());
2740
2740
  }
2741
2741
  }
2742
2742
 
@@ -511,7 +511,7 @@ public class SQLite3RubyJdbcConnection extends RubyJdbcConnection {
511
511
  statement.setDouble(index, ((RubyNumeric) value).getDoubleValue());
512
512
  }
513
513
  else { // e.g. `BigDecimal '42.00000000000000000001'`
514
- RubyBigDecimal val = RubyBigDecimal.newInstance(context, context.runtime.getModule("BigDecimal"), value);
514
+ RubyBigDecimal val = RubyBigDecimal.newInstance(context, context.runtime.getModule("BigDecimal"), value, RubyFixnum.newFixnum(context.runtime, Integer.MAX_VALUE));
515
515
  statement.setString(index, val.getValue().toString());
516
516
  }
517
517
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-jdbc-alt-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 70.0.0.rc2
4
+ version: 70.2.0
5
5
  platform: java
6
6
  authors:
7
7
  - Nick Sieger, Ola Bini, Karol Bucek, Jesse Chavez, and JRuby contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-02 00:00:00.000000000 Z
11
+ date: 2024-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -17,8 +17,8 @@ dependencies:
17
17
  - !ruby/object:Gem::Version
18
18
  version: 7.0.0
19
19
  name: activerecord
20
- prerelease: false
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
@@ -231,11 +231,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
231
231
  version: '0'
232
232
  required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  requirements:
234
- - - ">"
234
+ - - ">="
235
235
  - !ruby/object:Gem::Version
236
- version: 1.3.1
236
+ version: '0'
237
237
  requirements: []
238
- rubygems_version: 3.3.25
238
+ rubygems_version: 3.3.26
239
239
  signing_key:
240
240
  specification_version: 4
241
241
  summary: ActiveRecord JDBC adapter, for use within JRuby on Rails and SQL Server