activerecord-jdbc-alt-adapter 80.0.0.rc1-java → 80.1.0.beta1-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 +4 -4
- data/.github/workflows/main.yml +3 -3
- data/activerecord-jdbc-adapter.gemspec +1 -1
- data/activerecord-jdbc-alt-adapter.gemspec +1 -1
- data/lib/arjdbc/abstract/database_statements.rb +3 -25
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/mssql/adapter.rb +1 -0
- data/lib/arjdbc/mssql/column.rb +2 -2
- data/lib/arjdbc/mssql/database_statements.rb +1 -1
- data/lib/arjdbc/mssql/schema_creation.rb +1 -1
- data/lib/arjdbc/mssql/schema_statements.rb +4 -0
- data/lib/arjdbc/mssql/type_metadata.rb +36 -0
- data/lib/arjdbc/mssql/types/binary_types.rb +5 -4
- data/lib/arjdbc/mssql/types/deprecated_types.rb +15 -12
- data/lib/arjdbc/mssql/types/string_types.rb +10 -8
- data/lib/arjdbc/mssql.rb +1 -1
- data/lib/arjdbc/postgresql/adapter.rb +0 -4
- data/lib/arjdbc/postgresql/schema_statements.rb +7 -0
- data/lib/arjdbc/tasks/mssql_database_tasks.rb +1 -21
- data/lib/arjdbc/version.rb +1 -1
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +3 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e84b54bc11898d1512c4eef346ee60a6f310efb072b2566524caa3d8a3cbf27c
|
|
4
|
+
data.tar.gz: ee626a6778a58bdc56aa366619ffe80528cee99119152a1ecf4686cfc041f2a2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9e4b283987223aff1540b1e3cd55f36dac4d0755af34c1a2ea7076bd4e92b5a5209609b536ef9e9f56e09b8ad199308720f1b93f6dc8529854e582dbb3f43977
|
|
7
|
+
data.tar.gz: a32fa2c34cdaa642a5e6f7a26acc3e301ecc6a8d06f794d124ff1f9ce8c4fcf8f7e340941856ee3bee99c82da9d8c10957d99247f28bfa83841f4edc3c41ab41
|
data/.github/workflows/main.yml
CHANGED
|
@@ -160,7 +160,7 @@ jobs:
|
|
|
160
160
|
ruby-version: [ 'jruby-10.0.6.0' ]
|
|
161
161
|
db: [ 'mssql' ]
|
|
162
162
|
test_targets: [ "rails:test_mssql" ]
|
|
163
|
-
ar_version: ["8-
|
|
163
|
+
ar_version: ["8-1-stable-dev"]
|
|
164
164
|
|
|
165
165
|
services:
|
|
166
166
|
mssql:
|
|
@@ -216,7 +216,7 @@ jobs:
|
|
|
216
216
|
ruby-version: ['jruby-10.0.6.0']
|
|
217
217
|
db: ['sqlite3']
|
|
218
218
|
test_targets: ["rails:test_sqlite3"]
|
|
219
|
-
ar_version: ["8-
|
|
219
|
+
ar_version: ["8-1-stable-dev"]
|
|
220
220
|
|
|
221
221
|
env:
|
|
222
222
|
DB: ${{ matrix.db }}
|
|
@@ -248,7 +248,7 @@ jobs:
|
|
|
248
248
|
ruby-version: [ 'jruby-10.0.6.0' ]
|
|
249
249
|
db: [ 'postgresql' ]
|
|
250
250
|
test_targets: [ "rails:test_postgresql" ]
|
|
251
|
-
ar_version: ["8-
|
|
251
|
+
ar_version: ["8-1-stable-dev"]
|
|
252
252
|
prepared_statements: [ 'false', 'true' ]
|
|
253
253
|
|
|
254
254
|
services:
|
|
@@ -41,7 +41,7 @@ Gem::Specification.new do |gem|
|
|
|
41
41
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
|
42
42
|
gem.test_files = gem.files.grep(%r{^test/})
|
|
43
43
|
|
|
44
|
-
gem.add_dependency "activerecord", "~> 8.0"
|
|
44
|
+
gem.add_dependency "activerecord", "~> 8.1.0"
|
|
45
45
|
|
|
46
46
|
#gem.add_development_dependency 'test-unit', '2.5.4'
|
|
47
47
|
#gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
|
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |gem|
|
|
|
43
43
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
|
44
44
|
gem.test_files = gem.files.grep(%r{^test/})
|
|
45
45
|
|
|
46
|
-
gem.add_dependency "activerecord", "~> 8.
|
|
46
|
+
gem.add_dependency "activerecord", "~> 8.1.0"
|
|
47
47
|
|
|
48
48
|
#gem.add_development_dependency 'test-unit', '2.5.4'
|
|
49
49
|
#gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
|
|
@@ -10,13 +10,7 @@ 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, returning: nil)
|
|
13
|
-
|
|
14
|
-
raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
mark_transaction_written_if_write(sql)
|
|
18
|
-
|
|
19
|
-
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
|
|
13
|
+
sql = preprocess_query(sql)
|
|
20
14
|
|
|
21
15
|
type_casted_binds = type_casted_binds(binds)
|
|
22
16
|
|
|
@@ -36,13 +30,7 @@ module ArJdbc
|
|
|
36
30
|
# It appears that at this point (AR 5.0) "prepare" should only ever be true
|
|
37
31
|
# if prepared statements are enabled
|
|
38
32
|
def internal_exec_query(sql, name = nil, binds = NO_BINDS, prepare: false, async: false, allow_retry: false, materialize_transactions: true)
|
|
39
|
-
|
|
40
|
-
raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
mark_transaction_written_if_write(sql)
|
|
44
|
-
|
|
45
|
-
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
|
|
33
|
+
sql = preprocess_query(sql)
|
|
46
34
|
|
|
47
35
|
# puts "[1]internal----->sql: #{sql}, binds: #{binds}"
|
|
48
36
|
type_casted_binds = type_casted_binds(binds)
|
|
@@ -62,11 +50,7 @@ module ArJdbc
|
|
|
62
50
|
end
|
|
63
51
|
|
|
64
52
|
def exec_update(sql, name = 'SQL', binds = NO_BINDS)
|
|
65
|
-
|
|
66
|
-
raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
mark_transaction_written_if_write(sql)
|
|
53
|
+
sql = preprocess_query(sql)
|
|
70
54
|
|
|
71
55
|
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
|
|
72
56
|
|
|
@@ -103,12 +87,6 @@ module ArJdbc
|
|
|
103
87
|
ActiveRecord::Relation::QueryAttribute.new(nil, type_cast(value, column), ActiveModel::Type::Value.new)
|
|
104
88
|
end
|
|
105
89
|
end
|
|
106
|
-
|
|
107
|
-
def preprocess_query(sql)
|
|
108
|
-
check_if_write_query(sql) if respond_to?(:check_if_write_query, true)
|
|
109
|
-
mark_transaction_written_if_write(sql) if respond_to?(:mark_transaction_written_if_write, true)
|
|
110
|
-
sql
|
|
111
|
-
end
|
|
112
90
|
end
|
|
113
91
|
end
|
|
114
92
|
end
|
|
Binary file
|
data/lib/arjdbc/mssql/adapter.rb
CHANGED
data/lib/arjdbc/mssql/column.rb
CHANGED
|
@@ -6,12 +6,12 @@ module ActiveRecord
|
|
|
6
6
|
class MSSQLColumn < Column
|
|
7
7
|
attr_reader :table_name
|
|
8
8
|
|
|
9
|
-
def initialize(name, raw_default, sql_type_metadata = nil, null = true, table_name = nil, default_function = nil, collation = nil, comment: nil)
|
|
9
|
+
def initialize(name, cast_type, raw_default, sql_type_metadata = nil, null = true, table_name = nil, default_function = nil, collation = nil, comment: nil)
|
|
10
10
|
@table_name = table_name
|
|
11
11
|
|
|
12
12
|
default_val, default_fun = extract_default(raw_default)
|
|
13
13
|
|
|
14
|
-
super(name, default_val, sql_type_metadata, null, default_fun, collation: collation, comment: comment)
|
|
14
|
+
super(name, cast_type, default_val, sql_type_metadata, null, default_fun, collation: collation, comment: comment)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def extract_default(value)
|
|
@@ -92,7 +92,7 @@ module ActiveRecord
|
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
-
def internal_exec_query(sql, name = 'SQL', binds = [], prepare: false, async: false, allow_retry: false)
|
|
95
|
+
def internal_exec_query(sql, name = 'SQL', binds = [], prepare: false, async: false, allow_retry: false, materialize_transactions: true)
|
|
96
96
|
sql = preprocess_query(sql)
|
|
97
97
|
|
|
98
98
|
# binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
|
|
@@ -55,7 +55,7 @@ module ActiveRecord
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def add_column_options!(sql, options)
|
|
58
|
-
sql << " DEFAULT #{
|
|
58
|
+
sql << " DEFAULT #{quote_default_expression_for_column_definition(options[:default], options[:column])}" if options_include_default?(options)
|
|
59
59
|
|
|
60
60
|
sql << ' NOT NULL' if options[:null] == false
|
|
61
61
|
|
|
@@ -419,6 +419,10 @@ module ActiveRecord
|
|
|
419
419
|
field
|
|
420
420
|
end
|
|
421
421
|
|
|
422
|
+
def fetch_type_metadata(sql_type)
|
|
423
|
+
MSSQL::TypeMetadata.new(super(sql_type))
|
|
424
|
+
end
|
|
425
|
+
|
|
422
426
|
def create_db_edition_options(options = {})
|
|
423
427
|
edition_config = options.select { |k, _v| k.match?('azure') }
|
|
424
428
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
module ConnectionAdapters
|
|
5
|
+
module MSSQL
|
|
6
|
+
class TypeMetadata < DelegateClass(SqlTypeMetadata)
|
|
7
|
+
undef to_yaml if method_defined?(:to_yaml)
|
|
8
|
+
|
|
9
|
+
include Deduplicable
|
|
10
|
+
|
|
11
|
+
def initialize(type_metadata)
|
|
12
|
+
super(type_metadata)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def ==(other)
|
|
16
|
+
other.is_a?(TypeMetadata) &&
|
|
17
|
+
__getobj__ == other.__getobj__
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
alias eql? ==
|
|
21
|
+
|
|
22
|
+
def hash
|
|
23
|
+
TypeMetadata.hash ^
|
|
24
|
+
__getobj__.hash
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def deduplicated
|
|
30
|
+
__setobj__(__getobj__.deduplicate)
|
|
31
|
+
super
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -20,12 +20,13 @@ module ActiveRecord
|
|
|
20
20
|
|
|
21
21
|
# This is the Rails binary type
|
|
22
22
|
class VarbinaryMax < ActiveRecord::Type::Binary
|
|
23
|
-
def
|
|
24
|
-
|
|
23
|
+
def initialize(**args)
|
|
24
|
+
super
|
|
25
|
+
@limit = 2_147_483_647
|
|
25
26
|
end
|
|
26
27
|
|
|
27
|
-
def
|
|
28
|
-
|
|
28
|
+
def type
|
|
29
|
+
:binary
|
|
29
30
|
end
|
|
30
31
|
end
|
|
31
32
|
|
|
@@ -7,32 +7,35 @@ module ActiveRecord
|
|
|
7
7
|
module Type
|
|
8
8
|
|
|
9
9
|
class Text < ActiveRecord::Type::String
|
|
10
|
-
def
|
|
11
|
-
|
|
10
|
+
def initialize(**args)
|
|
11
|
+
super
|
|
12
|
+
@limit = 2_147_483_647
|
|
12
13
|
end
|
|
13
14
|
|
|
14
|
-
def
|
|
15
|
-
|
|
15
|
+
def type
|
|
16
|
+
:text_basic
|
|
16
17
|
end
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
class Ntext < ActiveRecord::Type::String
|
|
20
|
-
def
|
|
21
|
-
|
|
21
|
+
def initialize(**args)
|
|
22
|
+
super
|
|
23
|
+
@limit = 2_147_483_647
|
|
22
24
|
end
|
|
23
25
|
|
|
24
|
-
def
|
|
25
|
-
|
|
26
|
+
def type
|
|
27
|
+
:ntext
|
|
26
28
|
end
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
class Image < ActiveRecord::Type::Binary
|
|
30
|
-
def
|
|
31
|
-
|
|
32
|
+
def initialize(**args)
|
|
33
|
+
super
|
|
34
|
+
@limit = 2_147_483_647
|
|
32
35
|
end
|
|
33
36
|
|
|
34
|
-
def
|
|
35
|
-
|
|
37
|
+
def type
|
|
38
|
+
:image
|
|
36
39
|
end
|
|
37
40
|
end
|
|
38
41
|
|
|
@@ -19,12 +19,13 @@ module ActiveRecord
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
class VarcharMax < ActiveRecord::Type::String
|
|
22
|
-
def
|
|
23
|
-
|
|
22
|
+
def initialize(**args)
|
|
23
|
+
super
|
|
24
|
+
@limit = 2_147_483_647
|
|
24
25
|
end
|
|
25
26
|
|
|
26
|
-
def
|
|
27
|
-
|
|
27
|
+
def type
|
|
28
|
+
:varchar_max
|
|
28
29
|
end
|
|
29
30
|
end
|
|
30
31
|
|
|
@@ -43,12 +44,13 @@ module ActiveRecord
|
|
|
43
44
|
|
|
44
45
|
# This is Rails logical text type
|
|
45
46
|
class NvarcharMax < ActiveRecord::Type::String
|
|
46
|
-
def
|
|
47
|
-
|
|
47
|
+
def initialize(**args)
|
|
48
|
+
super
|
|
49
|
+
@limit = 2_147_483_647
|
|
48
50
|
end
|
|
49
51
|
|
|
50
|
-
def
|
|
51
|
-
|
|
52
|
+
def type
|
|
53
|
+
:text
|
|
52
54
|
end
|
|
53
55
|
end
|
|
54
56
|
|
data/lib/arjdbc/mssql.rb
CHANGED
|
@@ -957,8 +957,6 @@ module ActiveRecord::ConnectionAdapters
|
|
|
957
957
|
FEATURE_NOT_SUPPORTED = "0A000" # :nodoc:
|
|
958
958
|
|
|
959
959
|
def execute_and_clear(sql, name, binds, prepare: false, async: false)
|
|
960
|
-
check_if_write_query(sql)
|
|
961
|
-
|
|
962
960
|
if !prepare || without_prepared_statement?(binds)
|
|
963
961
|
result = exec_no_cache(sql, name, binds, async: async)
|
|
964
962
|
else
|
|
@@ -975,7 +973,6 @@ module ActiveRecord::ConnectionAdapters
|
|
|
975
973
|
|
|
976
974
|
def exec_no_cache(sql, name, binds, async: false)
|
|
977
975
|
materialize_transactions
|
|
978
|
-
mark_transaction_written_if_write(sql)
|
|
979
976
|
|
|
980
977
|
# make sure we carry over any changes to ActiveRecord.default_timezone that have been
|
|
981
978
|
# made since we established the connection
|
|
@@ -993,7 +990,6 @@ module ActiveRecord::ConnectionAdapters
|
|
|
993
990
|
|
|
994
991
|
def exec_cache(sql, name, binds, async: false)
|
|
995
992
|
materialize_transactions
|
|
996
|
-
mark_transaction_written_if_write(sql)
|
|
997
993
|
update_typemap_for_default_timezone
|
|
998
994
|
|
|
999
995
|
stmt_key = prepare_statement(sql, binds)
|
|
@@ -11,6 +11,13 @@ module ArJdbc
|
|
|
11
11
|
_arjdbc_array_parser.parse_pg_array(value)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
# Returns an array of the names of all schemas presently in the effective search path,
|
|
15
|
+
# in their priority order.
|
|
16
|
+
def current_schemas # :nodoc:
|
|
17
|
+
schemas = query_value("SELECT current_schemas(false)", "SCHEMA")
|
|
18
|
+
decode_string_array(schemas)
|
|
19
|
+
end
|
|
20
|
+
|
|
14
21
|
private
|
|
15
22
|
|
|
16
23
|
def _arjdbc_array_parser
|
|
@@ -4,7 +4,7 @@ require 'active_record/tasks/database_tasks'
|
|
|
4
4
|
|
|
5
5
|
module ArJdbc
|
|
6
6
|
module Tasks # :nodoc:
|
|
7
|
-
class MSSQLDatabaseTasks # :nodoc:
|
|
7
|
+
class MSSQLDatabaseTasks < ActiveRecord::Tasks::AbstractTasks # :nodoc:
|
|
8
8
|
def self.using_database_configurations?
|
|
9
9
|
true
|
|
10
10
|
end
|
|
@@ -127,25 +127,5 @@ module ArJdbc
|
|
|
127
127
|
msg
|
|
128
128
|
end
|
|
129
129
|
end
|
|
130
|
-
|
|
131
|
-
module DatabaseTasksMSSQL
|
|
132
|
-
extend ActiveSupport::Concern
|
|
133
|
-
|
|
134
|
-
module ClassMethods
|
|
135
|
-
|
|
136
|
-
def check_protected_environments!
|
|
137
|
-
super
|
|
138
|
-
rescue ActiveRecord::JDBCError => e
|
|
139
|
-
case e.message
|
|
140
|
-
when /cannot open database .* requested by the login/i
|
|
141
|
-
else
|
|
142
|
-
raise
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
ActiveRecord::Tasks::DatabaseTasks.send(:include, DatabaseTasksMSSQL)
|
|
150
130
|
end
|
|
151
131
|
end
|
data/lib/arjdbc/version.rb
CHANGED
|
@@ -3186,9 +3186,11 @@ public class RubyJdbcConnection extends RubyObject {
|
|
|
3186
3186
|
|
|
3187
3187
|
final IRubyObject type_metadata = adapter.callMethod(context, "fetch_type_metadata", sqlType);
|
|
3188
3188
|
|
|
3189
|
+
final IRubyObject cast_type = adapter.callMethod(context, "lookup_cast_type", sqlType);
|
|
3190
|
+
|
|
3189
3191
|
// (name, default, sql_type_metadata = nil, null = true, table_name = nil, default_function = nil, collation = nil, comment: nil)
|
|
3190
3192
|
final IRubyObject[] args = new IRubyObject[] {
|
|
3191
|
-
columnName, defaultValue, type_metadata, nullable, tableName
|
|
3193
|
+
columnName, cast_type, defaultValue, type_metadata, nullable, tableName
|
|
3192
3194
|
};
|
|
3193
3195
|
columns.append(context, Column.newInstance(context, args, Block.NULL_BLOCK));
|
|
3194
3196
|
}
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord-jdbc-alt-adapter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 80.
|
|
4
|
+
version: 80.1.0.beta1
|
|
5
5
|
platform: java
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Sieger, Ola Bini, Karol Bucek, Jesse Chavez, and JRuby contributors
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 8.
|
|
18
|
+
version: 8.1.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 8.
|
|
25
|
+
version: 8.1.0
|
|
26
26
|
description: 'Fork of the ActiveRecord JDBC adapter with support for SQL Server and
|
|
27
27
|
Azure SQL, for more information and help look at the README file in the github repository.
|
|
28
28
|
AR-JDBC is a database adapter for Rails'' ActiveRecord component designed to be
|
|
@@ -124,6 +124,7 @@ files:
|
|
|
124
124
|
- lib/arjdbc/mssql/schema_statements.rb
|
|
125
125
|
- lib/arjdbc/mssql/server_version.rb
|
|
126
126
|
- lib/arjdbc/mssql/transaction.rb
|
|
127
|
+
- lib/arjdbc/mssql/type_metadata.rb
|
|
127
128
|
- lib/arjdbc/mssql/types.rb
|
|
128
129
|
- lib/arjdbc/mssql/types/binary_types.rb
|
|
129
130
|
- lib/arjdbc/mssql/types/date_and_time_types.rb
|