activerecord-jdbc-alt-adapter 52.4.0-java → 61.0.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.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.nvimlog +0 -0
  4. data/.travis.yml +63 -39
  5. data/Gemfile +11 -4
  6. data/README.md +55 -35
  7. data/Rakefile +1 -1
  8. data/Rakefile.jdbc +8 -1
  9. data/activerecord-jdbc-adapter.gemspec +6 -9
  10. data/activerecord-jdbc-alt-adapter.gemspec +9 -12
  11. data/lib/arel/visitors/postgresql_jdbc.rb +1 -1
  12. data/lib/arel/visitors/sqlserver.rb +49 -23
  13. data/lib/arjdbc/abstract/connection_management.rb +7 -0
  14. data/lib/arjdbc/abstract/core.rb +17 -23
  15. data/lib/arjdbc/abstract/database_statements.rb +30 -2
  16. data/lib/arjdbc/abstract/statement_cache.rb +2 -5
  17. data/lib/arjdbc/abstract/transaction_support.rb +22 -7
  18. data/lib/arjdbc/db2/column.rb +0 -39
  19. data/lib/arjdbc/derby/adapter.rb +1 -20
  20. data/lib/arjdbc/firebird/adapter.rb +0 -21
  21. data/lib/arjdbc/h2/adapter.rb +0 -15
  22. data/lib/arjdbc/hsqldb/adapter.rb +0 -14
  23. data/lib/arjdbc/informix/adapter.rb +0 -23
  24. data/lib/arjdbc/jdbc/adapter.rb +3 -1
  25. data/lib/arjdbc/jdbc/adapter_require.rb +3 -1
  26. data/lib/arjdbc/jdbc/base_ext.rb +3 -1
  27. data/lib/arjdbc/jdbc/callbacks.rb +2 -0
  28. data/lib/arjdbc/jdbc/column.rb +2 -0
  29. data/lib/arjdbc/jdbc/connection.rb +2 -0
  30. data/lib/arjdbc/jdbc/connection_methods.rb +2 -0
  31. data/lib/arjdbc/jdbc/error.rb +2 -0
  32. data/lib/arjdbc/jdbc/extension.rb +2 -0
  33. data/lib/arjdbc/jdbc/java.rb +3 -1
  34. data/lib/arjdbc/jdbc/railtie.rb +3 -1
  35. data/lib/arjdbc/jdbc/rake_tasks.rb +3 -1
  36. data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +3 -1
  37. data/lib/arjdbc/jdbc/type_cast.rb +2 -0
  38. data/lib/arjdbc/jdbc/type_converter.rb +2 -0
  39. data/lib/arjdbc/mssql.rb +3 -1
  40. data/lib/arjdbc/mssql/adapter.rb +114 -36
  41. data/lib/arjdbc/mssql/column.rb +19 -1
  42. data/lib/arjdbc/mssql/connection_methods.rb +10 -2
  43. data/lib/arjdbc/mssql/database_limits.rb +9 -0
  44. data/lib/arjdbc/mssql/database_statements.rb +44 -6
  45. data/lib/arjdbc/mssql/errors.rb +2 -0
  46. data/lib/arjdbc/mssql/explain_support.rb +3 -1
  47. data/lib/arjdbc/mssql/extensions/attribute_methods.rb +6 -2
  48. data/lib/arjdbc/mssql/extensions/calculations.rb +2 -0
  49. data/lib/arjdbc/mssql/quoting.rb +38 -0
  50. data/lib/arjdbc/mssql/schema_creation.rb +25 -3
  51. data/lib/arjdbc/mssql/schema_definitions.rb +10 -0
  52. data/lib/arjdbc/mssql/schema_dumper.rb +2 -0
  53. data/lib/arjdbc/mssql/schema_statements.rb +92 -22
  54. data/lib/arjdbc/mssql/transaction.rb +2 -0
  55. data/lib/arjdbc/mssql/types.rb +2 -0
  56. data/lib/arjdbc/mssql/types/binary_types.rb +2 -0
  57. data/lib/arjdbc/mssql/types/date_and_time_types.rb +2 -0
  58. data/lib/arjdbc/mssql/types/deprecated_types.rb +2 -0
  59. data/lib/arjdbc/mssql/types/numeric_types.rb +2 -0
  60. data/lib/arjdbc/mssql/types/string_types.rb +2 -0
  61. data/lib/arjdbc/mssql/utils.rb +2 -0
  62. data/lib/arjdbc/mysql/adapter.rb +59 -21
  63. data/lib/arjdbc/mysql/connection_methods.rb +6 -1
  64. data/lib/arjdbc/postgresql/adapter.rb +257 -219
  65. data/lib/arjdbc/postgresql/base/array_decoder.rb +2 -0
  66. data/lib/arjdbc/postgresql/base/array_encoder.rb +4 -2
  67. data/lib/arjdbc/postgresql/base/array_parser.rb +4 -2
  68. data/lib/arjdbc/postgresql/base/pgconn.rb +2 -0
  69. data/lib/arjdbc/postgresql/column.rb +6 -4
  70. data/lib/arjdbc/postgresql/connection_methods.rb +1 -0
  71. data/lib/arjdbc/postgresql/name.rb +2 -0
  72. data/lib/arjdbc/postgresql/oid_types.rb +7 -4
  73. data/lib/arjdbc/sqlite3/adapter.rb +266 -221
  74. data/lib/arjdbc/sqlite3/connection_methods.rb +26 -4
  75. data/lib/arjdbc/tasks/databases.rake +21 -13
  76. data/lib/arjdbc/tasks/mssql_database_tasks.rb +126 -25
  77. data/lib/arjdbc/util/quoted_cache.rb +3 -1
  78. data/lib/arjdbc/util/serialized_attributes.rb +3 -1
  79. data/lib/arjdbc/util/table_copier.rb +3 -1
  80. data/lib/arjdbc/version.rb +3 -1
  81. data/pom.xml +4 -4
  82. data/rakelib/01-tomcat.rake +2 -2
  83. data/rakelib/rails.rake +1 -1
  84. data/src/java/arjdbc/ArJdbcModule.java +5 -5
  85. data/src/java/arjdbc/jdbc/DriverWrapper.java +1 -9
  86. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +549 -691
  87. data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +88 -0
  88. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +13 -23
  89. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +125 -53
  90. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +97 -103
  91. data/src/java/arjdbc/util/DateTimeUtils.java +12 -4
  92. metadata +10 -18
