activerecord-jdbc-adapter 1.3.0.rc1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/CONTRIBUTING.md +3 -5
  2. data/Gemfile +3 -5
  3. data/Gemfile.lock +1 -1
  4. data/History.md +30 -3
  5. data/README.md +14 -9
  6. data/gemfiles/rails23.gemfile +3 -0
  7. data/gemfiles/rails23.gemfile.lock +8 -0
  8. data/gemfiles/rails30.gemfile +3 -0
  9. data/gemfiles/rails30.gemfile.lock +11 -0
  10. data/gemfiles/rails31.gemfile +3 -0
  11. data/gemfiles/rails31.gemfile.lock +8 -0
  12. data/gemfiles/rails32.gemfile +3 -0
  13. data/gemfiles/rails32.gemfile.lock +11 -0
  14. data/gemfiles/rails40.gemfile +3 -0
  15. data/gemfiles/rails40.gemfile.lock +6 -0
  16. data/lib/arjdbc/db2/adapter.rb +39 -23
  17. data/lib/arjdbc/db2/column.rb +3 -3
  18. data/lib/arjdbc/derby/adapter.rb +45 -0
  19. data/lib/arjdbc/firebird/adapter.rb +38 -36
  20. data/lib/arjdbc/h2/adapter.rb +1 -1
  21. data/lib/arjdbc/hsqldb/adapter.rb +1 -0
  22. data/lib/arjdbc/hsqldb/explain_support.rb +6 -6
  23. data/lib/arjdbc/jdbc/adapter.rb +80 -39
  24. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  25. data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +3 -21
  26. data/lib/arjdbc/mssql/adapter.rb +41 -18
  27. data/lib/arjdbc/mssql/column.rb +3 -8
  28. data/lib/arjdbc/mssql/explain_support.rb +1 -1
  29. data/lib/arjdbc/mysql/adapter.rb +19 -9
  30. data/lib/arjdbc/mysql/column.rb +1 -1
  31. data/lib/arjdbc/mysql/connection_methods.rb +1 -0
  32. data/lib/arjdbc/mysql/explain_support.rb +2 -1
  33. data/lib/arjdbc/oracle/adapter.rb +42 -26
  34. data/lib/arjdbc/oracle/column.rb +1 -1
  35. data/lib/arjdbc/postgresql/adapter.rb +13 -4
  36. data/lib/arjdbc/sqlite3/adapter.rb +2 -0
  37. data/lib/arjdbc/tasks/oracle/enhanced_structure_dump.rb +5 -5
  38. data/lib/arjdbc/util/serialized_attributes.rb +87 -0
  39. data/lib/arjdbc/version.rb +1 -1
  40. data/rakelib/02-test.rake +1 -1
  41. data/rakelib/db.rake +1 -1
  42. data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +2 -2
  43. data/src/java/arjdbc/derby/DerbyModule.java +26 -173
  44. data/src/java/arjdbc/h2/H2Module.java +1 -0
  45. data/src/java/arjdbc/h2/H2RubyJdbcConnection.java +1 -2
  46. data/src/java/arjdbc/hsqldb/HSQLDBModule.java +10 -9
  47. data/src/java/arjdbc/jdbc/AdapterJavaService.java +3 -3
  48. data/src/java/arjdbc/jdbc/JdbcConnectionFactory.java +4 -3
  49. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +189 -70
  50. data/src/java/arjdbc/jdbc/SQLBlock.java +4 -4
  51. data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +6 -7
  52. data/src/java/arjdbc/mysql/MySQLModule.java +1 -0
  53. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +14 -9
  54. data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +19 -3
  55. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +305 -11
  56. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +3 -3
  57. metadata +6 -5
@@ -79,8 +79,8 @@ module ArJdbc
79
79
 
80
80
  def simplified_type(field_type)
81
81
  case field_type
82
- when /^decimal\(1\)$/i then DB2.emulate_booleans ? :boolean : :integer
83
- when /smallint/i then DB2.emulate_booleans ? :boolean : :integer
82
+ when /^decimal\(1\)$/i then DB2.emulate_booleans? ? :boolean : :integer
83
+ when /smallint/i then DB2.emulate_booleans? ? :boolean : :integer
84
84
  when /boolean/i then :boolean
85
85
  when /^real|double/i then :float
86
86
  when /int|serial/i then :integer
@@ -156,7 +156,7 @@ module ArJdbc
156
156
  return value unless value.is_a?(String)
157
157
  return nil if value.empty?
158
158
  return Time.now if value.index('CURRENT') == 0
159
-
159
+
160
160
  return value
161
161
  end
162
162
 
@@ -146,6 +146,46 @@ module ArJdbc
146
146
  NATIVE_DATABASE_TYPES
147
147
  end
148
148
 
149
+ # @override
150
+ def quote(value, column = nil)
151
+ return value.quoted_id if value.respond_to?(:quoted_id)
152
+ return value if sql_literal?(value)
153
+ return 'NULL' if value.nil?
154
+
155
+ column_type = column && column.type
156
+ if column_type == :string || column_type == :text
157
+ # Derby is not permissive
158
+ # e.g. sending an Integer to a VARCHAR column will fail
159
+ case value
160
+ when BigDecimal then value = value.to_s('F')
161
+ when Numeric then value = value.to_s
162
+ when true, false then value = value.to_s
163
+ when Date, Time then value = quoted_date(value)
164
+ else # on 2.3 attribute serialization needs to_yaml here
165
+ value = value.to_s if ActiveRecord::VERSION::MAJOR >= 3
166
+ end
167
+ end
168
+
169
+ case value
170
+ when String, ActiveSupport::Multibyte::Chars
171
+ if column_type == :text
172
+ "CAST('#{quote_string(value)}' AS CLOB)"
173
+ elsif column_type == :binary
174
+ "CAST(X'#{quote_binary(value)}' AS BLOB)"
175
+ elsif column_type == :xml
176
+ "XMLPARSE(DOCUMENT '#{quote_string(value)}' PRESERVE WHITESPACE)"
177
+ elsif column_type == :integer
178
+ value.to_i
179
+ elsif column_type == :float
180
+ value.to_f
181
+ else
182
+ "'#{quote_string(value)}'"
183
+ end
184
+ else
185
+ super
186
+ end
187
+ end
188
+
149
189
  # @override
150
190
  def quoted_date(value)
151
191
  if value.acts_like?(:time) && value.respond_to?(:usec)
