activerecord-jdbc-adapter 52.7-java → 60.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -2
  3. data/.travis.yml +58 -37
  4. data/Gemfile +9 -2
  5. data/README.md +25 -9
  6. data/Rakefile +1 -1
  7. data/Rakefile.jdbc +8 -1
  8. data/activerecord-jdbc-adapter.gemspec +5 -8
  9. data/lib/arjdbc/abstract/connection_management.rb +7 -0
  10. data/lib/arjdbc/abstract/core.rb +16 -23
  11. data/lib/arjdbc/abstract/database_statements.rb +26 -2
  12. data/lib/arjdbc/abstract/statement_cache.rb +2 -5
  13. data/lib/arjdbc/abstract/transaction_support.rb +5 -3
  14. data/lib/arjdbc/db2/column.rb +0 -39
  15. data/lib/arjdbc/derby/adapter.rb +1 -20
  16. data/lib/arjdbc/firebird/adapter.rb +0 -21
  17. data/lib/arjdbc/h2/adapter.rb +0 -15
  18. data/lib/arjdbc/hsqldb/adapter.rb +0 -14
  19. data/lib/arjdbc/informix/adapter.rb +0 -23
  20. data/lib/arjdbc/jdbc/adapter.rb +3 -1
  21. data/lib/arjdbc/jdbc/adapter_require.rb +3 -1
  22. data/lib/arjdbc/jdbc/base_ext.rb +3 -1
  23. data/lib/arjdbc/jdbc/callbacks.rb +2 -0
  24. data/lib/arjdbc/jdbc/column.rb +2 -0
  25. data/lib/arjdbc/jdbc/connection.rb +2 -0
  26. data/lib/arjdbc/jdbc/connection_methods.rb +2 -0
  27. data/lib/arjdbc/jdbc/error.rb +2 -0
  28. data/lib/arjdbc/jdbc/extension.rb +2 -0
  29. data/lib/arjdbc/jdbc/java.rb +3 -1
  30. data/lib/arjdbc/jdbc/railtie.rb +3 -1
  31. data/lib/arjdbc/jdbc/rake_tasks.rb +3 -1
  32. data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +3 -1
  33. data/lib/arjdbc/jdbc/type_cast.rb +2 -0
  34. data/lib/arjdbc/jdbc/type_converter.rb +2 -0
  35. data/lib/arjdbc/mysql/adapter.rb +47 -18
  36. data/lib/arjdbc/mysql/connection_methods.rb +0 -1
  37. data/lib/arjdbc/postgresql/adapter.rb +220 -213
  38. data/lib/arjdbc/postgresql/base/array_decoder.rb +2 -0
  39. data/lib/arjdbc/postgresql/base/array_encoder.rb +4 -2
  40. data/lib/arjdbc/postgresql/base/array_parser.rb +4 -2
  41. data/lib/arjdbc/postgresql/base/pgconn.rb +2 -0
  42. data/lib/arjdbc/postgresql/column.rb +6 -4
  43. data/lib/arjdbc/postgresql/connection_methods.rb +0 -1
  44. data/lib/arjdbc/postgresql/name.rb +2 -0
  45. data/lib/arjdbc/postgresql/oid_types.rb +2 -0
  46. data/lib/arjdbc/sqlite3/adapter.rb +175 -180
  47. data/lib/arjdbc/sqlite3/connection_methods.rb +15 -5
  48. data/lib/arjdbc/tasks/databases.rake +13 -10
  49. data/lib/arjdbc/util/quoted_cache.rb +3 -1
  50. data/lib/arjdbc/util/serialized_attributes.rb +3 -1
  51. data/lib/arjdbc/util/table_copier.rb +3 -1
  52. data/lib/arjdbc/version.rb +1 -1
  53. data/pom.xml +4 -4
  54. data/rakelib/01-tomcat.rake +2 -2
  55. data/rakelib/rails.rake +1 -1
  56. data/src/java/arjdbc/ArJdbcModule.java +5 -5
  57. data/src/java/arjdbc/jdbc/DriverWrapper.java +1 -9
  58. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +434 -701
  59. data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +0 -51
  60. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +13 -23
  61. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +31 -24
  62. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +94 -99
  63. metadata +8 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e10da6d252a05adeedfb0b57fbd49bb6e2b8af28df60c5005adada50ea29bc4
