activerecord-jdbc-adapter 5.0.pre1 → 50.0

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.

Potentially problematic release.


This version of activerecord-jdbc-adapter might be problematic. Click here for more details.

Files changed (66) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -2
  3. data/.travis.yml +15 -416
  4. data/Gemfile +35 -37
  5. data/README.md +23 -118
  6. data/RUNNING_TESTS.md +31 -26
  7. data/Rakefile +2 -3
  8. data/lib/arjdbc/abstract/connection_management.rb +21 -0
  9. data/lib/arjdbc/abstract/core.rb +62 -0
  10. data/lib/arjdbc/abstract/database_statements.rb +46 -0
  11. data/lib/arjdbc/abstract/statement_cache.rb +58 -0
  12. data/lib/arjdbc/abstract/transaction_support.rb +86 -0
  13. data/lib/arjdbc/derby/adapter.rb +6 -1
  14. data/lib/arjdbc/discover.rb +0 -7
  15. data/lib/arjdbc/firebird/adapter.rb +2 -2
  16. data/lib/arjdbc/jdbc.rb +2 -2
  17. data/lib/arjdbc/jdbc/adapter.rb +10 -252
  18. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  19. data/lib/arjdbc/jdbc/connection.rb +6 -0
  20. data/lib/arjdbc/mysql/adapter.rb +82 -946
  21. data/lib/arjdbc/mysql/connection_methods.rb +4 -2
  22. data/lib/arjdbc/postgresql/adapter.rb +270 -970
  23. data/lib/arjdbc/postgresql/base/array_decoder.rb +26 -0
  24. data/lib/arjdbc/postgresql/base/array_encoder.rb +25 -0
  25. data/lib/arjdbc/postgresql/base/pgconn.rb +8 -5
  26. data/lib/arjdbc/postgresql/column.rb +10 -599
  27. data/lib/arjdbc/postgresql/connection_methods.rb +9 -0
  28. data/lib/arjdbc/postgresql/name.rb +24 -0
  29. data/lib/arjdbc/postgresql/oid_types.rb +28 -109
  30. data/lib/arjdbc/sqlite3/adapter.rb +18 -42
  31. data/lib/arjdbc/tasks/database_tasks.rb +1 -3
  32. data/lib/arjdbc/tasks/db2_database_tasks.rb +2 -2
  33. data/lib/arjdbc/version.rb +1 -1
  34. data/pom.xml +3 -3
  35. data/rakelib/02-test.rake +0 -12
  36. data/rakelib/compile.rake +1 -1
  37. data/rakelib/db.rake +7 -5
  38. data/rakelib/rails.rake +67 -64
  39. data/src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java +1 -17
  40. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +518 -1260
  41. data/src/java/arjdbc/mysql/MySQLModule.java +3 -3
  42. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +53 -134
  43. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +214 -240
  44. data/src/java/arjdbc/sqlite3/SQLite3Module.java +0 -20
  45. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +85 -10
  46. metadata +16 -29
  47. data/Appraisals +0 -41
  48. data/lib/active_record/connection_adapters/oracle_adapter.rb +0 -1
  49. data/lib/arjdbc/common_jdbc_methods.rb +0 -89
  50. data/lib/arjdbc/mysql/bulk_change_table.rb +0 -150
  51. data/lib/arjdbc/mysql/column.rb +0 -162
  52. data/lib/arjdbc/mysql/explain_support.rb +0 -82
  53. data/lib/arjdbc/mysql/schema_creation.rb +0 -58
  54. data/lib/arjdbc/oracle.rb +0 -4
  55. data/lib/arjdbc/oracle/adapter.rb +0 -952
  56. data/lib/arjdbc/oracle/column.rb +0 -126
  57. data/lib/arjdbc/oracle/connection_methods.rb +0 -21
  58. data/lib/arjdbc/postgresql/base/oid.rb +0 -412
  59. data/lib/arjdbc/postgresql/base/schema_definitions.rb +0 -131
  60. data/lib/arjdbc/postgresql/explain_support.rb +0 -53
  61. data/lib/arjdbc/postgresql/oid/bytea.rb +0 -2
  62. data/lib/arjdbc/postgresql/schema_creation.rb +0 -60
  63. data/lib/arjdbc/tasks/oracle/enhanced_structure_dump.rb +0 -297
  64. data/lib/arjdbc/tasks/oracle_database_tasks.rb +0 -65
  65. data/src/java/arjdbc/oracle/OracleModule.java +0 -75
  66. data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +0 -465
