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.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.travis.yml +80 -52
  4. data/Gemfile +10 -3
  5. data/README.md +55 -37
  6. data/Rakefile +31 -5
  7. data/Rakefile.jdbc +8 -1
  8. data/activerecord-jdbc-adapter.gemspec +6 -9
  9. data/activerecord-jdbc-alt-adapter.gemspec +6 -9
  10. data/lib/arel/visitors/sqlserver.rb +33 -23
  11. data/lib/arjdbc/abstract/connection_management.rb +7 -0
  12. data/lib/arjdbc/abstract/core.rb +17 -24
  13. data/lib/arjdbc/abstract/database_statements.rb +31 -20
  14. data/lib/arjdbc/abstract/statement_cache.rb +2 -5
  15. data/lib/arjdbc/abstract/transaction_support.rb +5 -3
  16. data/lib/arjdbc/db2/column.rb +0 -39
  17. data/lib/arjdbc/derby/adapter.rb +1 -20
  18. data/lib/arjdbc/firebird/adapter.rb +0 -21
  19. data/lib/arjdbc/h2/adapter.rb +0 -15
  20. data/lib/arjdbc/hsqldb/adapter.rb +0 -14
  21. data/lib/arjdbc/informix/adapter.rb +0 -23
  22. data/lib/arjdbc/jdbc.rb +0 -4
  23. data/lib/arjdbc/jdbc/adapter.rb +3 -1
  24. data/lib/arjdbc/jdbc/adapter_require.rb +3 -1
  25. data/lib/arjdbc/jdbc/base_ext.rb +3 -1
  26. data/lib/arjdbc/jdbc/callbacks.rb +2 -0
  27. data/lib/arjdbc/jdbc/column.rb +3 -5
  28. data/lib/arjdbc/jdbc/connection.rb +2 -0
  29. data/lib/arjdbc/jdbc/connection_methods.rb +2 -0
  30. data/lib/arjdbc/jdbc/error.rb +2 -0
  31. data/lib/arjdbc/jdbc/extension.rb +2 -0
  32. data/lib/arjdbc/jdbc/java.rb +3 -1
  33. data/lib/arjdbc/jdbc/railtie.rb +3 -1
  34. data/lib/arjdbc/jdbc/rake_tasks.rb +3 -1
  35. data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +3 -1
  36. data/lib/arjdbc/jdbc/type_cast.rb +2 -0
  37. data/lib/arjdbc/jdbc/type_converter.rb +2 -0
  38. data/lib/arjdbc/mssql.rb +3 -1
  39. data/lib/arjdbc/mssql/adapter.rb +112 -46
  40. data/lib/arjdbc/mssql/column.rb +5 -1
  41. data/lib/arjdbc/mssql/connection_methods.rb +13 -2
  42. data/lib/arjdbc/mssql/database_limits.rb +2 -0
  43. data/lib/arjdbc/mssql/database_statements.rb +44 -6
  44. data/lib/arjdbc/mssql/errors.rb +2 -0
  45. data/lib/arjdbc/mssql/explain_support.rb +3 -1
  46. data/lib/arjdbc/mssql/extensions/attribute_methods.rb +5 -1
  47. data/lib/arjdbc/mssql/extensions/calculations.rb +2 -0
  48. data/lib/arjdbc/mssql/quoting.rb +38 -0
  49. data/lib/arjdbc/mssql/schema_creation.rb +24 -2
  50. data/lib/arjdbc/mssql/schema_definitions.rb +10 -0
  51. data/lib/arjdbc/mssql/schema_dumper.rb +2 -0
  52. data/lib/arjdbc/mssql/schema_statements.rb +63 -21
  53. data/lib/arjdbc/mssql/transaction.rb +2 -0
  54. data/lib/arjdbc/mssql/types.rb +2 -0
  55. data/lib/arjdbc/mssql/types/binary_types.rb +2 -0
  56. data/lib/arjdbc/mssql/types/date_and_time_types.rb +2 -0
  57. data/lib/arjdbc/mssql/types/deprecated_types.rb +2 -0
  58. data/lib/arjdbc/mssql/types/numeric_types.rb +2 -0
  59. data/lib/arjdbc/mssql/types/string_types.rb +2 -0
  60. data/lib/arjdbc/mssql/utils.rb +2 -0
  61. data/lib/arjdbc/mysql/adapter.rb +47 -18
  62. data/lib/arjdbc/mysql/connection_methods.rb +13 -7
  63. data/lib/arjdbc/postgresql/adapter.rb +240 -214
  64. data/lib/arjdbc/postgresql/base/array_decoder.rb +2 -0
  65. data/lib/arjdbc/postgresql/base/array_encoder.rb +4 -2
  66. data/lib/arjdbc/postgresql/base/array_parser.rb +4 -2
  67. data/lib/arjdbc/postgresql/base/pgconn.rb +2 -0
  68. data/lib/arjdbc/postgresql/column.rb +11 -6
  69. data/lib/arjdbc/postgresql/connection_methods.rb +3 -1
  70. data/lib/arjdbc/postgresql/name.rb +2 -0
  71. data/lib/arjdbc/postgresql/oid_types.rb +3 -1
  72. data/lib/arjdbc/sqlite3/adapter.rb +188 -180
  73. data/lib/arjdbc/sqlite3/connection_methods.rb +16 -4
  74. data/lib/arjdbc/tasks/databases.rake +13 -10
  75. data/lib/arjdbc/tasks/mssql_database_tasks.rb +49 -5
  76. data/lib/arjdbc/util/quoted_cache.rb +3 -1
  77. data/lib/arjdbc/util/serialized_attributes.rb +3 -1
  78. data/lib/arjdbc/util/table_copier.rb +3 -1
  79. data/lib/arjdbc/version.rb +1 -1
  80. data/pom.xml +4 -4
  81. data/rakelib/01-tomcat.rake +2 -2
  82. data/rakelib/02-test.rake +0 -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 +468 -637
  87. data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +319 -38
  88. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +13 -23
  89. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +44 -31
  90. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +94 -99
  91. data/src/java/arjdbc/util/DateTimeUtils.java +34 -12
  92. metadata +7 -17
