activerecord-jdbc-alt-adapter 70.0.0.rc2-java → 70.1.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: 0c3d514e216f7046d55347dee117af72c6f9970542a59d720e4a570adc51481c
4
+ data.tar.gz: fb7ae7aa872404230ce35232237c4917f73971d0a39ef40998ca3ab6e11422af
5
5
  SHA512:
6
- metadata.gz: 16c1ca8af769eec8eaab04650e6293f0b0e8cfdc20ae77bb5c2d37c276f5104ed3e42da35a1397215f4d8925bd192e87a18c163cdbdb03578573baa181d7550b
7
- data.tar.gz: e200993abec93188a25038d74a3641d83e16cd11d87b10fba1051d51e2e61622dca977edad111c965215e731f51d013bec95bdf42ef73f6c98067a118acf9117
6
+ metadata.gz: 53c2771f7803cf7b5b34ddfb3d3786c4478263fd43ec609bf726b60b8c9056e799f3ebf61f6d48fc3fc7450ee2c15e9cf66be61784a48fec3edb64cd36b88d15
7
+ data.tar.gz: 7c23c77d26b5e845c3f9c779c5761f4fbce1ff29db75e5a8a9ea7cf115f14b2cf4be6d56d172f16200f5866f54e5c68253f0293c44be7bd2c2c7034a908af9a7
@@ -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']
@@ -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?
@@ -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.1.0'
5
5
  end
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.1.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: 2023-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -231,9 +231,9 @@ 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
238
  rubygems_version: 3.3.25
239
239
  signing_key: