activerecord-jdbc-alt-adapter 52.2.3-java → 60.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 +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +80 -52
- data/Gemfile +10 -3
- data/README.md +55 -37
- data/Rakefile +31 -5
- data/Rakefile.jdbc +8 -1
- data/activerecord-jdbc-adapter.gemspec +6 -9
- data/activerecord-jdbc-alt-adapter.gemspec +6 -9
- data/lib/arel/visitors/sqlserver.rb +33 -23
- data/lib/arjdbc/abstract/connection_management.rb +7 -0
- data/lib/arjdbc/abstract/core.rb +17 -24
- data/lib/arjdbc/abstract/database_statements.rb +31 -20
- data/lib/arjdbc/abstract/statement_cache.rb +2 -5
- data/lib/arjdbc/abstract/transaction_support.rb +5 -3
- data/lib/arjdbc/db2/column.rb +0 -39
- data/lib/arjdbc/derby/adapter.rb +1 -20
- data/lib/arjdbc/firebird/adapter.rb +0 -21
- data/lib/arjdbc/h2/adapter.rb +0 -15
- data/lib/arjdbc/hsqldb/adapter.rb +0 -14
- data/lib/arjdbc/informix/adapter.rb +0 -23
- data/lib/arjdbc/jdbc.rb +0 -4
- data/lib/arjdbc/jdbc/adapter.rb +3 -1
- data/lib/arjdbc/jdbc/adapter_require.rb +3 -1
- data/lib/arjdbc/jdbc/base_ext.rb +3 -1
- data/lib/arjdbc/jdbc/callbacks.rb +2 -0
- data/lib/arjdbc/jdbc/column.rb +3 -5
- data/lib/arjdbc/jdbc/connection.rb +2 -0
- data/lib/arjdbc/jdbc/connection_methods.rb +2 -0
- data/lib/arjdbc/jdbc/error.rb +2 -0
- data/lib/arjdbc/jdbc/extension.rb +2 -0
- data/lib/arjdbc/jdbc/java.rb +3 -1
- data/lib/arjdbc/jdbc/railtie.rb +3 -1
- data/lib/arjdbc/jdbc/rake_tasks.rb +3 -1
- data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +3 -1
- data/lib/arjdbc/jdbc/type_cast.rb +2 -0
- data/lib/arjdbc/jdbc/type_converter.rb +2 -0
- data/lib/arjdbc/mssql.rb +3 -1
- data/lib/arjdbc/mssql/adapter.rb +112 -46
- data/lib/arjdbc/mssql/column.rb +5 -1
- data/lib/arjdbc/mssql/connection_methods.rb +13 -2
- data/lib/arjdbc/mssql/database_limits.rb +2 -0
- data/lib/arjdbc/mssql/database_statements.rb +44 -6
- data/lib/arjdbc/mssql/errors.rb +2 -0
- data/lib/arjdbc/mssql/explain_support.rb +3 -1
- data/lib/arjdbc/mssql/extensions/attribute_methods.rb +5 -1
- data/lib/arjdbc/mssql/extensions/calculations.rb +2 -0
- data/lib/arjdbc/mssql/quoting.rb +38 -0
- data/lib/arjdbc/mssql/schema_creation.rb +24 -2
- data/lib/arjdbc/mssql/schema_definitions.rb +10 -0
- data/lib/arjdbc/mssql/schema_dumper.rb +2 -0
- data/lib/arjdbc/mssql/schema_statements.rb +63 -21
- data/lib/arjdbc/mssql/transaction.rb +2 -0
- data/lib/arjdbc/mssql/types.rb +2 -0
- data/lib/arjdbc/mssql/types/binary_types.rb +2 -0
- data/lib/arjdbc/mssql/types/date_and_time_types.rb +2 -0
- data/lib/arjdbc/mssql/types/deprecated_types.rb +2 -0
- data/lib/arjdbc/mssql/types/numeric_types.rb +2 -0
- data/lib/arjdbc/mssql/types/string_types.rb +2 -0
- data/lib/arjdbc/mssql/utils.rb +2 -0
- data/lib/arjdbc/mysql/adapter.rb +47 -18
- data/lib/arjdbc/mysql/connection_methods.rb +13 -7
- data/lib/arjdbc/postgresql/adapter.rb +240 -214
- data/lib/arjdbc/postgresql/base/array_decoder.rb +2 -0
- data/lib/arjdbc/postgresql/base/array_encoder.rb +4 -2
- data/lib/arjdbc/postgresql/base/array_parser.rb +4 -2
- data/lib/arjdbc/postgresql/base/pgconn.rb +2 -0
- data/lib/arjdbc/postgresql/column.rb +11 -6
- data/lib/arjdbc/postgresql/connection_methods.rb +3 -1
- data/lib/arjdbc/postgresql/name.rb +2 -0
- data/lib/arjdbc/postgresql/oid_types.rb +3 -1
- data/lib/arjdbc/sqlite3/adapter.rb +188 -180
- data/lib/arjdbc/sqlite3/connection_methods.rb +16 -4
- data/lib/arjdbc/tasks/databases.rake +13 -10
- data/lib/arjdbc/tasks/mssql_database_tasks.rb +49 -5
- data/lib/arjdbc/util/quoted_cache.rb +3 -1
- data/lib/arjdbc/util/serialized_attributes.rb +3 -1
- data/lib/arjdbc/util/table_copier.rb +3 -1
- data/lib/arjdbc/version.rb +1 -1
- data/pom.xml +4 -4
- data/rakelib/01-tomcat.rake +2 -2
- data/rakelib/02-test.rake +0 -2
- data/rakelib/rails.rake +1 -1
- data/src/java/arjdbc/ArJdbcModule.java +5 -5
- data/src/java/arjdbc/jdbc/DriverWrapper.java +1 -9
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +468 -637
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +319 -38
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +13 -23
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +44 -31
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +94 -99
- data/src/java/arjdbc/util/DateTimeUtils.java +34 -12
- metadata +7 -17
data/lib/arjdbc/derby/adapter.rb
CHANGED
@@ -65,25 +65,6 @@ module ArJdbc
|
|
65
65
|
limit
|
66
66
|
end
|
67
67
|
|
68
|
-
def simplified_type(field_type)
|
69
|
-
case field_type
|
70
|
-
when /^smallint/i then Derby.emulate_booleans? ? :boolean : :integer
|
71
|
-
when /^bigint|int/i then :integer
|
72
|
-
when /^real|double/i then :float
|
73
|
-
when /^dec/i then # DEC is a DECIMAL alias
|
74
|
-
extract_scale(field_type) == 0 ? :integer : :decimal
|
75
|
-
when /^timestamp/i then :datetime
|
76
|
-
when /^xml/i then :xml
|
77
|
-
when 'long varchar' then :text
|
78
|
-
when /for bit data/i then :binary
|
79
|
-
# :name=>"long varchar for bit data", :limit=>32700
|
80
|
-
# :name=>"varchar() for bit data", :limit=>32672
|
81
|
-
# :name=>"char() for bit data", :limit=>254}
|
82
|
-
else
|
83
|
-
super
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
68
|
# Post process default value from JDBC into a Rails-friendly format (columns{-internal})
|
88
69
|
def default_value(value)
|
89
70
|
# JDBC returns column default strings with actual single quotes around the value.
|
@@ -420,7 +401,7 @@ module ArJdbc
|
|
420
401
|
|
421
402
|
# @override
|
422
403
|
def supports_ddl_transactions?; true end
|
423
|
-
|
404
|
+
|
424
405
|
# @override
|
425
406
|
def supports_foreign_keys?; true end
|
426
407
|
|
@@ -38,27 +38,6 @@ module ArJdbc
|
|
38
38
|
return $1 unless $1.upcase == 'NULL'
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def simplified_type(field_type)
|
45
|
-
case field_type
|
46
|
-
when /timestamp/i then :datetime
|
47
|
-
when /^smallint/i then :integer
|
48
|
-
when /^bigint|int/i then :integer
|
49
|
-
when /^double/i then :float # double precision
|
50
|
-
when /^decimal/i then
|
51
|
-
extract_scale(field_type) == 0 ? :integer : :decimal
|
52
|
-
when /^char\(1\)$/i then Firebird.emulate_booleans? ? :boolean : :string
|
53
|
-
when /^char/i then :string
|
54
|
-
when /^blob\ssub_type\s(\d)/i
|
55
|
-
return :binary if $1 == '0'
|
56
|
-
return :text if $1 == '1'
|
57
|
-
else
|
58
|
-
super
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
41
|
end
|
63
42
|
|
64
43
|
# @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_column_class
|
data/lib/arjdbc/h2/adapter.rb
CHANGED
@@ -47,21 +47,6 @@ module ArJdbc
|
|
47
47
|
limit
|
48
48
|
end
|
49
49
|
|
50
|
-
def simplified_type(field_type)
|
51
|
-
case field_type
|
52
|
-
when /^bit|bool/i then :boolean
|
53
|
-
when /^signed|year/i then :integer
|
54
|
-
when /^real|double/i then :float
|
55
|
-
when /^varchar/i then :string
|
56
|
-
when /^longvarchar/i then :text
|
57
|
-
when /^binary|raw|bytea/i then :binary
|
58
|
-
when /varbinary/i then :binary # longvarbinary, varbinary
|
59
|
-
when /^blob|image|oid/i then :binary
|
60
|
-
else
|
61
|
-
super
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
50
|
# Post process default value from JDBC into a Rails-friendly format (columns{-internal})
|
66
51
|
def default_value(value)
|
67
52
|
# H2 auto-generated key default value
|
@@ -42,20 +42,6 @@ module ArJdbc
|
|
42
42
|
limit
|
43
43
|
end
|
44
44
|
|
45
|
-
def simplified_type(field_type)
|
46
|
-
case field_type
|
47
|
-
when /^nvarchar/i then :string
|
48
|
-
when /^character/i then :string
|
49
|
-
when /^longvarchar/i then :text
|
50
|
-
when /int/i then :integer # TINYINT, SMALLINT, BIGINT, INT
|
51
|
-
when /real|double/i then :float
|
52
|
-
when /^bit/i then :boolean
|
53
|
-
when /binary/i then :binary # VARBINARY, LONGVARBINARY
|
54
|
-
else
|
55
|
-
super
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
45
|
# Post process default value from JDBC into a Rails-friendly format (columns{-internal})
|
60
46
|
def default_value(value)
|
61
47
|
# JDBC returns column default strings with actual single quotes around the value.
|
@@ -28,11 +28,6 @@ module ArJdbc
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
# @see ActiveRecord::ConnectionAdapters::JdbcColumn#column_types
|
32
|
-
def self.column_selector
|
33
|
-
[ /informix/i, lambda { |cfg, column| column.extend(ColumnMethods) } ]
|
34
|
-
end
|
35
|
-
|
36
31
|
JdbcConnection = ::ActiveRecord::ConnectionAdapters::InformixJdbcConnection
|
37
32
|
|
38
33
|
# @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_connection_class
|
@@ -45,20 +40,6 @@ module ArJdbc
|
|
45
40
|
::ActiveRecord::ConnectionAdapters::InformixColumn
|
46
41
|
end
|
47
42
|
|
48
|
-
module ColumnMethods
|
49
|
-
|
50
|
-
private
|
51
|
-
# TODO: Test all Informix column types.
|
52
|
-
def simplified_type(field_type)
|
53
|
-
if field_type =~ /serial/i
|
54
|
-
:primary_key
|
55
|
-
else
|
56
|
-
super
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
43
|
def modify_types(types)
|
63
44
|
super(types)
|
64
45
|
types[:primary_key] = "SERIAL PRIMARY KEY"
|
@@ -152,10 +133,6 @@ module ArJdbc
|
|
152
133
|
end # module ::ArJdbc
|
153
134
|
|
154
135
|
module ActiveRecord::ConnectionAdapters
|
155
|
-
class InformixColumn < JdbcColumn
|
156
|
-
include ::ArJdbc::Informix::ColumnMethods
|
157
|
-
end
|
158
|
-
|
159
136
|
class InformixAdapter < JdbcAdapter
|
160
137
|
include ::ArJdbc::Informix
|
161
138
|
end
|
data/lib/arjdbc/jdbc.rb
CHANGED
@@ -2,12 +2,8 @@ require 'active_support/deprecation'
|
|
2
2
|
|
3
3
|
module ArJdbc
|
4
4
|
|
5
|
-
# @private
|
6
|
-
AR40 = ::ActiveRecord::VERSION::MAJOR > 3
|
7
5
|
# @private
|
8
6
|
AR42 = ::ActiveRecord::VERSION::STRING >= '4.2'
|
9
|
-
# @private
|
10
|
-
AR50 = ::ActiveRecord::VERSION::MAJOR > 4
|
11
7
|
|
12
8
|
# @private
|
13
9
|
AR52 = ::ActiveRecord::VERSION::STRING >= '5.2'
|
data/lib/arjdbc/jdbc/adapter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_record/version'
|
2
4
|
require 'active_record/connection_adapters/abstract_adapter'
|
3
5
|
|
@@ -94,7 +96,7 @@ module ActiveRecord
|
|
94
96
|
nil
|
95
97
|
end
|
96
98
|
|
97
|
-
ADAPTER_NAME = 'JDBC'
|
99
|
+
ADAPTER_NAME = 'JDBC'
|
98
100
|
|
99
101
|
# @return [String] the 'JDBC' adapter name.
|
100
102
|
def adapter_name
|
data/lib/arjdbc/jdbc/base_ext.rb
CHANGED
data/lib/arjdbc/jdbc/column.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActiveRecord
|
2
4
|
module ConnectionAdapters
|
3
5
|
module Jdbc
|
@@ -28,17 +30,13 @@ module ActiveRecord
|
|
28
30
|
|
29
31
|
if ArJdbc::AR52
|
30
32
|
# undefined method `cast' for #<ActiveRecord::ConnectionAdapters::SqlTypeMetadata> on AR52
|
31
|
-
|
33
|
+
else
|
32
34
|
default = args[0].cast(default)
|
33
35
|
|
34
36
|
sql_type = args.delete_at(1)
|
35
37
|
type = args.delete_at(0)
|
36
38
|
|
37
39
|
args.unshift(SqlTypeMetadata.new(:sql_type => sql_type, :type => type))
|
38
|
-
elsif ArJdbc::AR42
|
39
|
-
default = args[0].type_cast_from_database(default)
|
40
|
-
else
|
41
|
-
default = default_value(default)
|
42
40
|
end
|
43
41
|
|
44
42
|
# super <= 4.1: (name, default, sql_type = nil, null = true)
|
data/lib/arjdbc/jdbc/error.rb
CHANGED
data/lib/arjdbc/jdbc/java.rb
CHANGED
data/lib/arjdbc/jdbc/railtie.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'arjdbc/util/serialized_attributes'
|
2
4
|
|
3
|
-
ArJdbc.deprecate "require 'arjdbc/util/serialized_attributes' instead of 'arjdbc/jdbc/serialized_attributes_helper'"
|
5
|
+
ArJdbc.deprecate "require 'arjdbc/util/serialized_attributes' instead of 'arjdbc/jdbc/serialized_attributes_helper'"
|
data/lib/arjdbc/mssql.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'arjdbc'
|
2
2
|
require 'arjdbc/mssql/adapter'
|
3
3
|
require 'arjdbc/mssql/connection_methods'
|
4
|
+
|
4
5
|
module ArJdbc
|
5
6
|
MsSQL = MSSQL # compatibility with 1.2
|
6
7
|
end
|
7
|
-
|
8
|
+
|
9
|
+
ArJdbc.warn_unsupported_adapter 'mssql', [6, 0] # warns on AR >= 4.2
|
data/lib/arjdbc/mssql/adapter.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
ArJdbc.load_java_part :MSSQL
|
4
4
|
|
@@ -68,8 +68,19 @@ module ActiveRecord
|
|
68
68
|
# configure_connection happens in super
|
69
69
|
super(connection, logger, config)
|
70
70
|
|
71
|
-
|
72
|
-
raise "Your
|
71
|
+
if database_version < '11'
|
72
|
+
raise "Your #{mssql_product_name} #{mssql_version_year} is too old. This adapter supports #{mssql_product_name} >= 2012."
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.database_exists?(config)
|
77
|
+
!!ActiveRecord::Base.sqlserver_connection(config)
|
78
|
+
rescue ActiveRecord::JDBCError => e
|
79
|
+
case e.message
|
80
|
+
when /Cannot open database .* requested by the login/
|
81
|
+
false
|
82
|
+
else
|
83
|
+
raise
|
73
84
|
end
|
74
85
|
end
|
75
86
|
|
@@ -101,6 +112,14 @@ module ActiveRecord
|
|
101
112
|
true
|
102
113
|
end
|
103
114
|
|
115
|
+
def supports_savepoints?
|
116
|
+
true
|
117
|
+
end
|
118
|
+
|
119
|
+
def supports_lazy_transactions?
|
120
|
+
true
|
121
|
+
end
|
122
|
+
|
104
123
|
# The MSSQL datetime type doe have precision.
|
105
124
|
def supports_datetime_with_precision?
|
106
125
|
true
|
@@ -121,17 +140,35 @@ module ActiveRecord
|
|
121
140
|
true
|
122
141
|
end
|
123
142
|
|
143
|
+
def supports_insert_on_conflict?
|
144
|
+
false
|
145
|
+
end
|
146
|
+
alias supports_insert_on_duplicate_skip? supports_insert_on_conflict?
|
147
|
+
alias supports_insert_on_duplicate_update? supports_insert_on_conflict?
|
148
|
+
alias supports_insert_conflict_target? supports_insert_on_conflict?
|
149
|
+
|
150
|
+
def build_insert_sql(insert) # :nodoc:
|
151
|
+
# TODO: hope we can implement an upsert like feature
|
152
|
+
"INSERT #{insert.into} #{insert.values_list}"
|
153
|
+
end
|
154
|
+
|
124
155
|
# Overrides abstract method which always returns false
|
125
156
|
def valid_type?(type)
|
126
157
|
!native_database_types[type].nil?
|
127
158
|
end
|
128
159
|
|
129
|
-
# FIXME: to be reviewed.
|
130
160
|
def clear_cache!
|
131
161
|
reload_type_map
|
132
162
|
super
|
133
163
|
end
|
134
164
|
|
165
|
+
def reset!
|
166
|
+
# execute 'IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION'
|
167
|
+
# NOTE: it seems the above line interferes with the jdbc driver
|
168
|
+
# and ending up in connection closed, issue seen in rails 5.2 and 6.0
|
169
|
+
reconnect!
|
170
|
+
end
|
171
|
+
|
135
172
|
def disable_referential_integrity
|
136
173
|
tables = tables_with_referential_integrity
|
137
174
|
|
@@ -163,22 +200,6 @@ module ActiveRecord
|
|
163
200
|
result
|
164
201
|
end
|
165
202
|
|
166
|
-
def arel_visitor # :nodoc:
|
167
|
-
::Arel::Visitors::SQLServer.new(self)
|
168
|
-
end
|
169
|
-
|
170
|
-
def schema_creation # :nodoc:
|
171
|
-
MSSQL::SchemaCreation.new(self)
|
172
|
-
end
|
173
|
-
|
174
|
-
def create_table_definition(*args) # :nodoc:
|
175
|
-
MSSQL::TableDefinition.new(*args)
|
176
|
-
end
|
177
|
-
|
178
|
-
def update_table_definition(table_name, base) #:nodoc:
|
179
|
-
MSSQL::Table.new(table_name, base)
|
180
|
-
end
|
181
|
-
|
182
203
|
# Returns the name of the current security context
|
183
204
|
def current_user
|
184
205
|
@current_user ||= select_value('SELECT CURRENT_USER')
|
@@ -201,34 +222,34 @@ module ActiveRecord
|
|
201
222
|
|
202
223
|
alias_method :current_schema=, :default_schema=
|
203
224
|
|
204
|
-
#
|
205
|
-
#
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
if [:string, :text].include?(column.type) && collation && !collation.match(/_CS/)
|
210
|
-
|
211
|
-
|
212
|
-
|
225
|
+
# FIXME: This needs to be fixed when we implement the collation per
|
226
|
+
# column basis. At the moment we only use the global database collation
|
227
|
+
def default_uniqueness_comparison(attribute, value, klass) # :nodoc:
|
228
|
+
column = column_for_attribute(attribute)
|
229
|
+
|
230
|
+
if [:string, :text].include?(column.type) && collation && !collation.match(/_CS/) && !value.nil?
|
231
|
+
# NOTE: there is a deprecation warning here in the mysql adapter
|
232
|
+
# no sure if it's required.
|
233
|
+
attribute.eq(Arel::Nodes::Bin.new(value))
|
213
234
|
else
|
214
235
|
super
|
215
236
|
end
|
216
237
|
end
|
217
238
|
|
218
|
-
def
|
219
|
-
|
239
|
+
def case_sensitive_comparison(attribute, value)
|
240
|
+
column = column_for_attribute(attribute)
|
220
241
|
|
221
|
-
|
242
|
+
if [:string, :text].include?(column.type) && collation && !collation.match(/_CS/) && !value.nil?
|
243
|
+
attribute.eq(Arel::Nodes::Bin.new(value))
|
244
|
+
else
|
245
|
+
super
|
246
|
+
end
|
222
247
|
end
|
223
248
|
|
224
|
-
def
|
225
|
-
|
249
|
+
def configure_connection
|
250
|
+
# Here goes initial settings per connection
|
226
251
|
|
227
|
-
|
228
|
-
timeout
|
229
|
-
else
|
230
|
-
5_000
|
231
|
-
end
|
252
|
+
set_session_transaction_isolation
|
232
253
|
end
|
233
254
|
|
234
255
|
def set_session_transaction_isolation
|
@@ -251,6 +272,27 @@ module ActiveRecord
|
|
251
272
|
MSSQL_VERSION_YEAR[mssql_major_version.to_i]
|
252
273
|
end
|
253
274
|
|
275
|
+
def mssql_product_version
|
276
|
+
return @mssql_product_version if defined? @mssql_product_version
|
277
|
+
|
278
|
+
@mssql_product_version = @connection.database_product_version
|
279
|
+
end
|
280
|
+
|
281
|
+
def mssql_product_name
|
282
|
+
return @mssql_product_name if defined? @mssql_product_name
|
283
|
+
|
284
|
+
@mssql_product_name = @connection.database_product_name
|
285
|
+
end
|
286
|
+
|
287
|
+
def get_database_version # :nodoc:
|
288
|
+
MSSQLAdapter::Version.new(mssql_product_version)
|
289
|
+
end
|
290
|
+
|
291
|
+
def check_version # :nodoc:
|
292
|
+
# NOTE: hitting the database from here causes trouble when adapter
|
293
|
+
# uses JNDI or Data Source setup.
|
294
|
+
end
|
295
|
+
|
254
296
|
def tables_with_referential_integrity
|
255
297
|
schema_and_tables_sql = %(
|
256
298
|
SELECT s.name, o.name
|
@@ -269,20 +311,22 @@ module ActiveRecord
|
|
269
311
|
|
270
312
|
private
|
271
313
|
|
272
|
-
def translate_exception(exception, message)
|
314
|
+
def translate_exception(exception, message:, sql:, binds:)
|
273
315
|
case message
|
274
316
|
when /(cannot insert duplicate key .* with unique index) | (violation of unique key constraint)/i
|
275
|
-
RecordNotUnique.new(message)
|
317
|
+
RecordNotUnique.new(message, sql: sql, binds: binds)
|
276
318
|
when /Lock request time out period exceeded/i
|
277
|
-
LockTimeout.new(message)
|
319
|
+
LockTimeout.new(message, sql: sql, binds: binds)
|
278
320
|
when /The .* statement conflicted with the FOREIGN KEY constraint/
|
279
|
-
|
321
|
+
InvalidForeignKey.new(message, sql: sql, binds: binds)
|
322
|
+
when /The .* statement conflicted with the REFERENCE constraint/
|
323
|
+
InvalidForeignKey.new(message, sql: sql, binds: binds)
|
280
324
|
when /(String or binary data would be truncated)/i
|
281
|
-
|
325
|
+
ValueTooLong.new(message, sql: sql, binds: binds)
|
282
326
|
when /Cannot insert the value NULL into column .* does not allow nulls/
|
283
|
-
|
327
|
+
NotNullViolation.new(message, sql: sql, binds: binds)
|
284
328
|
when /Arithmetic overflow error converting expression/
|
285
|
-
|
329
|
+
RangeError.new(message, sql: sql, binds: binds)
|
286
330
|
else
|
287
331
|
super
|
288
332
|
end
|
@@ -390,6 +434,28 @@ module ActiveRecord
|
|
390
434
|
map.register_type 'ntext', MSSQL::Type::Ntext.new
|
391
435
|
map.register_type 'image', MSSQL::Type::Image.new
|
392
436
|
end
|
437
|
+
|
438
|
+
# Returns an array of Column objects for the table specified by +table_name+.
|
439
|
+
# See the concrete implementation for details on the expected parameter values.
|
440
|
+
# NOTE: This is ready, all implemented in the java part of adapter,
|
441
|
+
# it uses MSSQLColumn, SqlTypeMetadata, etc.
|
442
|
+
def column_definitions(table_name)
|
443
|
+
log('JDBC: GETCOLUMNS', 'SCHEMA') { @connection.columns(table_name) }
|
444
|
+
rescue => e
|
445
|
+
# raise translate_exception_class(e, nil)
|
446
|
+
# FIXME: this breaks one arjdbc test but fixes activerecord tests
|
447
|
+
# (table name alias). Also it behaves similarly to the CRuby adapter
|
448
|
+
# which returns an empty array too. (postgres throws a exception)
|
449
|
+
[]
|
450
|
+
end
|
451
|
+
|
452
|
+
def arel_visitor # :nodoc:
|
453
|
+
::Arel::Visitors::SQLServer.new(self)
|
454
|
+
end
|
455
|
+
|
456
|
+
def build_statement_pool
|
457
|
+
# NOTE: @statements is set in StatementCache module
|
458
|
+
end
|
393
459
|
end
|
394
460
|
end
|
395
461
|
end
|