activerecord-jdbc-adapter 70.0.pre-java → 70.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/activerecord-jdbc-adapter.gemspec +1 -3
  4. data/lib/arel/visitors/compat.rb +5 -33
  5. data/lib/arel/visitors/h2.rb +1 -13
  6. data/lib/arel/visitors/hsqldb.rb +1 -21
  7. data/lib/arel/visitors/sql_server.rb +2 -103
  8. data/lib/arjdbc/abstract/core.rb +8 -9
  9. data/lib/arjdbc/abstract/database_statements.rb +8 -0
  10. data/lib/arjdbc/discover.rb +0 -67
  11. data/lib/arjdbc/jdbc/adapter.rb +1 -1
  12. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  13. data/lib/arjdbc/jdbc/column.rb +1 -26
  14. data/lib/arjdbc/jdbc.rb +0 -7
  15. data/lib/arjdbc/mysql/adapter.rb +2 -1
  16. data/lib/arjdbc/mysql/connection_methods.rb +43 -42
  17. data/lib/arjdbc/oracle/adapter.rb +4 -23
  18. data/lib/arjdbc/postgresql/adapter.rb +152 -3
  19. data/lib/arjdbc/postgresql/oid_types.rb +155 -108
  20. data/lib/arjdbc/sqlite3/adapter.rb +54 -36
  21. data/lib/arjdbc/tasks/database_tasks.rb +0 -15
  22. data/lib/arjdbc/util/serialized_attributes.rb +0 -22
  23. data/lib/arjdbc/util/table_copier.rb +2 -1
  24. data/lib/arjdbc/version.rb +1 -1
  25. data/rakelib/02-test.rake +3 -18
  26. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +1 -1
  27. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +5 -0
  28. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +6 -1
  29. metadata +6 -39
  30. data/lib/active_record/connection_adapters/as400_adapter.rb +0 -2
  31. data/lib/active_record/connection_adapters/db2_adapter.rb +0 -1
  32. data/lib/active_record/connection_adapters/derby_adapter.rb +0 -1
  33. data/lib/active_record/connection_adapters/informix_adapter.rb +0 -1
  34. data/lib/arel/visitors/db2.rb +0 -137
  35. data/lib/arel/visitors/derby.rb +0 -112
  36. data/lib/arel/visitors/firebird.rb +0 -79
  37. data/lib/arjdbc/db2/adapter.rb +0 -808
  38. data/lib/arjdbc/db2/as400.rb +0 -142
  39. data/lib/arjdbc/db2/column.rb +0 -131
  40. data/lib/arjdbc/db2/connection_methods.rb +0 -48
  41. data/lib/arjdbc/db2.rb +0 -4
  42. data/lib/arjdbc/derby/active_record_patch.rb +0 -13
  43. data/lib/arjdbc/derby/adapter.rb +0 -521
  44. data/lib/arjdbc/derby/connection_methods.rb +0 -20
  45. data/lib/arjdbc/derby/schema_creation.rb +0 -15
  46. data/lib/arjdbc/derby.rb +0 -3
  47. data/lib/arjdbc/firebird/adapter.rb +0 -413
  48. data/lib/arjdbc/firebird/connection_methods.rb +0 -23
  49. data/lib/arjdbc/firebird.rb +0 -4
  50. data/lib/arjdbc/informix/adapter.rb +0 -139
  51. data/lib/arjdbc/informix/connection_methods.rb +0 -9
  52. data/lib/arjdbc/sybase/adapter.rb +0 -47
  53. data/lib/arjdbc/sybase.rb +0 -2
  54. data/lib/arjdbc/tasks/db2_database_tasks.rb +0 -104
  55. data/lib/arjdbc/tasks/derby_database_tasks.rb +0 -95
  56. data/src/java/arjdbc/derby/DerbyModule.java +0 -178
  57. data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +0 -152
  58. data/src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java +0 -174
  59. data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +0 -75
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0552eaeb2b86ff8a8a2e24e86c56315c059dff050596c329cb5a082ad9d0c460
4
- data.tar.gz: 12c7b5068269990ed27e15e7ef0d97ba0928a7bbcfbc6ca2cc6aa3e854d780ba
3
+ metadata.gz: 91bed685b2bb3b78dbf3ddc464f79e8c8023a3f9790c96c498e77398a3e589b1
4
+ data.tar.gz: d6056d03d71a6558172737f827429e379d8f855d74b9a091ca78623646c68dff
5
5
  SHA512:
6
- metadata.gz: 90f35907b970e53e8c3910cf7d6e572a33d78270ab7002ad7c10170bdff4872d8784bf4d361b6ef5d1dda397387e5e2804fabee549b195e594178ba7bcfa7b97
7
- data.tar.gz: 10be265dd0aab6905de89bb779b1aa653e004e0ed0d5a536c4a54ca876b2dc806c17da8d36b2a15c1852c97e87305b29edc99c5e05e2d946f43e44202a989288
6
+ metadata.gz: d8154960b44d44a8419ab4f57e5e3d9ffc622245472f9c23de709d38bb0745d593dfa3a8477e90c71c0547f18a0dc94a6a8d2fb97c65a59e18fdede3eb526b47
7
+ data.tar.gz: e4db4d37e11007a182f091995550c5cc74897183c9732faab755dc08e39f95f489459350bb8857d2d1936e93f2cad8cb199889107204ac8f93b6fc21855c374f
data/Rakefile CHANGED
@@ -26,7 +26,7 @@
26
26
 
27
27
  require 'rake/clean'
28
28
 
29
- CLEAN.include 'derby*', 'test.db.*', '*test.sqlite3', 'test/reports'
29
+ CLEAN.include 'test.db.*', '*test.sqlite3', 'test/reports'
30
30
  CLEAN.include 'lib/**/*.jar', 'MANIFEST.MF', '*.log', 'target/*'
31
31
 
32
32
  task :default => :jar # RubyGems extention will do a bare `rake' e.g. :