@@ -0,0 +1,46 @@
1
+ module ArJdbc
2
+ module Abstract
3
+
4
+ # This provides the basic interface for interacting with the
5
+ # database for JDBC based adapters
6
+ module DatabaseStatements
7
+
8
+ # It appears that at this point (AR 5.0) "prepare" should only ever be true
9
+ # if prepared statements are enabled
10
+ def exec_query(sql, name = nil, binds = [], prepare: false)
11
+ if without_prepared_statement?(binds)
12
+ execute(sql, name)
13
+ else
14
+ binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
15
+ log(sql, name, binds) do
16
+ # It seems that #supports_statement_cache? is defined but isn't checked before setting "prepare" (AR 5.0)
17
+ cached_statement = fetch_cached_statement(sql) if prepare && supports_statement_cache?
18
+ @connection.execute_prepared(sql, binds, cached_statement)
19
+ end
20
+ end
21
+ end
22
+
23
+ def exec_update(sql, name = nil, binds = [])
24
+ if without_prepared_statement?(binds)
25
+ log(sql, name) { @connection.execute_update(sql, nil) }
26
+ else
27
+ log(sql, name, binds) { @connection.execute_prepared_update(sql, binds) }
28
+ end
29
+ end
30
+ alias :exec_delete :exec_update
31
+
32
+ def execute(sql, name = nil)
33
+ log(sql, name) { @connection.execute(sql) }
34
+ end
35
+
36
+ private
37
+
38
+ def convert_legacy_binds_to_attributes(binds)
39
+ binds.map do |column, value|
40
+ ActiveRecord::Relation::QueryAttribute.new(nil, type_cast(value, column), ActiveModel::Type::Value.new)
41
+ end
42
+ end
43
+
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,58 @@
1
+ require 'active_record/connection_adapters/statement_pool'
2
+
3
+ module ArJdbc
4
+ module Abstract
5
+ module StatementCache
6
+
7
+ # This works a little differently than the AR implementation in that
8
+ # we are storing an actual PreparedStatement object instead of just
9
+ # the name of the prepared statement
10
+ class StatementPool < ActiveRecord::ConnectionAdapters::StatementPool
11
+
12
+ private
13
+
14
+ def dealloc(statement)
15
+ statement.close
16
+ end
17
+
18
+ end
19
+
20
+ def initialize(connection, logger, config)
21
+ super
22
+
23
+ # Only say we support the statement cache if we are using prepared statements
24
+ # and have a max number of statements defined
25
+ statement_limit = self.class.type_cast_config_to_integer(config[:statement_limit])
26
+ @jdbc_statement_cache_enabled = config[:prepared_statements] && (statement_limit.nil? || statement_limit > 0)
27
+
28
+ @statements = StatementPool.new(statement_limit) # AR (5.0) expects this to be stored as @statements
29
+ end
30
+
31
+ # Clears the prepared statements cache.
32
+ def clear_cache!
33
+ @statements.clear
34
+ end
35
+
36
+ def delete_cached_statement(sql)
37
+ @statements.delete(cached_statement_key(sql))
38
+ end
39
+
40
+ def fetch_cached_statement(sql)
41
+ @statements[cached_statement_key(sql)] ||= @connection.connection.prepare_statement(sql)
42
+ end
43
+
44
+ def supports_statement_cache?
45
+ @jdbc_statement_cache_enabled
46
+ end
47
+
48
+ private
49
+
50
+ # This should be overridden by the adapter if the sql itself
51
+ # is not enough to make the key unique
52
+ def cached_statement_key(sql)
53
+ sql
54
+ end
55
+
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,86 @@
1
+ module ArJdbc
2
+ module Abstract
3
+
4
+ # Provides the basic interface needed to support transactions for JDBC based adapters
5
+ module TransactionSupport
6
+
7
+ ########################## Support Checks #################################
8
+
9
+ # Does our database (+ its JDBC driver) support save-points?
10
+ # @since 1.3.0
11
+ # @override
12
+ def supports_savepoints?
13
+ @connection.supports_savepoints?
14
+ end
15
+
16
+ # Does this adapter support setting the isolation level for a transaction?
17
+ # Unlike 'plain' `ActiveRecord` we allow checking for concrete transaction
18
+ # isolation level support by the database.
19
+ # @param level optional to check if we support a specific isolation level
20
+ # @since 1.3.0
21
+ # @extension added optional level parameter
22
+ def supports_transaction_isolation?(level = nil)
23
+ return false unless level
24
+ @connection.supports_transaction_isolation?(level)
25
+ end
26
+
27
+ ########################## Transaction Interface ##########################
28
+
29
+ # Starts a database transaction.
30
+ # @override
31
+ def begin_db_transaction
32
+ log('BEGIN TRANSACTION'.freeze, nil) { @connection.begin }
33
+ end
34
+
35
+ # Starts a database transaction.
36
+ # @param isolation the transaction isolation to use
37
+ def begin_isolated_db_transaction(isolation)
38
+ log("BEGIN ISOLATED TRANSACTION - #{isolation}", nil) { @connection.begin(isolation) }
39
+ end
40
+
41
+ # Commits the current database transaction.
42
+ # @override
43
+ def commit_db_transaction
44
+ log('COMMIT TRANSACTION'.freeze, nil) { @connection.commit }
45
+ end
46
+
47
+ # Rolls back the current database transaction.
48
+ # Called from 'rollback_db_transaction' in the AbstractAdapter
49
+ # @override
50
+ def exec_rollback_db_transaction
51
+ log('ROLLBACK TRANSACTION'.freeze, nil) { @connection.rollback }
52
+ end
53
+
54
+ ########################## Savepoint Interface ############################
55
+
56
+ # Creates a (transactional) save-point one can rollback to.
57
+ # Unlike 'plain' `ActiveRecord` it is allowed to pass a save-point name.
58
+ # @param name the save-point name
59
+ # @return save-point name (even if nil passed will be generated)
60
+ # @since 1.3.0
61
+ # @extension added optional name parameter
62
+ def create_savepoint(name = current_savepoint_name)
63
+ log("SAVEPOINT #{name}", 'Savepoint') { @connection.create_savepoint(name) }
64
+ end
65
+
66
+ # Transaction rollback to a given (previously created) save-point.
67
+ # If no save-point name given rollback to the last created one.
68
+ # Called from 'rollback_to_savepoint' in AbstractAdapter
69
+ # @param name the save-point name
70
+ # @extension added optional name parameter
71
+ def exec_rollback_to_savepoint(name = current_savepoint_name)
72
+ log("ROLLBACK TO SAVEPOINT #{name}", 'Savepoint') { @connection.rollback_savepoint(name) }
73
+ end
74
+
75
+ # Release a previously created save-point.
76
+ # @note Save-points are auto-released with the transaction they're created
77
+ # in (on transaction commit or roll-back).
78
+ # @param name the save-point name
79
+ # @extension added optional name parameter
80
+ def release_savepoint(name = current_savepoint_name)
81
+ log("RELEASE SAVEPOINT #{name}", 'Savepoint') { @connection.release_savepoint(name) }
82
+ end
83
+
84
+ end
85
+ end
86
+ end
@@ -175,10 +175,15 @@ module ArJdbc
175
175
  NATIVE_DATABASE_TYPES