@@ -367,6 +407,11 @@ module ArJdbc
367
407
  %Q{"#{name.to_s.upcase.gsub('"', '""')}"}
368
408
  end
369
409
 
410
+ # @override
411
+ def quote_table_name_for_assignment(table, attr)
412
+ quote_column_name(attr)
413
+ end if ::ActiveRecord::VERSION::MAJOR > 3
414
+
370
415
  # @note Only used with (non-AREL) ActiveRecord **2.3**.
371
416
  # @see Arel::Visitors::Derby
372
417
  def add_limit_offset!(sql, options)
@@ -11,18 +11,8 @@ module ArJdbc
11
11
  def self.initialize!
12
12
  return if @@_initialized; @@_initialized = true
13
13
 
14
- require 'arjdbc/jdbc/serialized_attributes_helper'
15
- ActiveRecord::Base.class_eval do
16
- def after_save_with_firebird_blob
17
- self.class.columns.select { |c| c.sql_type =~ /blob/i }.each do |column|
18
- value = ::ArJdbc::SerializedAttributesHelper.dump_column_value(self, column)
19
- next if value.nil?
20
-
21
- self.class.connection.update_lob_value(self, column, value)
22
- end
23
- end
24
- end
25
- ActiveRecord::Base.after_save :after_save_with_firebird_blob
14
+ require 'arjdbc/util/serialized_attributes'
15
+ Util::SerializedAttributes.setup /blob/i
26
16
  end
27
17
 
28
18
  # @see ActiveRecord::ConnectionAdapters::JdbcColumn#column_types
@@ -33,13 +23,6 @@ module ArJdbc
33
23
  # @see ActiveRecord::ConnectionAdapters::JdbcColumn
34
24
  module Column
35
25
 
36
- def simplified_type(field_type)
37
- case field_type
38
- when /timestamp/i then :datetime
39
- else super
40
- end
41
- end
42
-
43
26
  def default_value(value)
44
27
  return nil unless value
45
28
  if value =~ /^\s*DEFAULT\s+(.*)\s*$/i
@@ -47,6 +30,26 @@ module ArJdbc
47
30
  end
48
31
  end
49
32
 
33
+ private
34
+
35
+ def simplified_type(field_type)
36
+ case field_type
37
+ when /timestamp/i then :datetime
38
+ when /^smallint/i then :integer
39
+ when /^bigint|int/i then :integer
40
+ when /^double/i then :float # double precision
41
+ when /^decimal/i then
42
+ extract_scale(field_type) == 0 ? :integer : :decimal
43
+ when /^char\(1\)$/i then Firebird.emulate_booleans? ? :boolean : :string
44
+ when /^char/i then :string
45
+ when /^blob\ssub_type\s(\d)/i
46
+ return :binary if $1 == '0'
47
+ return :text if $1 == '1'
48
+ else
49
+ super
50
+ end
51
+ end
52
+
50
53
  end
51
54
 
52
55
  # @see ArJdbc::ArelHelper::ClassMethods#arel_visitor_type
@@ -59,14 +62,18 @@ module ArJdbc
59
62
  { 'firebird' => arel_visitor_type, 'firebirdsql' => arel_visitor_type }
60
63
  end
61
64
 
62
- # @@emulate_booleans = true
65
+ # @private
66
+ @@emulate_booleans = true
63
67
 
64
68
  # Boolean emulation can be disabled using :
65
69
  #
66
- # ArJdbc::FireBird.emulate_booleans = false
70
+ # ArJdbc::Firebird.emulate_booleans = false
67
71
  #
68
- # def self.emulate_booleans; @@emulate_booleans; end
69
- # def self.emulate_booleans=(emulate); @@emulate_booleans = emulate; end
72
+ def self.emulate_booleans?; @@emulate_booleans; end
73
+ # @deprecated Use {#emulate_booleans?} instead.
74
+ def self.emulate_booleans; @@emulate_booleans; end
75
+ # @see #emulate_booleans?
76
+ def self.emulate_booleans=(emulate); @@emulate_booleans = emulate; end
70
77
 
71
78
  ADAPTER_NAME = 'Firebird'.freeze
72
79
 
@@ -80,25 +87,19 @@ module ArJdbc
80
87
  :text => { :name => "blob sub_type text" },
81
88
  :integer => { :name => "integer" },
82
89
  :float => { :name => "float" },
83
- :decimal => { :name => "decimal" },
84
90
  :datetime => { :name => "timestamp" },
85
91
  :timestamp => { :name => "timestamp" },
86
92
  :time => { :name => "time" },
87
93
  :date => { :name => "date" },
88
94
  :binary => { :name => "blob" },
89
- :boolean => { :name => 'smallint' }
95
+ :boolean => { :name => 'char', :limit => 1 },
96
+ :numeric => { :name => "numeric" },
97
+ :decimal => { :name => "decimal" },
98
+ :char => { :name => "char" },
90
99
  }
91
100
 
92
101
  def native_database_types
93
- super.merge(NATIVE_DATABASE_TYPES)
94
- end
95
-
96
- def modify_types(types)
97
- super(types)
98
- NATIVE_DATABASE_TYPES.each do |key, value|
99
- types[key] = value.dup
100
- end
101
- types
102
+ NATIVE_DATABASE_TYPES
102
103
  end
103
104
 
104
105
  def type_to_sql(type, limit = nil, precision = nil, scale = nil)
@@ -216,6 +217,7 @@ module ArJdbc
216
217
  # @override
217
218
  def quote(value, column = nil)
218
219
  return value.quoted_id if value.respond_to?(:quoted_id)
220
+ return value if sql_literal?(value)
219
221
 
220
222
  type = column && column.type
221
223
  # BLOBs are updated separately by an after_save trigger.
@@ -231,7 +233,7 @@ module ArJdbc
231
233
  else
232
234
  "'#{quote_string(value)}'"
233
235
  end
234
- when NilClass then "NULL"
236
+ when NilClass then 'NULL'
235
237
  when TrueClass then (type == :integer ? '1' : quoted_true)
236
238
  when FalseClass then (type == :integer ? '0' : quoted_false)
237
239
  when Float, Fixnum, Bignum then value.to_s
@@ -240,7 +242,7 @@ module ArJdbc
240
242
  when Symbol then "'#{quote_string(value.to_s)}'"
241
243
  else
242
244
  if type == :time && value.acts_like?(:time)