@@ -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
 
@@ -27,7 +24,7 @@ Gem::Specification.new do |gem|
27
24
  reject { |f| f =~ /^(gemfiles)/ } # no tests - no Gemfile_s appraised ...
28
25
  gem.files += ['lib/arjdbc/jdbc/adapter_java.jar'] #if ENV['RELEASE'].eql?('true')
29
26
 
30
- if ENV['RELEASE'] != 'true' # @see Rakefile
27
+ if ENV['INCLUDE_JAR_IN_GEM'] != 'true' # @see Rakefile
31
28
  gem.extensions << 'Rakefile' # to support auto-building .jar with :git paths
32
29
 
33
30
  #gem.add_runtime_dependency 'jar-dependencies', '~> 0.1' # development not enough!
@@ -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'
@@ -13,13 +13,10 @@ Gem::Specification.new do |gem|
13
13
  gem.description = "" <<
14
14
  "Fork of the ActiveRecord JDBC adapter with support for SQL Server and Azure SQL, " <<
15
15
  "for more information and help look at the README file in the github repository. " <<
16
- "AR-JDBC is a database adapter for Rails' ActiveRecord component designed " <<
17
- "to be used with JRuby built upon Java's JDBC API for database access. " <<
18
- "Provides (ActiveRecord) built-in adapters: MySQL, PostgreSQL and SQLite3 " <<
19
- "as well as adapters for popular databases such as Oracle, SQLServer, " <<
20
- "DB2, FireBird and even Java (embed) databases: Derby, HSQLDB and H2. " <<
21
- "It allows to connect to virtually any JDBC-compliant database with your " <<
22
- "JRuby on Rails application."
16
+ "AR-JDBC is a database adapter for Rails' ActiveRecord component " <<
17
+ "designed to be used with JRuby built upon Java's JDBC API for " <<
18
+ "database access. Provides (ActiveRecord) built-in adapters: MySQL, " <<
19
+ "PostgreSQL, SQLite3, and SQLServer."
23
20
 
24
21
  gem.require_paths = ["lib"]
25
22
 
@@ -29,7 +26,7 @@ Gem::Specification.new do |gem|
29
26
  reject { |f| f =~ /^(gemfiles)/ } # no tests - no Gemfile_s appraised ...