176
176
  end
177
177
 
178
+ # UNTESTED
179
+ def existing_savepoint_name?(name)
180
+ (@connection.instance_variable_get('@savepoints') || {}).key? name
181
+ end
182
+
178
183
  # Ensure the savepoint name is unused before creating it.
179
184
  # @override
180
185
  def create_savepoint(name = current_savepoint_name(true))
181
- release_savepoint(name) if @connection.marked_savepoint_names.include?(name)
186
+ release_savepoint(name) if existing_savepoint_name?(name)
182
187
  super(name)
183
188
  end
184
189
 
@@ -75,13 +75,6 @@ module ArJdbc
75
75
  end
76
76
  end
77
77
 
78
- extension :Oracle do |name|
79
- if name =~ /oracle/i
80
- require 'arjdbc/oracle'
81
- true
82
- end
83
- end
84
-
85
78
  # NOTE: following ones are likely getting deprecated :
86
79
 
87
80
  extension :FireBird do |name|
@@ -413,7 +413,7 @@ module ActiveRecord::ConnectionAdapters
413
413
  # ActiveRecord::ConnectionAdapters::FirebirdAdapter.emulate_booleans = false
414
414
  #
415
415
  def self.emulate_booleans?; ::ArJdbc::Firebird.emulate_booleans?; end