243
- return "'#{value.strftime("%H:%M:%S")}'"
245
+ return "'#{get_time(value).strftime("%H:%M:%S")}'"
244
246
  end
245
247
  if type == :date && value.acts_like?(:date)
246
248
  return "'#{value.strftime("%Y-%m-%d")}'"
@@ -204,7 +204,7 @@ module ArJdbc
204
204
  # @override
205
205
  def explain(arel, binds = [])
206
206
  sql = "EXPLAIN #{to_sql(arel, binds)}"
207
- raw_result = execute(sql, "EXPLAIN", binds)
207
+ raw_result = exec_query_raw(sql, "EXPLAIN", binds)
208
208
  raw_result[0].values.join("\n") # [ "SELECT \n ..." ].to_s
209
209
  end
210
210
 
@@ -110,6 +110,7 @@ module ArJdbc
110
110
  # @override
111
111
  def quote(value, column = nil)
112
112
  return value.quoted_id if value.respond_to?(:quoted_id)
113
+ return value if sql_literal?(value)
113
114
 
114
115
  case value
115
116
  when String
@@ -2,14 +2,14 @@ module ArJdbc
2
2
  module HSQLDB
3
3
  module ExplainSupport
4
4
  def supports_explain?; true; end
5
-
5
+
6
6
  def explain(arel, binds = [])
7
7
  sql = "EXPLAIN PLAN FOR #{to_sql(arel, binds)}"
8
- raw_result = execute(sql, "EXPLAIN", binds)
8
+ raw_result = exec_query_raw(sql, "EXPLAIN", binds)
9
9
  # HSQLDB's SqlTool just prints it as it comes :
10
- #
10
+ #
11
11
  # sql> EXPLAIN PLAN FOR SELECT * FROM entries JOIN users on ... ;
12
- #
12
+ #
13
13
  # isDistinctSelect=[false]
14
14
  # isGrouped=[false]
15
15
  # isAggregated=[false]
@@ -27,8 +27,8 @@ module ArJdbc
27
27
  # PARAMETERS=[]
28
28
  # SUBQUERIES[]
29
29
  #
30
- rows = raw_result.map { |hash| hash.values }
31
- rows.join("\n")
30
+ raw_result.map!(&:values)
31
+ raw_result.join("\n")
32
32
  end
33
33
  end
34
34
  end
@@ -413,10 +413,13 @@ module ActiveRecord
413
413
  # @return [ActiveRecord::Result] or [Array] on **AR-2.3**
414
414
  # @override available since **AR-3.1**
415
415
  def exec_query(sql, name = 'SQL', binds = [])
416
+ if sql.respond_to?(:to_sql)
417
+ sql = to_sql(sql, binds); to_sql = true
418
+ end
416
419
  if prepared_statements?
417
420
  log(sql, name, binds) { @connection.execute_query(sql, binds) }
418
421
  else
419
- sql = suble_binds(sql, binds)
422
+ sql = suble_binds(sql, binds) unless to_sql # deprecated behavior
420
423
  log(sql, name) { @connection.execute_query(sql) }
421
424
  end
422
425
  end
@@ -427,10 +430,13 @@ module ActiveRecord
427
430
  # @param binds the bind parameters
428
431
  # @override available since **AR-3.1**
429
432
  def exec_insert(sql, name, binds, pk = nil, sequence_name = nil)
433
+ if sql.respond_to?(:to_sql)
434
+ sql = to_sql(sql, binds); to_sql = true
435
+ end
430
436
  if prepared_statements?
431
437
  log(sql, name || 'SQL', binds) { @connection.execute_insert(sql, binds) }
432
438
  else
433
- sql = suble_binds sql, binds
439
+ sql = suble_binds(sql, binds) unless to_sql # deprecated behavior
434
440
  log(sql, name || 'SQL') { @connection.execute_insert(sql) }
435
441
  end
436
442
  end
@@ -441,10 +447,13 @@ module ActiveRecord
441
447
  # @param binds the bind parameters
442
448
  # @override available since **AR-3.1**
443
449
  def exec_delete(sql, name, binds)
450
+ if sql.respond_to?(:to_sql)
451
+ sql = to_sql(sql, binds); to_sql = true
452
+ end
444
453
  if prepared_statements?
445
454
  log(sql, name || 'SQL', binds) { @connection.execute_delete(sql, binds) }