@@ -1,7 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- path = File.expand_path('lib/arjdbc/version.rb', File.dirname(__FILE__))
4
- puts "VERSION: #{File.read(path).match( /.*VERSION\s*=\s*['"](.*)['"]/m )[1]}"
5
3
  Gem::Specification.new do |gem|
6
4
  gem.name = 'activerecord-jdbc-adapter'
7
5
  path = File.expand_path('lib/arjdbc/version.rb', File.dirname(__FILE__))
@@ -49,6 +47,6 @@ Gem::Specification.new do |gem|
49
47
  #gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
50
48
  #gem.add_development_dependency 'mocha', '~> 0.13.1'
51
49
 
52
- gem.rdoc_options = ["--main", "README.md", "-SHN", "-f", "darkfish"]
50
+ gem.rdoc_options = ["--main", "README.md"]
53
51
  end
54
52
 
@@ -4,44 +4,16 @@ module Arel
4
4
 
5
5
  protected
6
6
 
7
- if ToSql.instance_method('visit').arity == 1
8
- def do_visit(x, a); visit(x); end # a = nil
9
- else # > AREL 4.0
10
- def do_visit(x, a); visit(x, a); end
11
- end
7
+ def do_visit(x, a); visit(x, a); end
12
8
 
13
- if ToSql.instance_method('visit_Arel_Nodes_SelectCore').arity == 1
14
- def do_visit_select_core(x, a) # a = nil
15
- visit_Arel_Nodes_SelectCore(x)
16
- end
17
- else # > AREL 4.0
18
- def do_visit_select_core(x, a)
19
- visit_Arel_Nodes_SelectCore(x, a)
20
- end
9
+ def do_visit_select_core(x, a)
10
+ visit_Arel_Nodes_SelectCore(x, a)
21
11
  end
22
12
 
23
13
  private
24
14
 
25
- if ArJdbc::AR42
26
- if Arel::VERSION < '6.0.2'
27
- def limit_for(limit_or_node)
28
- if limit_or_node.respond_to?(:expr)
29
- expr = limit_or_node.expr
30
- # NOTE(uwe): Different behavior for Arel 6.0.0 and 6.0.2
31
- expr.respond_to?(:value) ? expr.value.to_i : expr.to_i
32
- else
33
- limit_or_node
34
- end
35
- end
36
- else
37
- def limit_for(limit_or_node)
38
- limit_or_node.respond_to?(:expr) ? limit_or_node.expr.to_i : limit_or_node
39
- end
40
- end
41
- else
42
- def limit_for(limit_or_node)
43
- limit_or_node.respond_to?(:expr) ? limit_or_node.expr.to_i : limit_or_node
44
- end
15
+ def limit_for(limit_or_node)
16
+ limit_or_node.respond_to?(:expr) ? limit_or_node.expr.to_i : limit_or_node
45
17
  end
46
18
  module_function :limit_for
47
19
 
@@ -7,19 +7,7 @@ module Arel
7
7
  def visit_Arel_Nodes_SelectStatement(o, *)
8
8
  o.limit ||= Arel::Nodes::Limit.new(-1) if o.offset
9
9
  super
10
- end if ArJdbc::AR42
11
-
12
- def limit_offset sql, o
13
- offset = o.offset || 0
14
- offset = offset.expr unless (offset.nil? || offset == 0)
15
- if limit = o.limit
16
- "SELECT LIMIT #{offset} #{limit_for(limit)} #{sql[7..-1]}"
17
- elsif offset > 0
18
- "SELECT LIMIT #{offset} -1 #{sql[7..-1]}" # removes "SELECT "
19
- else
20
- sql
21
- end
22
- end unless ArJdbc::AR42
10
+ end
23
11
  end
24
12
  end
25
13
  end
@@ -6,27 +6,7 @@ module Arel
6
6
  def visit_Arel_Nodes_SelectStatement(o, *)
7
7
  o.limit ||= Arel::Nodes::Limit.new(0) if o.offset
8
8
  super
9
- end if ArJdbc::AR42
10
-
11
- def visit_Arel_Nodes_SelectStatement o, a = nil
12
- sql = limit_offset(o.cores.map { |x| do_visit_select_core x, a }.join, o)
13
- sql << " ORDER BY #{o.orders.map { |x| do_visit x, a }.join(', ')}" unless o.orders.empty?
14
- sql
15
- end unless ArJdbc::AR42
16
-
17
- private
18
-
19
- def limit_offset sql, o
20
- offset = o.offset || 0
21
- offset = offset.expr unless (offset.nil? || offset == 0)
22
- if limit = o.limit
23
- "SELECT LIMIT #{offset} #{limit_for(limit)} #{sql[7..-1]}"
24
- elsif offset > 0
25
- "SELECT LIMIT #{offset} 0 #{sql[7..-1]}" # removes "SELECT "
26
- else
27
- sql
28
- end
29
- end unless ArJdbc::AR42
9
+ end
30
10
  end
31
11
  end
32
12
  end
@@ -11,44 +11,6 @@ module Arel
11
11
 
12
12
  private
13
13
 
14
- def visit_Arel_Nodes_SelectStatement(*args) # [o] AR <= 4.0 [o, a] on 4.1
15
- o, a = args.first, args.last
16
-
17
- return _visit_Arel_Nodes_SelectStatement(*args) if ! o.limit && ! o.offset
18
-
19
- unless o.orders.empty?
20
- select_order_by = do_visit_columns o.orders, a, 'ORDER BY '
21
- end
22
-
23
- select_count = false; sql = ''
24
- o.cores.each do |x|
25
- x = x.dup
26
- core_order_by = select_order_by || determine_order_by(x, a)
27
- if select_count? x
28
- x.projections = [
29
- Arel::Nodes::SqlLiteral.new(core_order_by ? over_row_num(core_order_by) : '*')
30
- ]
31
- select_count = true
32
- else
33
- # NOTE: this should really be added here and we should built the
34
- # wrapping SQL but than #replace_limit_offset! assumes it does that
35
- # ... MS-SQL adapter code seems to be 'hacked' by a lot of people
36
- #x.projections << Arel::Nodes::SqlLiteral.new over_row_num(order_by)
37
- end
38
- sql << do_visit_select_core(x, a)
39
- end
40
-
41
- #sql = "SELECT _t.* FROM (#{sql}) as _t WHERE #{get_offset_limit_clause(o)}"
42
- select_order_by ||= "ORDER BY #{@connection.determine_order_clause(sql)}"
43
- replace_limit_offset!(sql, limit_for(o.limit), o.offset && o.offset.value.to_i, select_order_by)
44
-
45
- sql = "SELECT COUNT(*) AS count_id FROM (#{sql}) AS subquery" if select_count
46
-
47
- add_lock!(sql, :lock => o.lock && true)
48
-
49
- sql
50
- end unless ArJdbc::AR42
51
-
52
14
  # @private
53
15
  MAX_LIMIT_VALUE = 9_223_372_036_854_775_807
54
16
 
@@ -60,14 +22,6 @@ module Arel
60
22
  super
61
23
  end
62
24
 
63
- def visit_Arel_Nodes_Lock o, a = nil
64
- # MS-SQL doesn't support "SELECT...FOR UPDATE". Instead, it needs
65
- # WITH(ROWLOCK,UPDLOCK) specified after each table in the FROM clause.
66
- #
67
- # we return nothing here and add the appropriate stuff with #add_lock!
68
- #do_visit o.expr, a
69
- end unless ArJdbc::AR42
70
-
71
25
  def visit_Arel_Nodes_Top o, a = nil
72
26
  # `top` wouldn't really work here:
73
27
  # User.select("distinct first_name").limit(10)
@@ -76,29 +30,6 @@ module Arel
76
30
  a || ''
77
31
  end
78
32
 
79
- def visit_Arel_Nodes_Limit o, a = nil
80
- "TOP (#{do_visit o.expr, a})"
81
- end unless ArJdbc::AR42
82
-
83
- def visit_Arel_Nodes_Ordering o, a = nil
84
- expr = do_visit o.expr, a
85
- if o.respond_to?(:direction)
86
- "#{expr} #{o.ascending? ? 'ASC' : 'DESC'}"
87
- else
88
- expr
89
- end
90
- end unless ArJdbc::AR42
91
-
92
- def visit_Arel_Nodes_Bin o, a = nil
93
- expr = o.expr; sql = do_visit expr, a
94
- if expr.respond_to?(:val) && expr.val.is_a?(Numeric)
95
- sql
96
- else
97
- sql << " #{::ArJdbc::MSSQL.cs_equality_operator} "
98
- sql
99
- end
100
- end unless ArJdbc::AR42
101
-
102
33
  private
103
34
 
104
35
  def self.possibly_private_method_defined?(name)
@@ -140,25 +71,7 @@ module Arel
140
71
  visit(x, sql); sql << ', ' unless i == last
141
72
  end
142
73
  sql.value
143
- end if ArJdbc::AR42
144
-
145
- def do_visit_columns(colls, a, sql)
146
- non_simple_order = /\sASC|\sDESC|\sCASE|\sCOLLATE|[\.,\[\(]/i # MIN(width)
147
-
148
- last = colls.size - 1
149
- colls.each_with_index do |x, i|
150
- coll = do_visit(x, a)
151
-
152
- if coll !~ non_simple_order && coll.to_i == 0
153
- sql << @connection.quote_column_name(coll)
154
- else
155
- sql << coll
156
- end
157
-
158
- sql << ', ' unless i == last
159
- end
160
- sql
161
- end if Arel::VERSION < '4.0.0'
74
+ end
162
75
 
163
76
  def over_row_num order_by
164
77
  "ROW_NUMBER() OVER (#{order_by}) as _row_num"
@@ -174,20 +87,6 @@ module Arel
174
87
  end
175
88
  end
176
89
 
177
- def table_from_select_core core
178
- table_finder = lambda do |x|
179
- case x
180
- when Arel::Table
181
- x
182
- when Arel::Nodes::SqlLiteral
183
- Arel::Table.new(x, @engine)
184
- when Arel::Nodes::Join
185
- table_finder.call(x.left)
186
- end
187
- end
188
- table_finder.call(core.froms)
189
- end if ActiveRecord::VERSION::STRING < '3.2'
190
-
191
90
  def primary_key_from_table t
192
91
  return unless t
193
92
  return t.primary_key if t.primary_key
@@ -219,7 +118,7 @@ module Arel
219
118
  include ArJdbc::MSSQL::LimitHelpers::SqlServer2000ReplaceLimitOffset
220
119
  end
221
120
 
222
- load 'arel/visitors/sql_server/ng42.rb' if ArJdbc::AR42
121
+ load 'arel/visitors/sql_server/ng42.rb'
223
122
 
224
123
  end
225
124
  end
@@ -34,7 +34,7 @@ module ArJdbc
34
34
  raw_connection.jdbc_connection(unwrap)
35
35
  end
36
36
 
37
- protected
37
+ private
38
38
 
39
39
  def translate_exception_class(e, sql, binds)
40
40
  message = "#{e.class.name}: #{e.message}"
@@ -42,16 +42,19 @@ module ArJdbc
42
42
  exception = translate_exception(
43
43
  e, message: message, sql: sql, binds: binds
44
44
  )
45
- exception.set_backtrace e.backtrace
45
+ exception.set_backtrace e.backtrace unless exception.equal?(e)
46
46
  exception
47
47
  end
48
48
 
49
+ Throwable = java.lang.Throwable
50
+ private_constant :Throwable
51
+
49
52
  def translate_exception(exception, message:, sql:, binds:)
50
53
  # override in derived class
51
54
 
52
55
  # we shall not translate native "Java" exceptions as they might
53
56
  # swallow an ArJdbc / driver bug into an AR::StatementInvalid !
54
- return exception if exception.is_a?(Java::JavaLang::Throwable)
57
+ return exception if exception.is_a?(Throwable)
55
58
 
56
59
  case exception
57
60
  when SystemExit, SignalException, NoMemoryError then exception
@@ -61,14 +64,10 @@ module ArJdbc
61
64
  end
62
65
  end
63
66
 
64
- def extract_raw_bind_values(binds)
65
- binds.map(&:value_for_database)
66
- end
67
-
68
67
  # this version of log() automatically fills type_casted_binds from binds if necessary
69
- def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil)
68
+ def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil, async: false)
70
69
  if binds.any? && (type_casted_binds.nil? || type_casted_binds.empty?)
71
- type_casted_binds = ->{ extract_raw_bind_values(binds) }
70
+ type_casted_binds = ->{ binds.map(&:value_for_database) } # extract_raw_bind_values
72
71
  end
73
72
  super
74
73
  end
@@ -10,6 +10,8 @@ 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
+ sql = transform_query(sql)
14
+
13
15
  if preventing_writes?
14
16
  raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
15
17
  end
@@ -31,6 +33,8 @@ module ArJdbc
31
33
  # It appears that at this point (AR 5.0) "prepare" should only ever be true
32
34
  # if prepared statements are enabled
33
35
  def exec_query(sql, name = nil, binds = NO_BINDS, prepare: false, async: false)
36
+ sql = transform_query(sql)
37
+
34
38
  if preventing_writes? && write_query?(sql)
35
39
  raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
36
40
  end
@@ -52,6 +56,8 @@ module ArJdbc
52
56
  end
53
57
 
54
58
  def exec_update(sql, name = nil, binds = NO_BINDS)
59
+ sql = transform_query(sql)
60
+
55
61
  if preventing_writes?
56
62
  raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
57
63
  end
@@ -70,6 +76,8 @@ module ArJdbc
70
76
  alias :exec_delete :exec_update
71
77
 
72
78
  def execute(sql, name = nil, async: false)
79
+ sql = transform_query(sql)
80
+
73
81
  if preventing_writes? && write_query?(sql)
74
82
  raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
75
83
  end
@@ -23,26 +23,6 @@ module ArJdbc
23
23
  require('arjdbc/sqlite3') || true if name =~ /sqlite/i
24
24
  end
25
25
 
26
- # Other supported adapters :
27
-
28
- extension :Derby do |name, config|
29
- if name =~ /derby/i
30
- require 'arjdbc/derby'
31
-
32
- if config && config[:username].nil? # set the database schema name (:username) :
33
- begin
34
- ArJdbc.with_meta_data_from_data_source_if_any(config) do
35
- |meta_data| config[:username] = meta_data.getUserName
36
- end
37
- rescue => e
38
- ArJdbc.warn("failed to set :username from (Derby) database meda-data: #{e.inspect}")
39
- end
40
- end
41
-
42
- true
43
- end
44
- end
45
-
46
26
  extension :H2 do |name|
47
27
  require('arjdbc/h2') || true if name =~ /\.h2\./i
48
28
  end
@@ -54,51 +34,4 @@ module ArJdbc
54
34
  extension :MSSQL do |name|
55
35
  require('arjdbc/mssql') || true if name =~ /sqlserver|tds|Microsoft SQL/i
56
36
  end
57
-
58
- extension :DB2 do |name, config|
59
- if name =~ /db2/i && name !~ /as\/?400/i && config[:url] !~ /^jdbc:derby:net:/
60
- require 'arjdbc/db2'
61
- true
62
- end
63
- end
64
-
65
- extension :AS400 do |name, config|
66
- # The native JDBC driver always returns "DB2 UDB for AS/400"
67
- if name =~ /as\/?400/i
68
- require 'arjdbc/db2'
69
- require 'arjdbc/db2/as400'
70
- true
71
- end
72
- end
73
-
74
- # NOTE: following ones are likely getting deprecated :
75
-
76
- extension :FireBird do |name|
77
- if name =~ /firebird/i
78
- require 'arjdbc/firebird'
79
- true
80
- end
81
- end
82
-
83
- extension :Sybase do |name|
84
- if name =~ /sybase|tds/i
85
- require 'arjdbc/sybase'
86
- true
87
- end
88
- end
89
-
90
- extension :Informix do |name|
91
- if name =~ /informix/i
92
- require 'arjdbc/informix'
93
- true
94
- end
95
- end
96
-
97
- extension :Mimer do |name|
98
- if name =~ /mimer/i
99
- require 'arjdbc/mimer'
100
- true
101
- end
102
- end
103
-
104
37
  end
@@ -431,7 +431,7 @@ module ActiveRecord
431
431
  private
432
432
 
433
433
  # Helper useful during {#quote} since AREL might pass in it's literals
434
- # to be quoted, fixed since AREL 4.0.0.beta1 : http://git.io/7gyTig
434
+ # to be quoted, fixed since AREL 4.0.0.beta1 : https://github.com/rails/arel/commit/9c514f3
435
435
  def sql_literal?(value); ::Arel::Nodes::SqlLiteral === value; end
436
436
 
437
437
  # Helper to get local/UTC time (based on `ActiveRecord::default_timezone`).
Binary file
@@ -28,21 +28,6 @@ module ActiveRecord
28
28
  end
29
29
  end
30
30
 
31
- if ArJdbc::AR52
32
- # undefined method `cast' for #<ActiveRecord::ConnectionAdapters::SqlTypeMetadata> on AR52
33
- else
34
- default = args[0].cast(default)
35
-
36
- sql_type = args.delete_at(1)
37
- type = args.delete_at(0)
38
-
39
- args.unshift(SqlTypeMetadata.new(:sql_type => sql_type, :type => type))
40
- end
41
-
42
- # super <= 4.1: (name, default, sql_type = nil, null = true)
43
- # super >= 4.2: (name, default, cast_type, sql_type = nil, null = true)
44
- # super >= 5.0: (name, default, sql_type_metadata = nil, null = true)
45
-
46
31
  super(name, default, *args)
47
32
  init_column(name, default, *args)
48
33
  end
@@ -80,18 +65,8 @@ module ActiveRecord
80
65
  end
81
66
 
82
67
  class << self
83
-
84
- include Jdbc::TypeCast if ::ActiveRecord::VERSION::STRING >= '4.2'
85
-
86
- if ActiveRecord::VERSION::MAJOR > 3 && ActiveRecord::VERSION::STRING < '4.2'
87
-
88
- # @private provides compatibility between AR 3.x/4.0 API
89
- def string_to_date(value); value_to_date(value) end
90
-
91
- end
92
-
68
+ include Jdbc::TypeCast
93
69
  end
94
-
95
70
  end
96
71
  end
97
72
  end
data/lib/arjdbc/jdbc.rb CHANGED
@@ -1,13 +1,6 @@
1
1
  require 'active_support/deprecation'
2
2
 
3
3
  module ArJdbc
4
-
5
- # @private
6
- AR42 = ::ActiveRecord::VERSION::STRING >= '4.2'
7
-
8
- # @private
9
- AR52 = ::ActiveRecord::VERSION::STRING >= '5.2'
10
-
11
4
  class << self
12
5
 
13
6
  # @private Internal API
@@ -107,7 +107,8 @@ module ActiveRecord
107
107
 
108
108
  # Reloading the type map in abstract/statement_cache.rb blows up postgres
109
109
  def clear_cache!
110
- reload_type_map
110
+ # FIXME: This seems to have disappeared in Rails 7?
111
+ # reload_type_map
111
112
  super
112
113
  end
113
114
 
@@ -126,51 +126,52 @@ ArJdbc::ConnectionMethods.module_eval do
126
126
 
127
127
  private
128
128
 
129
- @@mysql_encodings = nil
129
+ MYSQL_ENCODINGS = {
130
+ "big5" => "Big5",
131
+ "dec8" => nil,
132
+ #"cp850" => "Cp850",
133
+ "hp8" => nil,
134
+ #"koi8r" => "KOI8-R",
135
+ "latin1" => "Cp1252",
136
+ "latin2" => "ISO8859_2",
137
+ "swe7" => nil,
138
+ "ascii" => "US-ASCII",
139
+ "ujis" => "EUC_JP",
140
+ "sjis" => "SJIS",
141
+ "hebrew" => "ISO8859_8",
142
+ "tis620" => "TIS620",
143
+ "euckr" => "EUC_KR",
144
+ #"koi8u" => "KOI8-R",
145
+ "gb2312" => "EUC_CN",
146
+ "greek" => "ISO8859_7",
147
+ "cp1250" => "Cp1250",
148
+ "gbk" => "GBK",
149
+ #"latin5" => "ISO-8859-9",
150
+ "armscii8" => nil,
151
+ "ucs2" => "UnicodeBig",
152
+ "cp866" => "Cp866",
153
+ "keybcs2" => nil,
154
+ "macce" => "MacCentralEurope",
155
+ "macroman" => "MacRoman",
156
+ #"cp852" => "CP852",
157
+ #"latin7" => "ISO-8859-13",
158
+ "cp1251" => "Cp1251",
159
+ "cp1256" => "Cp1256",
160
+ "cp1257" => "Cp1257",
161
+ "binary" => false,
162
+ "geostd8" => nil,
163
+ "cp932" => "Cp932",
164
+ #"eucjpms" => "eucJP-ms"
165
+ "utf8" => "UTF-8",
166
+ "utf8mb4" => false,
167
+ "utf16" => false,
168
+ "utf32" => false,
169
+ }
170
+
130
171
 
131
172
  # @see https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-charsets.html
132
173
  def convert_mysql_encoding(encoding) # to charset-name (characterEncoding=...)
133
- ( @@mysql_encodings ||= {
134
- "big5" => "Big5",
135
- "dec8" => nil,
136
- #"cp850" => "Cp850",
137
- "hp8" => nil,
138
- #"koi8r" => "KOI8-R",
139
- "latin1" => "Cp1252",
140
- "latin2" => "ISO8859_2",
141
- "swe7" => nil,
142
- "ascii" => "US-ASCII",
143
- "ujis" => "EUC_JP",
144
- "sjis" => "SJIS",
145
- "hebrew" => "ISO8859_8",
146
- "tis620" => "TIS620",
147
- "euckr" => "EUC_KR",
148
- #"koi8u" => "KOI8-R",
149
- "gb2312" => "EUC_CN",
150
- "greek" => "ISO8859_7",
151
- "cp1250" => "Cp1250",
152
- "gbk" => "GBK",
153
- #"latin5" => "ISO-8859-9",
154
- "armscii8" => nil,
155
- "ucs2" => "UnicodeBig",
156
- "cp866" => "Cp866",
157
- "keybcs2" => nil,
158
- "macce" => "MacCentralEurope",
159
- "macroman" => "MacRoman",
160
- #"cp852" => "CP852",
161
- #"latin7" => "ISO-8859-13",
162
- "cp1251" => "Cp1251",
163
- "cp1256" => "Cp1256",
164
- "cp1257" => "Cp1257",
165
- "binary" => false,
166
- "geostd8" => nil,
167
- "cp932" => "Cp932",
168
- #"eucjpms" => "eucJP-ms"
169
- "utf8" => "UTF-8",
170
- "utf8mb4" => false,
171
- "utf16" => false,
172
- "utf32" => false,
173
- } )[ encoding ]
174
+ MYSQL_ENCODINGS[ encoding ]
174
175
  end
175
176
 
176
177
  end