@@ -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
@@ -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
@@ -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'.freeze
99
+ ADAPTER_NAME = 'JDBC'
98
100
 
99
101
  # @return [String] the 'JDBC' adapter name.
100
102
  def adapter_name
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
 
3
5
  if defined? ConnectionAdapters::ConnectionSpecification::Resolver # 4.0
@@ -43,4 +45,4 @@ module ActiveRecord
43
45
 
44
46
  end
45
47
 
46
- end
48
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  class << Base
3
5
  m = Module.new do
@@ -12,4 +14,4 @@ module ActiveRecord
12
14
 
13
15
  self.prepend(m)
14
16
  end
15
- end
17
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord::ConnectionAdapters
2
4
  module Jdbc
3
5
  # ActiveRecord connection pool callbacks for JDBC.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  module ConnectionAdapters
3
5
  module Jdbc
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  module ConnectionAdapters
3
5
  # JDBC (connection) base class, custom adapters we support likely extend
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ArJdbc
2
4
  ConnectionMethods = ::ActiveRecord::ConnectionHandling
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  # Represents exceptions that have propagated up through the JDBC API.
3
5
  class JDBCError < WrappedDatabaseException
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ArJdbc
2
4
 
3
5
  # Defines an AR-JDBC extension. An extension consists of a declaration using
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'java'
2
4
  require 'arjdbc/jdbc/adapter_java'
3
5
 
@@ -10,4 +12,4 @@ module ActiveRecord
10
12
  Types = ::Java::JavaSql::Types
11
13
  end
12
14
  end
13
- end
15
+ end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'arjdbc/railtie'
2
- ArJdbc.deprecate "require 'arjdbc/railtie' instead of 'arjdbc/jdbc/railtie'"
4
+ ArJdbc.deprecate "require 'arjdbc/railtie' instead of 'arjdbc/jdbc/railtie'"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  load 'arjdbc/tasks.rb'
2
4
 
3
- ArJdbc.deprecate "load 'arjdbc/tasks.rb' instead of 'arjdbc/jdbc/rake_tasks.rb'"
5
+ ArJdbc.deprecate "load 'arjdbc/tasks.rb' instead of 'arjdbc/jdbc/rake_tasks.rb'"
@@ -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'"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_record/connection_adapters/column'
2
4
 
3
5
  module ActiveRecord::ConnectionAdapters
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  module ConnectionAdapters
3
5
  # I want to use JDBC's DatabaseMetaData#getTypeInfo to choose the best native types to
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
- ArJdbc.warn_unsupported_adapter 'mssql', [5, 2] # warns on AR >= 4.2
8
+
9
+ ArJdbc.warn_unsupported_adapter 'mssql', [6, 1] # warns on AR >= 4.2
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
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
- unless mssql_major_version >= 11
72
- raise "Your MSSQL #{mssql_version_year} is too old. This adapter supports MSSQL >= 2012."
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,15 +222,25 @@ module ActiveRecord
201
222
 