416
- def self.emulate_booleans; ::ArJdbc::Firebird.emulate_booleans?; end # oracle-enhanced
416
+ def self.emulate_booleans; ::ArJdbc::Firebird.emulate_booleans?; end
417
417
  def self.emulate_booleans=(emulate); ::ArJdbc::Firebird.emulate_booleans = emulate; end
418
418
 
419
419
  def initialize(*args)
@@ -431,4 +431,4 @@ module ActiveRecord::ConnectionAdapters
431
431
  include ::ArJdbc::Firebird::Column
432
432
  end
433
433
 
434
- end
434
+ end
@@ -31,7 +31,7 @@ module ArJdbc
31
31
  end
32
32
 
33
33
  def deprecate(message, once = nil) # adds a "DEPRECATION WARNING: " prefix
34
- ::ActiveSupport::Deprecation.warn(message, caller) || true if warn?(message, once)
34
+ ::ActiveSupport::Deprecation.warn(message, caller_locations) || true if warn?(message, once)
35
35
  end
36
36
 
37
37
  private
@@ -56,4 +56,4 @@ module ArJdbc
56
56
  else
57
57
  require 'arjdbc/discover'
58
58
  end
59
- end
59
+ end
@@ -11,6 +11,10 @@ require 'arjdbc/jdbc/connection'
11
11
  require 'arjdbc/jdbc/callbacks'
12
12
  require 'arjdbc/jdbc/extension'
13
13
  require 'arjdbc/jdbc/type_converter'
14
+ require 'arjdbc/abstract/core'
15
+ require 'arjdbc/abstract/connection_management'
16
+ require 'arjdbc/abstract/database_statements'
17
+ require 'arjdbc/abstract/transaction_support'
14
18
 
15
19
  module ActiveRecord
16
20
  module ConnectionAdapters
@@ -34,7 +38,12 @@ module ActiveRecord
34
38
  class JdbcAdapter < AbstractAdapter
35
39
  include Jdbc::ConnectionPoolCallbacks
36
40
 
37
- attr_reader :config, :prepared_statements
41
+ include ArJdbc::Abstract::Core
42
+ include ArJdbc::Abstract::ConnectionManagement
43
+ include ArJdbc::Abstract::DatabaseStatements
44
+ include ArJdbc::Abstract::TransactionSupport
45
+
46
+ attr_reader :prepared_statements
38
47
 
39
48
  def self.new(connection, logger = nil, pool = nil)
40
49
  adapter = super
@@ -67,17 +76,11 @@ module ActiveRecord
67
76
  @config[:adapter_spec] = adapter_spec(@config) unless @config.key?(:adapter_spec)
68
77
  spec = @config[:adapter_spec]
69
78
 
70
- # NOTE: adapter spec's init_connection only called if instantiated here :
71
- connection ||= jdbc_connection_class(spec).new(@config, self)
72
-
73
79
  super(connection, logger, @config)