4
- data.tar.gz: 18a6f90b2c900b81e9e820e7c79f6478697baa3114ebc3938d67caceacc04e79
3
+ metadata.gz: 807d5401be5ff0aba3877e221cd597609d8b88b7388cd2bde43861565b3e008c
4
+ data.tar.gz: ac01cd946ad85a3c4b854d198408f61bff55ddd6a97dd6e3b47ceab20eb78e6a
5
5
  SHA512:
6
- metadata.gz: 304c31adfc470ac2852af55ecd84dab23be302df35917cdd683aeadd94c30fa86dae2b040e9b637365684f120677a5fcbbf6f8f6daa00d90f41f5ebd743f08e9
7
- data.tar.gz: 68d730d2b58312cdc63acd4fb46e5d208436dfa6e9d2ec16086ec2c381efb5d8fc0cd6d1af7bf740e840084a26fb99489f43463d04456eef68a9c7ceb224585a
6
+ metadata.gz: a8e2cbd16ca12f5fcd1403a899ca97328f5887b670789939e3ca83dc9046dff670c75def5e294ad0a19433a528355147f9974cfaac077f838491286f6786af47
7
+ data.tar.gz: cc77979db17af2578c841b16d95bf7f7b4203e437fb490016509498c43348486399b046c8b0140795848d6cd44f67e3fa17bd1f6bd16a854bbc3569959bf3522
data/.gitignore CHANGED
@@ -2,7 +2,6 @@
2
2
  *.tgz
3
3
  *~
4
4
  *.log
5
- /log/
6
5
  patches*
7
6
  *#
8
7
  TAGS
@@ -31,4 +30,4 @@ Gemfile.lock
31
30
  .idea
32
31
  .settings
33
32
  activerecord-jdbc.iml
34
- lib/arjdbc/jdbc/adapter_java.jar
33
+ lib/arjdbc/jdbc/adapter_java.jar
@@ -3,8 +3,6 @@ dist: xenial
3
3
 
4
4
  services:
5
5
  - mysql
6
- addons:
7
- postgresql: 9.4
8
6
 
9
7
  before_install:
10
8
  - unset _JAVA_OPTIONS
@@ -17,7 +15,7 @@ install:
17
15
 
18
16
  language: ruby
19
17
  rvm:
20
- - jruby-9.1.16.0
18
+ - jruby-9.2.7.0
21
19
  jdk:
22
20
  - openjdk8
23
21
 
@@ -49,45 +47,58 @@ before_script:
49
47
  || true
50
48
 
51
49
  env:
52
- - DB=mysql2 PREPARED_STATEMENTS=false
53
- - DB=mysql2 PREPARED_STATEMENTS=true
54
- - DB=mysql2 DRIVER=MariaDB
55
- - DB=postgresql PREPARED_STATEMENTS=false INSERT_RETURNING=false
56
- - DB=postgresql PREPARED_STATEMENTS=false INSERT_RETURNING=true
57
- - DB=postgresql PREPARED_STATEMENTS=true
58
- - DB=postgresql PREPARED_STATEMENTS=true INSERT_RETURNING=true
59
- - DB=sqlite3 PREPARED_STATEMENTS=false
60
- - DB=sqlite3 PREPARED_STATEMENTS=true
61
- - DB=jndi PREPARED_STATEMENTS=false
62
- - DB=jndi PREPARED_STATEMENTS=true
50
+ global:
51
+ - AR_VERSION="6-0-stable"
63
52
  matrix:
64
53
  allow_failures:
65
54
  - rvm: jruby-head
66
55
  include:
67
- # jruby-9.2
68
- - rvm: jruby-9.2.6.0
69
- env: DB=mysql2
70
- - rvm: jruby-9.2.6.0
71
- env: DB=postgresql
72
- - rvm: jruby-9.2.6.0
73
- env: DB=sqlite3
74
- # jruby-9.2 + Java 11
75
- - rvm: jruby-9.2.6.0
76
- env: DB=mysql2
77
- jdk: openjdk11
78
- - rvm: jruby-9.2.6.0
79
- env: DB=postgresql
80
- jdk: openjdk11
81
- - rvm: jruby-9.2.6.0
82
- env: DB=sqlite3
83
- jdk: openjdk11
56
+ - env: DB=mysql2 PREPARED_STATEMENTS=false
57
+ - env: DB=mysql2 PREPARED_STATEMENTS=true
58
+ - env: DB=mysql2 DRIVER=MariaDB
59
+
60
+ - addons:
61
+ postgresql: "10"
62
+ env: DB=postgresql PREPARED_STATEMENTS=false INSERT_RETURNING=false
63
+ - addons:
64
+ postgresql: "10"
65
+ env: DB=postgresql PREPARED_STATEMENTS=false INSERT_RETURNING=true
66
+ - addons:
67
+ postgresql: "10"
68
+ env: DB=postgresql PREPARED_STATEMENTS=true
69
+ - addons:
70
+ postgresql: "10"
71
+ env: DB=postgresql PREPARED_STATEMENTS=true INSERT_RETURNING=true
72
+ - addons:
73
+ postgresql: "9.4"
74
+ env: DB=postgresql PREPARED_STATEMENTS=true
75
+
76
+ - env: DB=sqlite3 PREPARED_STATEMENTS=false
77
+ - env: DB=sqlite3 PREPARED_STATEMENTS=true
78
+
79
+ - env: DB=jndi PREPARED_STATEMENTS=false
80
+ - env: DB=jndi PREPARED_STATEMENTS=true
81
+
82
+ # Java 11
83
+ - env: DB=mysql2
84
+ jdk: oraclejdk11
85
+ - env: DB=postgresql
86
+ jdk: oraclejdk11
87
+ addons:
88
+ postgresql: "10"
89
+ - env: DB=sqlite3
90
+ jdk: oraclejdk11
91
+
84
92
  # jruby-head
85
93
  - rvm: jruby-head
86
94
  env: DB=mysql2
87
95
  - rvm: jruby-head
88
96
  env: DB=postgresql
97
+ addons:
98
+ postgresql: "10"
89
99
  - rvm: jruby-head
90
100
  env: DB=sqlite3
101
+
91
102
  # testing against MariaDB
92
103
  - addons:
93
104
  mariadb: 10.2
@@ -95,10 +106,20 @@ matrix:
95
106
  - addons:
96
107
  mariadb: 10.3
97
108
  env: DB=mariadb PREPARED_STATEMENTS=true
109
+
98
110
  # Rails test-suite :
99
- - env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.2.3" # PS off by default
100
- - env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.2.3" PREPARED_STATEMENTS=true
101
- - env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.2.3" DRIVER=MariaDB
102
- - env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="v5.2.3" # PS on by default
103
- - env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="v5.2.3" PREPARED_STATEMENTS=false
104
- - env: DB=sqlite3 TEST_PREFIX="rails:" AR_VERSION="v5.2.3"
111
+ - env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="6-0-stable" # PS off by default
112
+ - env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="6-0-stable" PREPARED_STATEMENTS=true
113
+ - env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="6-0-stable" DRIVER=MariaDB
114
+
115
+ - addons:
116
+ postgresql: "10"
117
+ env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="6-0-stable" # PS on by default
118
+ - addons:
119
+ postgresql: "10"
120
+ env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="6-0-stable" PREPARED_STATEMENTS=false
121
+ - addons:
122
+ postgresql: "9.4"
123
+ env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="6-0-stable" # PS on by default
124
+
125
+ - env: DB=sqlite3 TEST_PREFIX="rails:" AR_VERSION="6-0-stable"
data/Gemfile CHANGED
@@ -10,10 +10,15 @@ if ENV['RAILS'] # Use local clone of Rails
10
10
 
11
11
  activemodel_dir = ::File.join(rails_dir, 'activemodel')
12
12
  activesupport_dir = ::File.join(rails_dir, 'activesupport')
13
-
13
+ actionpack_dir = ::File.join(rails_dir, 'actionpack')
14
+ actionview_dir = ::File.join(rails_dir, 'actionview')
15
+
14
16
  gem 'activerecord', require: false, path: activerecord_dir