202
223
  alias_method :current_schema=, :default_schema=
203
224
 
204
- # Overrides method in abstract adapter
205
- # FIXME: This needs to be fixed the we find a way how to
206
- # get the collation per column basis. At the moment we only use
207
- # the global database collation
208
- def case_sensitive_comparison(table, attribute, column, value)
209
- if [:string, :text].include?(column.type) && collation && !collation.match(/_CS/)
210
- table[attribute].eq(Arel::Nodes::Bin.new(value))
211
- # elsif value.acts_like?(:string)
212
- # table[attribute].eq(Arel::Nodes::Bin.new(Arel::Nodes::BindParam.new))
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) # :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))
234
+ else
235
+ super
236
+ end
237
+ end
238
+
239
+ def case_sensitive_comparison(attribute, value)
240
+ column = column_for_attribute(attribute)
241
+
242
+ if [:string, :text].include?(column.type) && collation && !collation.match(/_CS/) && !value.nil?
243
+ attribute.eq(Arel::Nodes::Bin.new(value))
213
244
  else
214
245
  super
215
246
  end
@@ -241,6 +272,27 @@ module ActiveRecord
241
272
  MSSQL_VERSION_YEAR[mssql_major_version.to_i]
242
273
  end
243
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
+
244
296
  def tables_with_referential_integrity
245
297
  schema_and_tables_sql = %(
246
298
  SELECT s.name, o.name
@@ -259,20 +311,24 @@ module ActiveRecord
259
311
 
260
312
  private
261
313
 
262
- def translate_exception(exception, message)
314
+ def translate_exception(exception, message:, sql:, binds:)
263
315
  case message
316
+ when /no connection available/i
317
+ ConnectionNotEstablished.new(exception)
264
318
  when /(cannot insert duplicate key .* with unique index) | (violation of unique key constraint)/i
265
- RecordNotUnique.new(message)
319
+ RecordNotUnique.new(message, sql: sql, binds: binds)
266
320
  when /Lock request time out period exceeded/i
267
- LockTimeout.new(message)
321
+ LockTimeout.new(message, sql: sql, binds: binds)
268
322
  when /The .* statement conflicted with the FOREIGN KEY constraint/
269
- ActiveRecord::InvalidForeignKey.new(message)
323
+ InvalidForeignKey.new(message, sql: sql, binds: binds)
324
+ when /The .* statement conflicted with the REFERENCE constraint/
325
+ InvalidForeignKey.new(message, sql: sql, binds: binds)
270
326
  when /(String or binary data would be truncated)/i
271
- ActiveRecord::ValueTooLong.new(message)
327
+ ValueTooLong.new(message, sql: sql, binds: binds)
272
328
  when /Cannot insert the value NULL into column .* does not allow nulls/
273
- ActiveRecord::NotNullViolation.new(message)
329
+ NotNullViolation.new(message, sql: sql, binds: binds)
274
330
  when /Arithmetic overflow error converting expression/
275
- ActiveRecord::RangeError.new(message)
331
+ RangeError.new(message, sql: sql, binds: binds)
276
332
  else
277
333
  super
278
334
  end
@@ -380,6 +436,28 @@ module ActiveRecord
380
436
  map.register_type 'ntext', MSSQL::Type::Ntext.new
381
437
  map.register_type 'image', MSSQL::Type::Image.new
382
438
  end
439
+
440
+ # Returns an array of Column objects for the table specified by +table_name+.
441
+ # See the concrete implementation for details on the expected parameter values.
442
+ # NOTE: This is ready, all implemented in the java part of adapter,
443
+ # it uses MSSQLColumn, SqlTypeMetadata, etc.
444
+ def column_definitions(table_name)
445
+ log('JDBC: GETCOLUMNS', 'SCHEMA') { @connection.columns(table_name) }
446
+ rescue => e
447
+ # raise translate_exception_class(e, nil)
448
+ # FIXME: this breaks one arjdbc test but fixes activerecord tests
449
+ # (table name alias). Also it behaves similarly to the CRuby adapter
450
+ # which returns an empty array too. (postgres throws a exception)
451
+ []
452
+ end
453
+
454
+ def arel_visitor # :nodoc:
455
+ ::Arel::Visitors::SQLServer.new(self)
456
+ end
457
+
458
+ def build_statement_pool
459
+ # NOTE: @statements is set in StatementCache module
460
+ end
383
461
  end
384
462
  end
385
463
  end