446
455
  else
447
- sql = suble_binds sql, binds
456
+ sql = suble_binds(sql, binds) unless to_sql # deprecated behavior
448
457
  log(sql, name || 'SQL') { @connection.execute_delete(sql) }
449
458
  end
450
459
  end
@@ -455,10 +464,13 @@ module ActiveRecord
455
464
  # @param binds the bind parameters
456
465
  # @override available since **AR-3.1**
457
466
  def exec_update(sql, name, binds)
467
+ if sql.respond_to?(:to_sql)
468
+ sql = to_sql(sql, binds); to_sql = true
469
+ end
458
470
  if prepared_statements?
459
471
  log(sql, name || 'SQL', binds) { @connection.execute_update(sql, binds) }
460
472
  else
461
- sql = suble_binds sql, binds
473
+ sql = suble_binds(sql, binds) unless to_sql # deprecated behavior
462
474
  log(sql, name || 'SQL') { @connection.execute_update(sql) }
463
475
  end
464
476
  end
@@ -474,10 +486,13 @@ module ActiveRecord
474
486
  # instead of returning mapped query results in an array.
475
487
  # @return [Array] unless a block is given
476
488
  def exec_query_raw(sql, name = 'SQL', binds = [], &block)
489
+ if sql.respond_to?(:to_sql)
490
+ sql = to_sql(sql, binds); to_sql = true
491
+ end
477
492
  if prepared_statements?
478
493
  log(sql, name, binds) { @connection.execute_query_raw(sql, binds, &block) }
479
494
  else
480
- sql = suble_binds(sql, binds)
495
+ sql = suble_binds(sql, binds) unless to_sql # deprecated behavior
481
496
  log(sql, name) { @connection.execute_query_raw(sql, &block) }
482
497
  end
483
498
  end
@@ -512,6 +527,7 @@ module ActiveRecord
512
527
  # statements that return a result set, while {#exec_query} is expected to
513
528
  # return a `ActiveRecord::Result` (since AR 3.1).
514
529
  # @note This method does not use prepared statements.
530
+ # @note The method does not emulate various "native" `execute` results on MRI.
515
531
  # @see #exec_query
516
532
  # @see #exec_insert
517
533
  # @see #exec_update
@@ -578,11 +594,14 @@ module ActiveRecord
578
594
  @connection.primary_keys(table)
579
595
  end
580
596
 
581
- # @deprecated use {#update_lob_value} instead
597
+ # @deprecated Rather use {#update_lob_value} instead.
582
598
  def write_large_object(*args)
583
599
  @connection.write_large_object(*args)
584
600
  end
585
601
 
602
+ # @param record the record e.g. `User.find(1)`
603
+ # @param column the model's column e.g. `User.columns_hash['photo']`
604
+ # @param value the lob value - string or (IO or Java) stream
586
605
  def update_lob_value(record, column, value)
587
606
  @connection.update_lob_value(record, column, value)
588
607
  end
@@ -604,22 +623,6 @@ module ActiveRecord
604
623
  sql
605
624
  end
606
625
 
607
- else # AR >= 3.1 or 4.0
608
-
609
- # @private
610
- def to_sql(arel, binds = [])
611
- # NOTE: same on 3.1/3.2 but on 4.0 binds are dup-ed
612
- # for us it is intentional to 'consume' (empty) the binds array
613
- # due our {#suble_binds} hack (that will be getting deprecated)
614
- if arel.respond_to?(:ast)
615
- visitor.accept(arel.ast) do
616
- quote(*binds.shift.reverse)
617
- end
618
- else
619
- arel
620
- end
621
- end
622
-
623
626
  end
624
627
 
625
628
  protected
@@ -713,29 +716,62 @@ module ActiveRecord
713
716
  # @prepared_statements = statements
714
717
  #end
715
718
 
716
- private
717
-
718
719
  def self.prepared_statements?(config)
719
720
  config.key?(:prepared_statements) ?
720
721
  type_cast_config_to_boolean(config.fetch(:prepared_statements)) :
721
- false # off by default
722
+ false # off by default - NOTE: on AR 4.x it's on by default !?
722
723
  end
723
724
 