15
17
  gem 'activemodel', require: false, path: activemodel_dir
16
18
  gem 'activesupport', require: false, path: activesupport_dir
19
+ gem 'actionpack', require: false, path: actionpack_dir
20
+ gem 'actionview', require: false, path: actionview_dir
21
+
17
22
  elsif ENV['AR_VERSION'] # Use specific version of AR and not .gemspec version
18
23
  version = ENV['AR_VERSION']
19
24
 
@@ -28,11 +33,13 @@ elsif ENV['AR_VERSION'] # Use specific version of AR and not .gemspec version
28
33
  else # branch
29
34
  opts = {branch: version}
30
35
  end
31
-
36
+
32
37
  git 'https://github.com/rails/rails.git', **opts do
33
38
  gem 'activerecord', require: false
34
39
  gem 'activemodel', require: false
35
40
  gem 'activesupport', require: false
41
+ gem 'actionpack', require: false
42
+ gem 'actionview', require: false
36
43
  end
37
44
  end
38
45
  end
data/README.md CHANGED
@@ -18,15 +18,15 @@ is not something we can do with the resources we currently have.
18
18
 
19
19
  Versions are targeted at certain versions of Rails and live on their own branches.
20
20
 
21
- | Gem Version | Rails Version | Branch |
22
- | ----------- | ------------- | ------ |
23
- | 50.x | 5.0.x | 50-stable |
24
- | 51.x | 5.1.x | 51-stable |
25
- | 52.x | 5.2.x | 52-stable |
26
- | future | latest | master |
21
+ | Gem Version | Rails Version | Branch | min JRuby | min Java |
22
+ | ----------- | ------------- | --------- | --------- | -------- |
23
+ | 50.x | 5.0.x | 50-stable | 9.1.x | 7 |
24
+ | 51.x | 5.1.x | 51-stable | 9.1.x | 7 |
25
+ | 52.x | 5.2.x | 52-stable | 9.1.x | 7 |
26
+ | 60.x | 6.0.x | master | 9.2.7 | 8 |
27
27
 
28
- The minimum version of JRuby for 50+ is JRuby **9.1.x** and
29
- JRuby 9.1+ requires Java 7 or newer (we recommend Java 8 at minimum).
28
+ Note that JRuby 9.1.x is end-of-life. We recommend Java 8 at a minimum for all
29
+ versions.
30
30
 
31
31
  ## Using ActiveRecord JDBC
32
32
 
@@ -83,6 +83,21 @@ production:
83
83
  connectTimeout: 60000