30
27
  gem.files += ['lib/arjdbc/jdbc/adapter_java.jar'] #if ENV['RELEASE'].eql?('true')
31
28
 
32
- if ENV['RELEASE'] != 'true' # @see Rakefile
29
+ if ENV['INCLUDE_JAR_IN_GEM'] != 'true' # @see Rakefile
33
30
  gem.extensions << 'Rakefile' # to support auto-building .jar with :git paths
34
31
 
35
32
  #gem.add_runtime_dependency 'jar-dependencies', '~> 0.1' # development not enough!
@@ -46,7 +43,7 @@ Gem::Specification.new do |gem|
46
43
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
47
44
  gem.test_files = gem.files.grep(%r{^test/})
48
45
 
49
- gem.add_dependency 'activerecord', '~> 5.2.0', '>= 5.2.3'
46
+ gem.add_dependency 'activerecord', '~> 6.0.0'
50
47
 
51
48
  #gem.add_development_dependency 'test-unit', '2.5.4'
52
49
  #gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
@@ -4,13 +4,8 @@
4
4
  module Arel
5
5
  module Visitors
6
6
  class SQLServer < Arel::Visitors::ToSql
7
-
8
- OFFSET = " OFFSET "
9
- ROWS = " ROWS"
10
- FETCH = " FETCH NEXT "
11
- FETCH0 = " FETCH FIRST (SELECT 0) "
12
- ROWS_ONLY = " ROWS ONLY"
13
-
7
+ # 'FETCH FIRST' or 'FETCH NEXT' do the same thing
8
+ # The SQL ANSI Standard says NEXT and FIRST are synonyms
14
9
 
15
10
  private
16
11
 
@@ -35,24 +30,24 @@ module Arel
35
30
 
36
31
  def visit_Arel_Nodes_Lock o, collector
37
32
  o.expr = Arel.sql('WITH(UPDLOCK)') if o.expr.to_s =~ /FOR UPDATE/
38
- collector << SPACE
33
+ collector << ' '
39
34
  visit o.expr, collector
40
35
  end
41
36
 
42
37
  def visit_Arel_Nodes_Offset o, collector
43
- collector << OFFSET
38
+ collector << ' OFFSET '
44
39
  visit o.expr, collector
45
- collector << ROWS
40
+ collector << ' ROWS'
46
41
  end
47
42
 
48
43
  def visit_Arel_Nodes_Limit o, collector
49
44
  if node_value(o) == 0
50
- collector << FETCH0
51
- collector << ROWS_ONLY
45
+ collector << ' FETCH FIRST (SELECT 0) '
46
+ collector << ' ROWS ONLY'
52
47
  else
53
- collector << FETCH
48
+ collector << ' FETCH NEXT '
54
49
  visit o.expr, collector
55
- collector << ROWS_ONLY
50
+ collector << ' ROWS ONLY'
56
51
  end
57
52
  end
58
53
 
@@ -61,7 +56,7 @@ module Arel
61
56
  distinct_One_As_One_Is_So_Not_Fetch o
62
57
  if o.with
63
58
  collector = visit o.with, collector
64
- collector << SPACE
59
+ collector << ' '
65
60
  end