74
80
 
75
81
  # kind of like `extend ArJdbc::MyDB if self.class == JdbcAdapter` :
76
82
  klass = @config[:adapter_class]
77
83
  extend spec if spec && ( ! klass || klass == JdbcAdapter)
78
-
79
- # NOTE: should not be necessary for JNDI due reconnect! on checkout :
80
- configure_connection if respond_to?(:configure_connection)
81
84
  end
82
85
 
83
86
  # Returns the (JDBC) connection class to be used for this adapter.
@@ -96,30 +99,6 @@ module ActiveRecord
96
99
  ::ActiveRecord::ConnectionAdapters::JdbcColumn
97
100
  end
98
101
 
99
- # Retrieve the raw `java.sql.Connection` object.
100
- # The unwrap parameter is useful if an attempt to unwrap a pooled (JNDI)
101
- # connection should be made - to really return the 'native' JDBC object.
102
- # @param unwrap [true, false] whether to unwrap the connection object
103
- # @return [Java::JavaSql::Connection] the JDBC connection
104
- def jdbc_connection(unwrap = nil)
105
- java_connection = raw_connection.connection
106
- return java_connection unless unwrap
107
- connection_class = java.sql.Connection.java_class
108
- begin
109
- if java_connection.wrapper_for?(connection_class)
110
- return java_connection.unwrap(connection_class) # java.sql.Wrapper.unwrap
111
- end
112
- rescue Java::JavaLang::AbstractMethodError => e
113
- ArJdbc.warn("driver/pool connection impl does not support unwrapping (#{e})")
114
- end
115
- if java_connection.respond_to?(:connection)
116
- # e.g. org.apache.tomcat.jdbc.pool.PooledConnection
117
- java_connection.connection # getConnection
118
- else
119
- java_connection
120
- end
121
- end
122
-
123
102
  # Locate the specialized (database specific) adapter specification module
124
103
  # if one exists based on provided configuration data. This module will than
125
104
  # extend an instance of the adapter (unless an `:adapter_class` provided).
@@ -282,202 +261,15 @@ module ActiveRecord
282
261
  return nil, nil
283
262
  end
284
263
 
285
- # @override
286
- def active?
287
- @connection.active?
288
- end
289
-
290
- # @override
291
- def reconnect!
292
- @connection.reconnect! # handles adapter.configure_connection
293
- @connection
294
- end
295
-
296
- # @override
297
- def disconnect!
298
- @connection.disconnect!
299
- end
300
-
301
- # @note Used on AR 2.3 and 3.0
302
- # @override
303
- def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
304
- id = execute(sql, name)
305
- id_value || id
306
- end
307
-
308
264
  def columns(table_name, name = nil)
309
265
  @connection.columns(table_name.to_s)
310
266
  end
311
267
 