84
84
  ```
85
85
 
86
+ #### MySQL specific notes
87
+
88
+ Depending on the MySQL server configuration, it might be required to set
89
+ additional connection properties for date/time support to work correctly. If you
90
+ encounter problems, try adding this to your database configuration:
91
+
92
+ ```yml
93
+ properties:
94
+ serverTimezone: <%= java.util.TimeZone.getDefault.getID %>
95
+ ```
96
+
97
+ The correct timezone depends on the system setup, but the one shown is a good
98
+ place to start and is actually the correct setting for many systems.
99
+
100
+
86
101
  ### Standalone with ActiveRecord
87
102
 
88
103
  Once the setup is made (see below) you can establish a JDBC connection like this
@@ -157,7 +172,8 @@ ask on the #JRuby IRC channel on http://freenode.net/ (try [web-chat][6]).
157
172
  This project was originally written by [Nick Sieger](http://github.com/nicksieger)
158
173
  and [Ola Bini](http://github.com/olabini) with lots of help from the JRuby community.
159
174
  Polished 3.x compatibility and 4.x support (for AR-JDBC >= 1.3.0) was managed by
160
- [Karol Bucek](http://github.com/kares) among others.
175
+ [Karol Bucek](http://github.com/kares) among others. Support for Rails 6 was
176
+ contributed by [shellyBits GmbH](https://shellybits.ch/)
161
177
 
162
178
  ## License
163
179
 
data/Rakefile CHANGED
@@ -185,7 +185,7 @@ if defined? JRUBY_VERSION
185
185
  #directory classes = 'pkg/classes'; CLEAN << classes
186
186
 
187
187
  file jar_file => FileList[ 'src/java/**/*.java' ] do
188
- source = target = '1.7'; debug = true
188
+ source = target = '1.8'; debug = true
189
189
 
190
190
  get_driver_jars_local = lambda do |*args|
191
191
  driver_deps = args.empty? ? [ :Postgres, :MySQL ] : args
@@ -17,4 +17,11 @@ desc "Build and install #{name}-#{version} gem into system gems"
17
17
  task('install') { gem_helper.install_gem }
18
18
 
19
19
  desc "Create tag #{version_tag} build and push #{name}-#{version} gem to Rubygems"
20
- task('release') { gem_helper.release_gem }
20
+ task('release') do
21
+ gem_helper.instance_eval do
22
+ guard_clean
23
+ built_gem_path = build_gem
24
+ tag_version unless already_tagged?
25
+ rubygem_push(built_gem_path) if gem_push?
26
+ end
27
+ end
@@ -11,13 +11,10 @@ Gem::Specification.new do |gem|
11
11
  gem.license = 'BSD-2-Clause'
12
12
  gem.summary = 'JDBC adapter for ActiveRecord, for use within JRuby on Rails.'
13
13
  gem.description = "" <<
14
- "AR-JDBC is a database adapter for Rails' ActiveRecord component designed " <<
15
- "to be used with JRuby built upon Java's JDBC API for database access. " <<
16
- "Provides (ActiveRecord) built-in adapters: MySQL, PostgreSQL and SQLite3 " <<
17
- "as well as adapters for popular databases such as Oracle, SQLServer, " <<
18
- "DB2, FireBird and even Java (embed) databases: Derby, HSQLDB and H2. " <<
19
- "It allows to connect to virtually any JDBC-compliant database with your " <<
20
- "JRuby on Rails application."
14
+ "AR-JDBC is a database adapter for Rails' ActiveRecord component " <<
15
+ "designed to be used with JRuby built upon Java's JDBC API for " <<
16
+ "database access. Provides (ActiveRecord) built-in adapters: MySQL, " <<
17
+ "PostgreSQL, SQLite3, and SQLServer."
21
18
 
22
19
  gem.require_paths = ["lib"]
23
20
 
@@ -44,7 +41,7 @@ Gem::Specification.new do |gem|
44
41
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
45
42
  gem.test_files = gem.files.grep(%r{^test/})
46
43
 
47
- gem.add_dependency 'activerecord', '~> 5.2.0'
44
+ gem.add_dependency 'activerecord', '~> 6.0.0'
48
45
 
49
46
  #gem.add_development_dependency 'test-unit', '2.5.4'
50
47
  #gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ArJdbc
2
4
  module Abstract
3
5
  module ConnectionManagement
@@ -8,6 +10,11 @@ module ArJdbc
8
10
  @connection.active?
9
11
  end
10
12
 
13
+ def really_valid?
14
+ return unless @connection
15
+ @connection.really_valid?
16
+ end
17
+
11
18
  # @override
12
19
  def reconnect!
13
20
  super # clear_cache! && reset_transaction
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ArJdbc
2
4
  module Abstract
3
5
 
@@ -34,28 +36,26 @@ module ArJdbc
34
36
 
35
37
  protected
36
38
 
37
- def translate_exception_class(e, sql)
38
- begin
39
- message = "#{e.class.name}: #{e.message}: #{sql}"
40
- rescue Encoding::CompatibilityError
41
- message = "#{e.class.name}: #{e.message.force_encoding sql.encoding}: #{sql}"
42
- end
39
+ def translate_exception_class(e, sql, binds)
40
+ message = "#{e.class.name}: #{e.message}"
43
41
 
44
- exception = translate_exception(e, message)
45
- exception.set_backtrace e.backtrace unless e.equal?(exception)
42
+ exception = translate_exception(
43
+ e, message: message, sql: sql, binds: binds
44
+ )
45
+ exception.set_backtrace e.backtrace
46
46
  exception
47
47
  end
48
48
 
49
- def translate_exception(e, message)
49
+ def translate_exception(exception, message:, sql:, binds:)
50
50
  # override in derived class
51
51
 
52
52
  # we shall not translate native "Java" exceptions as they might
53
53
  # swallow an ArJdbc / driver bug into an AR::StatementInvalid !
54
- return e if e.is_a?(Java::JavaLang::Throwable)
54
+ return exception if exception.is_a?(Java::JavaLang::Throwable)
55
55
 
56
- case e
57
- when SystemExit, SignalException, NoMemoryError then e
58
- when ActiveModel::RangeError, TypeError, RuntimeError then e
56
+ case exception
57
+ when SystemExit, SignalException, NoMemoryError then exception
58
+ when ActiveModel::RangeError, TypeError, RuntimeError then exception
59
59
  else super
60
60
  end
61
61
  end
@@ -74,13 +74,6 @@ module ArJdbc
74
74
  end
75
75
  end
76
76
 
77
- module LogSubscriber
78
- JDBC_GEM_ROOT = File.expand_path("../../../..", __FILE__) + "/"
79
-
80
- # Remove this gem from log trace so that query shows where it was called in application
81
- def ignored_callstack(path)
82
- super || path.start_with?(JDBC_GEM_ROOT)
83
- end
84
- end
85
- ActiveRecord::LogSubscriber.prepend(ArJdbc::LogSubscriber)
86
- end
77
+ JDBC_GEM_ROOT = File.expand_path("../../../..", __FILE__) + "/"
78
+ ActiveRecord::LogSubscriber.backtrace_cleaner.add_silencer { |line| line.start_with?(JDBC_GEM_ROOT) }
79
+ end
@@ -10,13 +10,19 @@ 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
+ if preventing_writes?
14
+ raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
15
+ end
16
+
17
+ materialize_transactions
18
+
13
19
  binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
14
20
 
15
21
  if without_prepared_statement?(binds)
16
- log(sql, name) { @connection.execute_insert_pk(sql, pk) }
22
+ log(sql, name) { @connection.execute_insert(sql) }
17
23
  else
18
24
  log(sql, name, binds) do
19
- @connection.execute_insert_pk(sql, binds, pk)
25
+ @connection.execute_insert(sql, binds)
20
26
  end
21
27
  end
22
28
  end
@@ -24,6 +30,12 @@ module ArJdbc
24
30
  # It appears that at this point (AR 5.0) "prepare" should only ever be true
25
31
  # if prepared statements are enabled
26
32
  def exec_query(sql, name = nil, binds = NO_BINDS, prepare: false)
33
+ if preventing_writes? && write_query?(sql)
34
+ raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
35
+ end
36
+
37
+ materialize_transactions
38
+
27
39
  binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
28
40
 
29
41
  if without_prepared_statement?(binds)
@@ -38,6 +50,12 @@ module ArJdbc
38
50
  end
39
51
 
40
52
  def exec_update(sql, name = nil, binds = NO_BINDS)
53
+ if preventing_writes?
54
+ raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
55
+ end
56
+
57
+ materialize_transactions
58
+
41
59
  binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
42
60
 
43
61
  if without_prepared_statement?(binds)
@@ -49,6 +67,12 @@ module ArJdbc
49
67
  alias :exec_delete :exec_update
50
68
 
51
69
  def execute(sql, name = nil)
70
+ if preventing_writes? && write_query?(sql)
71
+ raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
72
+ end
73
+
74
+ materialize_transactions
75
+
52
76
  log(sql, name) { @connection.execute(sql) }
53
77
  end
54
78
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_record/connection_adapters/statement_pool'
2
4
 
3
5
  module ArJdbc
@@ -41,11 +43,6 @@ module ArJdbc
41
43
  @statements[sql_key(sql)] ||= @connection.prepare_statement(sql)
42
44
  end
43
45
 
44
- def supports_statement_cache?
45
- ActiveSupport::Deprecation.deprecation_warning(__method__)
46
- @jdbc_statement_cache_enabled
47
- end
48
-
49
46
  private
50
47
 
51
48
  # This should be overridden by the adapter if the sql itself