724
- def suble_binds(sql, binds)
725
- return sql if binds.nil? || binds.empty?
726
- copy = binds.dup
727
- # TODO deprecate/warn about this behavior !
728
- sql.gsub('?') { quote(*copy.shift.reverse) }
725
+ if @@suble_binds = Java::JavaLang::System.getProperty('arjdbc.adapter.suble_binds')
726
+ @@suble_binds = Java::JavaLang::Boolean.parseBoolean(@@suble_binds)
727
+ else
728
+ @@suble_binds = ActiveRecord::VERSION::MAJOR < 4 # due compatibility
729
729
  end
730
+ def self.suble_binds?; @@suble_binds; end
731
+ def self.suble_binds=(flag); @@suble_binds = flag; end
730
732
 
731
- # @deprecated Replaced with {#suble_binds}.
733
+ private
734
+
735
+ # @note Since AR 4.0 we (finally) do not "sub" SQL's '?' parameters !
736
+ # @deprecated This should go away (hopefully), now here due 1.2.x.
737
+ def suble_binds(sql, binds)
738
+ return sql if ! @@suble_binds || binds.nil? || binds.empty?
739
+ binds = binds.dup; warn = nil
740
+ result = sql.gsub('?') { warn = true; quote(*binds.shift.reverse) }
741
+ ActiveSupport::Deprecation.warn(
742
+ "string binds substitution is deprecated - please refactor your sql", caller[1..-1]
743
+ ) if warn
744
+ result
745
+ end
746
+
747
+ # @private Supporting "string-subling" on AR 4.0 would require {#to_sql}
748
+ # to consume binds parameters otherwise it happens twice e.g. for a record
749
+ # insert it is called during {#insert} as well as on {#exec_insert} ...
750
+ # but that than leads to other issues with libraries that save the binds
751
+ # array and run a query again since it's the very same instance on 4.0 !
752
+ def suble_binds(sql, binds)
753
+ sql
754
+ end if ActiveRecord::VERSION::MAJOR > 3
755
+
756
+ # @deprecated No longer used, will be removed.
757
+ # @see #suble_binds
732
758
  def substitute_binds(sql, binds)
733
- suble_binds(extract_sql(sql), binds)
759
+ return sql if binds.nil? || binds.empty?; binds = binds.dup
760
+ extract_sql(sql).gsub('?') { quote(*binds.shift.reverse) }
734
761
  end
735
762
 
736
- # @deprecated No longer used, only kept for 1.2 API compatibility.
737
- def extract_sql(obj)
738
- obj.respond_to?(:to_sql) ? obj.send(:to_sql) : obj
763
+ # @deprecated No longer used, kept for 1.2 API compatibility.
764
+ def extract_sql(arel)
765
+ arel.respond_to?(:to_sql) ? arel.send(:to_sql) : arel
766
+ end
767
+
768
+ if ActiveRecord::VERSION::MAJOR > 2
769
+ # Helper useful during {#quote} since AREL might pass in it's literals
770
+ # to be quoted, fixed since AREL 4.0.0.beta1 : http://git.io/7gyTig
771
+ def sql_literal?(value); ::Arel::Nodes::SqlLiteral === value; end
772
+ else
773
+ # @private
774
+ def sql_literal?(value); false; end
739
775
  end
740
776
 
741
777
  # Helper to get local/UTC time (based on `ActiveRecord::Base.default_timezone`).
@@ -769,11 +805,11 @@ module ActiveRecord
769
805
  config =~ /\A\d+\z/ ? config.to_i : config
770
806
  end
771
807
 
772
- # @private
773
- def self.type_cast_config_to_boolean(config)
774
- config == "false" ? false : config
775
- end
808
+ end
776
809
 
810
+ # @private
811
+ def self.type_cast_config_to_boolean(config)
812
+ config == 'false' ? false : (config == 'true' ? true : config)
777
813
  end
778
814
 
779
815
  public
@@ -796,6 +832,11 @@ module ActiveRecord
796
832
  jdbc_column_class.string_to_time(value)
797
833
  end
798
834
 
835
+ if ActiveRecord::VERSION::MAJOR < 4 # emulating Rails 3.x compatibility
836
+ JdbcConnection.raw_date_time = true if JdbcConnection.raw_date_time? == nil
837
+ JdbcConnection.raw_boolean = true if JdbcConnection.raw_boolean? == nil
838
+ end
839
+
799
840
  end
800
841
  end
801
842
  end