312
- # Starts a database transaction.
313
- # @override
314
- def begin_db_transaction
315
- @connection.begin
316
- end
317
-
318
- # Commits the current database transaction.
319
- # @override
320
- def commit_db_transaction
321
- @connection.commit
322
- end
323
-
324
- # Rolls back the current database transaction.
325
- # @override
326
- def rollback_db_transaction
327
- @connection.rollback
328
- end
329
-
330
- # Starts a database transaction.
331
- # @param isolation the transaction isolation to use
332
- # @since 1.3.0
333
- # @override on **AR-4.0**
334
- def begin_isolated_db_transaction(isolation)
335
- @connection.begin(isolation)
336
- end
337
-
338
- # Does this adapter support setting the isolation level for a transaction?
339
- # Unlike 'plain' `ActiveRecord` we allow checking for concrete transaction
340
- # isolation level support by the database.
341
- # @param level optional to check if we support a specific isolation level
342
- # @since 1.3.0
343
- # @extension added optional level parameter
344
- def supports_transaction_isolation?(level = nil)
345
- @connection.supports_transaction_isolation?(level)
346
- end
347
-
348
- # Does our database (+ its JDBC driver) support save-points?
349
- # @since 1.3.0
350
- # @override
351
- def supports_savepoints?
352
- @connection.supports_savepoints?
353
- end
354
-
355
- # Creates a (transactional) save-point one can rollback to.
356
- # Unlike 'plain' `ActiveRecord` it is allowed to pass a save-point name.
357
- # @param name the save-point name
358
- # @return save-point name (even if nil passed will be generated)
359
- # @since 1.3.0
360
- # @extension added optional name parameter
361
- def create_savepoint(name = current_savepoint_name(true))
362
- @connection.create_savepoint(name)
363
- end
364
-
365
- # Transaction rollback to a given (previously created) save-point.
366
- # If no save-point name given rollback to the last created one.
367
- # @param name the save-point name
368
- # @since 1.3.0
369
- # @extension added optional name parameter
370
- def rollback_to_savepoint(name = current_savepoint_name(true))
371
- @connection.rollback_savepoint(name)
372
- end
373
-
374
- # Release a previously created save-point.
375
- # @note Save-points are auto-released with the transaction they're created
376
- # in (on transaction commit or roll-back).
377
- # @param name the save-point name
378
- # @since 1.3.0
379
- # @extension added optional name parameter
380
- def release_savepoint(name = current_savepoint_name(false))
381
- @connection.release_savepoint(name)
382
- end
383
-
384
- # Due tracking of save-points created in a LIFO manner, always returns
385
- # the correct name if any (last) save-point has been marked and not released.
386
- # Otherwise when creating a save-point same naming convention as
387
- # `ActiveRecord` uses ("active_record_" prefix) will be returned.
388
- # @return [String] the current save-point name
389
- # @since 1.3.0
390
- # @override
391
- def current_savepoint_name(compat = true)
392
- open_tx = open_transactions
393
- return "active_record_#{open_tx}" if compat # by default behave like AR
394
-
395
- sp_names = @connection.marked_savepoint_names
396
- sp_names.last || "active_record_#{open_tx}"
397
- # should (open_tx- 1) here but we play by AR's rules as it might fail
398
- end unless ArJdbc::AR42
399
-
400
- # @note Same as AR 4.2 but we're allowing an unused parameter.
401
- # @private
402
- def current_savepoint_name(compat = nil)
403
- current_transaction.savepoint_name # unlike AR 3.2-4.1 might be nil
404
- end if ArJdbc::AR42
405
-
406
268
  # @override
407
269
  def supports_views?
408
270
  @connection.supports_views?
409
271
  end
410
272
 