66
61
  collector = o.cores.inject(collector) { |c,x|
67
62
  visit_Arel_Nodes_SelectCore(x, c)
@@ -99,7 +94,7 @@ module Arel
99
94
  collector = visit_Arel_Nodes_SelectStatement_SQLServer_Lock collector
100
95
  end
101
96
  if o.right.any?
102
- collector << SPACE if o.left
97
+ collector << ' ' if o.left
103
98
  collector = inject_join o.right, collector, ' '
104
99
  end
105
100
  collector
@@ -110,7 +105,7 @@ module Arel
110
105
  collector = visit o.left, collector
111
106
  collector = visit_Arel_Nodes_SelectStatement_SQLServer_Lock collector, space: true
112
107
  if o.right
113
- collector << SPACE
108
+ collector << ' '
114
109
  visit(o.right, collector)
115
110
  else
116
111
  collector
@@ -121,16 +116,31 @@ module Arel
121
116
  collector << "LEFT OUTER JOIN "
122
117
  collector = visit o.left, collector
123
118
  collector = visit_Arel_Nodes_SelectStatement_SQLServer_Lock collector, space: true
124
- collector << SPACE
119
+ collector << ' '
125
120
  visit o.right, collector
126
121
  end
127
122
 
123
+ # NOTE: this overrides the original method in arel visitors 'to_sql.rb'
124
+ # fixes The ORDER BY clause is invalid in subqueries
125
+ # FIXME: we should probably have a 2-pass visitor for this
126
+ def build_subselect(key, o)
127
+ stmt = Nodes::SelectStatement.new
128
+ core = stmt.cores.first
129
+ core.froms = o.relation
130
+ core.wheres = o.wheres
131
+ core.projections = [key]
132
+ stmt.limit = o.limit
133
+ stmt.offset = o.offset
134
+ stmt.orders = []
135
+ stmt
136
+ end
137
+
128
138
  # SQLServer ToSql/Visitor (Additions)
129
139
 
130
140
  def visit_Arel_Nodes_SelectStatement_SQLServer_Lock collector, options = {}
131
141
  if select_statement_lock?
132
142
  collector = visit @select_statement.lock, collector
133
- collector << SPACE if options[:space]
143
+ collector << ' ' if options[:space]
134
144
  end
135
145
  collector
136
146
  end
@@ -138,12 +148,12 @@ module Arel
138
148
  def visit_Orders_And_Let_Fetch_Happen o, collector
139
149
  make_Fetch_Possible_And_Deterministic o
140
150
  unless o.orders.empty?
141
- collector << SPACE
142
- collector << ORDER_BY
151
+ collector << ' '
152
+ collector << ' ORDER BY '
143
153
  len = o.orders.length - 1
144
154
  o.orders.each_with_index { |x, i|
145
155
  collector = visit(x, collector)
146
- collector << COMMA unless len == i
156
+ collector << ', ' unless len == i
147
157
  }
148
158
  end
149
159
  collector
@@ -205,7 +215,7 @@ module Arel
205
215
  elsif Arel::Nodes::SqlLiteral === core.from
206
216
  Arel::Table.new(core.from)
207
217
  elsif Arel::Nodes::JoinSource === core.source
208
- Arel::Nodes::SqlLiteral === core.source.left ? Arel::Table.new(core.source.left, @engine) : core.source.left
218
+ Arel::Nodes::SqlLiteral === core.source.left ? Arel::Table.new(core.source.left, @engine) : core.source.left.left
209
219
  end
210
220
  end
211
221
 
@@ -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,29 +36,27 @@ 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
59
- else ActiveRecord::StatementInvalid.new(message)
56
+ case exception
57
+ when SystemExit, SignalException, NoMemoryError then exception
58
+ when ActiveModel::RangeError, TypeError, RuntimeError then exception
59
+ else super
60
60
  end
61
61
  end
62
62
 
@@ -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,11 +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
+
19
+ binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
20
+
13
21
  if without_prepared_statement?(binds)
14
- log(sql, name) { @connection.execute_insert(sql) }
22
+ log(sql, name) { @connection.execute_insert_pk(sql, pk) }
15
23
  else
16
24
  log(sql, name, binds) do
17
- @connection.execute_insert(sql, binds)
25
+ @connection.execute_insert_pk(sql, binds, pk)
18
26
  end
19
27
  end
20
28
  end
@@ -22,6 +30,14 @@ module ArJdbc
22
30
  # It appears that at this point (AR 5.0) "prepare" should only ever be true
23
31
  # if prepared statements are enabled
24
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
+
39
+ binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
40
+
25
41
  if without_prepared_statement?(binds)
26
42
  log(sql, name) { @connection.execute_query(sql) }
27
43
  else
@@ -34,6 +50,14 @@ module ArJdbc
34
50
  end
35
51
 
36
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
+
59
+ binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
60
+
37
61
  if without_prepared_statement?(binds)
38
62
  log(sql, name) { @connection.execute_update(sql) }
39
63
  else
@@ -42,26 +66,13 @@ module ArJdbc
42
66
  end
43
67
  alias :exec_delete :exec_update
44
68
 
45
- # overridden to support legacy binds
46
- def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [])
47
- binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
48
- super
49
- end
50
- alias create insert
51
-
52
- # overridden to support legacy binds
53
- def update(arel, name = nil, binds = [])
54
- binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
55
- super
56
- end
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
57
73
 