411
- # Executes a SQL query in the context of this connection using the bind
412
- # substitutes.
413
- # @param sql the query string (or AREL object)
414
- # @param name logging marker for the executed SQL statement log entry
415
- # @param binds the bind parameters
416
- # @return [ActiveRecord::Result] or [Array] on **AR-2.3**
417
- # @override available since **AR-3.1**
418
- def exec_query(sql, name = 'SQL', binds = [])
419
- if sql.respond_to?(:to_sql)
420
- sql = to_sql(sql, binds); to_sql = true
421
- end
422
- if prepared_statements?
423
- log(sql, name, binds) { @connection.execute_query(sql, binds) }
424
- else
425
- sql = suble_binds(sql, binds) unless to_sql # deprecated behavior
426
- log(sql, name) { @connection.execute_query(sql) }
427
- end
428
- end
429
-
430
- # Executes an insert statement in the context of this connection.
431
- # @param sql the query string (or AREL object)
432
- # @param name logging marker for the executed SQL statement log entry
433
- # @param binds the bind parameters
434
- # @override available since **AR-3.1**
435
- def exec_insert(sql, name, binds, pk = nil, sequence_name = nil)
436
- if sql.respond_to?(:to_sql)
437
- sql = to_sql(sql, binds); to_sql = true
438
- end
439
- if prepared_statements?
440
- log(sql, name || 'SQL', binds) { @connection.execute_insert(sql, binds) }
441
- else
442
- sql = suble_binds(sql, binds) unless to_sql # deprecated behavior
443
- log(sql, name || 'SQL') { @connection.execute_insert(sql) }
444
- end
445
- end
446
-
447
- # Executes a delete statement in the context of this connection.
448
- # @param sql the query string (or AREL object)
449
- # @param name logging marker for the executed SQL statement log entry
450
- # @param binds the bind parameters
451
- # @override available since **AR-3.1**
452
- def exec_delete(sql, name, binds)
453
- if sql.respond_to?(:to_sql)
454
- sql = to_sql(sql, binds); to_sql = true
455
- end
456
- if prepared_statements?
457
- log(sql, name || 'SQL', binds) { @connection.execute_delete(sql, binds) }
458
- else
459
- sql = suble_binds(sql, binds) unless to_sql # deprecated behavior
460
- log(sql, name || 'SQL') { @connection.execute_delete(sql) }
461
- end
462
- end
463
-
464
- # # Executes an update statement in the context of this connection.
465
- # @param sql the query string (or AREL object)
466
- # @param name logging marker for the executed SQL statement log entry
467
- # @param binds the bind parameters
468
- # @override available since **AR-3.1**
469
- def exec_update(sql, name, binds)
470
- if sql.respond_to?(:to_sql)
471
- sql = to_sql(sql, binds); to_sql = true
472
- end
473
- if prepared_statements?
474
- log(sql, name || 'SQL', binds) { @connection.execute_update(sql, binds) }
475
- else
476
- sql = suble_binds(sql, binds) unless to_sql # deprecated behavior
477
- log(sql, name || 'SQL') { @connection.execute_update(sql) }
478
- end
479
- end
480
-
481
273
  # Similar to {#exec_query} except it returns "raw" results in an array
482
274
  # where each rows is a hash with keys as columns (just like Rails used to
483
275
  # do up until 3.0) instead of wrapping them in a {#ActiveRecord::Result}.
@@ -506,22 +298,6 @@ module ActiveRecord
506
298
  exec_query_raw(sql, name, binds).map!(&:values)
507
299
  end
508
300
 
509
- if ActiveRecord::VERSION::MAJOR > 3 # expects AR::Result e.g. from select_all
510
-
511
- # @private
512
- def select(sql, name = nil, binds = [])
513
- exec_query(to_sql(sql, binds), name, binds)
514
- end
515
-
516
- else
517
-
518
- # @private
519
- def select(sql, name = nil, binds = []) # NOTE: only (sql, name) on AR < 3.1
520
- exec_query_raw(to_sql(sql, binds), name, binds)
521
- end
522
-
523
- end
524
-
525
301
  # Executes the SQL statement in the context of this connection.
526
302
  # The return value from this method depends on the SQL type (whether
527
303
  # it's a SELECT, INSERT etc.). For INSERTs a generated id might get
@@ -595,11 +371,6 @@ module ActiveRecord
595
371
  ( key = primary_key(table) ) ? [ key, nil ] : nil
596
372
  end
597
373
 
598
- # @override
599
- def primary_key(table)
600
- primary_keys(table).first
601
- end
602
-
603
374
  # @override
604
375
  def primary_keys(table)
605
376
  @connection.primary_keys(table)
@@ -662,19 +433,6 @@ module ActiveRecord
662
433
  end if ActiveRecord::VERSION::MAJOR < 3 ||
663
434
  ( ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR < 1 )
664
435
 
665
- def translate_exception(e, message)
666
- # we shall not translate native "Java" exceptions as they might
667
- # swallow an ArJdbc / driver bug into a AR::StatementInvalid ...
668
- return e if e.is_a?(NativeException) # JRuby 1.6
669
- return e if e.is_a?(Java::JavaLang::Throwable)
670
-
671
- case e
672
- when SystemExit, SignalException, NoMemoryError then e
673
- # NOTE: wraps AR::JDBCError into AR::StatementInvalid, desired ?!
674
- else super
675
- end
676
- end
677
-
678
436
  # Take an id from the result of an INSERT query.
679
437
  # @return [Integer, NilClass]
680
438
  def last_inserted_id(result)