58
- # overridden to support legacy binds
59
- def delete(arel, name = nil, binds = [])
60
- binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
61
- super
62
- end
74
+ materialize_transactions
63
75
 
64
- def execute(sql, name = nil)
65
76
  log(sql, name) { @connection.execute(sql) }
66
77
  end
67
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ArJdbc
2
4
  module Abstract
3
5
 
@@ -22,7 +24,7 @@ module ArJdbc
22
24
  # Starts a database transaction.
23
25
  # @override
24
26
  def begin_db_transaction
25
- log('BEGIN TRANSACTION'.freeze, nil) { @connection.begin }
27
+ log('BEGIN TRANSACTION', nil) { @connection.begin }
26
28
  end
27
29
 
28
30
  # Starts a database transaction.
@@ -34,14 +36,14 @@ module ArJdbc
34
36
  # Commits the current database transaction.
35
37
  # @override
36
38
  def commit_db_transaction
37
- log('COMMIT TRANSACTION'.freeze, nil) { @connection.commit }
39
+ log('COMMIT TRANSACTION', nil) { @connection.commit }
38
40
  end
39
41
 
40
42
  # Rolls back the current database transaction.
41
43
  # Called from 'rollback_db_transaction' in the AbstractAdapter
42
44
  # @override
43
45
  def exec_rollback_db_transaction
44
- log('ROLLBACK TRANSACTION'.freeze, nil) { @connection.rollback }
46
+ log('ROLLBACK TRANSACTION', nil) { @connection.rollback }
45
47
  end
46
48
 
47
49
  ########################## Savepoint Interface ############################
@@ -80,45 +80,6 @@ module ArJdbc
80
80
 
81
81
  private
82
82
 
83
- def simplified_type(field_type)
84
- case field_type
85
- when /^decimal\(1\)$/i then DB2.emulate_booleans? ? :boolean : :integer
86
- when /smallint/i then DB2.emulate_booleans? ? :boolean : :integer
87
- when /boolean/i then :boolean
88
- when /^real|double/i then :float
89
- when /int|serial/i then :integer
90
- # if a numeric column has no scale, lets treat it as an integer.
91
- # The AS400 rpg guys do this ALOT since they have no integer datatype ...
92
- when /decimal|numeric|decfloat/i
93
- extract_scale(field_type) == 0 ? :integer : :decimal
94
- when /timestamp/i then :timestamp
95
- when /datetime/i then :datetime
96
- when /time/i then :time
97
- when /date/i then :date
98
- # DB2 provides three data types to store these data objects as strings of up to 2 GB in size:
99
- # Character large objects (CLOBs)
100
- # Use the CLOB data type to store SBCS or mixed data, such as documents that contain
101
- # single character set. Use this data type if your data is larger (or might grow larger)
102
- # than the VARCHAR data type permits.
103
- # Double-byte character large objects (DBCLOBs)
104
- # Use the DBCLOB data type to store large amounts of DBCS data, such as documents that
105
- # use a DBCS character set.
106
- # Binary large objects (BLOBs)
107
- # Use the BLOB data type to store large amounts of noncharacter data, such as pictures,
108
- # voice, and mixed media.
109
- when /clob|text/i then :text # handles DBCLOB
110
- when /^long varchar/i then :text # :limit => 32700
111
- when /blob|binary/i then :binary
112
- # varchar () for bit data, char () for bit data, long varchar for bit data
113
- when /for bit data/i then :binary
114
- when /xml/i then :xml
115
- when /graphic/i then :graphic # vargraphic, long vargraphic
116
- when /rowid/i then :rowid # rowid is a supported datatype on z/OS and i/5
117
- else
118
- super
119
- end
120
- end
121
-
122
83
  # Post process default value from JDBC into a Rails-friendly format (columns{-internal})
123
84
  def default_value(value)
124
85
  # IBM i (AS400) will return an empty string instead of null for no default