activerecord-jdbc-adapter 1.3.0.rc1 → 1.3.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.
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
@@ -37,10 +37,8 @@ When fixing issues for a particular Rails version please be aware that we suppor
37
37
  multiple AR versions from a single code-base (and that means supporting Ruby 1.8
38
38
  as well - esp. targeting 4.x **we can not use the 1.9 syntax** yet).
39
39
 
40
-
41
- To speed-up fixes and response times on your issues or simply support AR-JDBC's
42
- development (esp. the refurbished **1.3.x** line) please consider [donating][0].
40
+ Please keep our [test-suite](https://travis-ci.org/jruby/activerecord-jdbc-adapter)
41
+ green (been funky for a while and it's been hard-work getting in back to shape),
42
+ while making changes, if they're related to an adapter covered by those.
43
43
 
44
44
  :heart: JRuby-Up!
45
-
46
- [0]: https://www.bountysource.com/#fundraisers/311-activerecord-jdbc-adapter-1-3-x
data/Gemfile CHANGED
@@ -33,8 +33,6 @@ group :rails do
33
33
  gem 'actionpack', :require => nil
34
34
  end
35
35
 
36
- group :test do
37
- gem 'mysql2', :require => nil, :platform => :mri
38
- gem 'pg', :require => nil, :platform => :mri
39
- gem 'sqlite3', :require => nil, :platform => :mri
40
- end
36
+ gem 'mysql2', :require => nil, :platform => :mri, :group => :test
37
+ gem 'pg', :require => nil, :platform => :mri, :group => :test
38
+ gem 'sqlite3', :require => nil, :platform => :mri, :group => :test
@@ -77,7 +77,7 @@ GEM
77
77
  multi_json (~> 1.0)
78
78
  rack (~> 1.0)
79
79
  tilt (~> 1.1, != 1.3.0)
80
- sqlite3 (1.3.7)
80
+ sqlite3 (1.3.8)
81
81
  test-unit (2.5.4)
82
82
  test-unit-context (0.3.1)
83
83
  test-unit (>= 2.4.0)
data/History.md CHANGED
@@ -1,3 +1,33 @@
1
+ ## 1.3.0 (08/29/13)
2
+
3
+ - [oracle] fix structure_dump: `column['data_default']` might come back as ''
4
+ - [oracle] avoid the JDBC call `connection.getMetaData` with exec_query (#453)
5
+ - review MSSQL/HSQLDB/H2 explain - make sure prepared statements are used
6
+ - [oracle] make sure explain works with prepared statements
7
+ - warn users about using our now deprecated suble_binds "extension"
8
+ - [mysql] username defaults to 'root' on MRI
9
+ - [mysql] match `columns` returned with latest AR 4.0 (collation, strict, extra)
10
+ - only `suble_binds` if not an arel passed + allow to turn bind subling off
11
+ - [postgres] fix `extension_enabled?` to work with raw boolean values
12
+ - [derby] setting true/false into text/string columns values should use `to_s`
13
+ also non-serializable attrs should use `to_s` (instead of `to_yaml`) on 3.x
14
+ - [derby] needs `quote_table_name_for_assignment` (on AR 4.0)
15
+ - [postgres] driver "hooks" to make PG types work with prepared statements, now
16
+ working: ranges, arrays, interval, (ip) addr types, tsvector, json and uuid
17
+ - missing `last_insert_id_result` method on PostgreSQL (#450)
18
+ - emulate pre AR 4.0 behavior with date-times/booleans (in custom SELECTs) they
19
+ will be returned as (raw) strings on AR 3.x
20
+ - warn when driver is not JDBC 4.0 compilant when checking if valid (#445)
21
+ - fix inline rescue syntax - invalid syntax at MSSQL's `string_to_time` (#444)
22
+ - no need to (double) update LOB values when using prepared statements
23
+ - replaced `emulate_booleans` with `emulate_booleans?` on adapter specs
24
+ - [firebird] emulate booleans with char(1) + fix time and review native types
25
+ - [db2] using new `update_lob_values` - now handles null inserts safely (#430)
26
+ - [mssql] configurable `update_lob_values?` - `string_to_binary` no longer abused
27
+ - refactored SerializedAttributesHelper and moved to Util::SerializedAttributes
28
+ there's now a new `update_lob_columns` helper hooked onto AR::Base for adapters
29
+ that send clob/blob values in a separate statement DB2, Oracle, MSSQL, Firebird
30
+
1
31
  ## 1.3.0.rc1 (08/03/13)
2
32
 
3
33
  - add activerecord gem as a dependency of the main AR-JDBC gem
@@ -62,9 +92,6 @@
62
92
  Code Contributors (in no particular order): Alexey Noskov, Pierrick Rouxel,
63
93
  Matías Battocchia, @gapthemind and Sören Mothes
64
94
 
65
- Code Contributors (in no particular order): @alno, @pierrickrouxel,
66
- @matiasbattocchia, @gapthemind, @soemo
67
-
68
95
  ## 1.3.0.beta2 (05/30/13)
69
96
 
70
97
  - only load rake tasks if AR is being used - AR::Railtie is loaded (#234)
data/README.md CHANGED
@@ -1,24 +1,27 @@
1
1
  # ActiveRecord JDBC Adapter
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/activerecord-jdbc-adapter.png)][7]
4
+
3
5
  ActiveRecord-JDBC-Adapter (AR-JDBC) is a database adapter for Rails'
4
6
  *ActiveRecord* component that can be used with [JRuby][0]. It allows use of
5
7
  virtually any JDBC-compliant database with your JRuby on Rails application.
6
8
 
7
- AR-JDBC **1.2.x** officially supports `ActiveRecord` **3.x** as well as **2.3**,
8
- it's latest version is compatible and requires JRuby **1.6.8+** (but as always we
9
- recommend to use the latest and greatest of JRubies) thus Java **1.6** is needed.
9
+ We supports *ActiveRecord* **2.3**, **3.x** and **4.x** from a single code base.
10
+ You'll need JRuby >= **1.6.8** (we recommend using the latest and greatest of
11
+ JRubies) thus Java >= **1.6** is mandatory.
10
12
 
11
- **NOTE:** version **1.3.x** of AR-JDBC adapter strives to provide `ActiveRecord`
12
- **4.x** compatibility (as well as still supporting **2.3** and **3.x**) from a
13
- single code base. It's a recommended update for all AR-JDBC 1.2.x users.
13
+ #### AR-JDBC **1.3.x** is a recommended update for all **1.2.x** users.
14
14
 
15
- [![Gem Version](https://badge.fury.io/rb/activerecord-jdbc-adapter.png)](http://badge.fury.io/rb/activerecord-jdbc-adapter)
15
+ Our latest major version **1.3.x** represents a few months of refactoring and
16
+ updates covering (not just) new *ActiveRecord* features. It tries to stay compatible
17
+ with 1.2.9 as much as possible but please be aware that it's not always possible
18
+ (mostly for the best), please read our [migration guide][8] for details.
16
19
 
17
20
  ## Databases
18
21
 
19
22
  ActiveRecord-JDBC-Adapter provides full or nearly full support for:
20
- **MySQL**, **PostgreSQL**, **SQLite3**, **Oracle**, **Microsoft SQL Server**,
21
- **DB2**, **FireBird**, **Derby**, **HSQLDB**, **H2**, and **Informix**.
23
+ **MySQL**, **PostgreSQL**, **SQLite3**, **Oracle**, *MS-SQL** (SQL Server),
24
+ **DB2**, **Firebird**, **Derby**, **HSQLDB**, **H2**, and **Informix**.
22
25
 
23
26
  Other databases will require testing and likely a custom configuration module.
24
27
  Please join the JRuby [mailing list][1] to help us discover support for more
@@ -262,3 +265,5 @@ license the database's drivers are licensed. See each driver gem's LICENSE.txt.
262
265
  [4]: http://github.com/nicksieger/activerecord-cachedb-adapter
263
266
  [5]: https://github.com/jruby/activerecord-jdbc-adapter/wiki
264
267
  [6]: https://webchat.freenode.net/?channels=#jruby
268
+ [7]: http://badge.fury.io/rb/activerecord-jdbc-adapter
269
+ [8]: https://github.com/jruby/activerecord-jdbc-adapter/wiki/Migrating-from-1.2.x-to-1.3.0
@@ -11,6 +11,9 @@ gem "test-unit-context", ">= 0.3.0", :group=>:test
11
11
  gem "mocha", "~> 0.13.1", :require=>nil, :group=>:test
12
12
  gem "simplecov", :require=>nil, :group=>:test
13
13
  gem "bcrypt-ruby", "~> 3.0.0", :require=>nil, :group=>:test
14
+ gem "mysql2", :require=>nil, :platform=>:mri, :group=>:test
15
+ gem "pg", :require=>nil, :platform=>:mri, :group=>:test
16
+ gem "sqlite3", :require=>nil, :platform=>:mri, :group=>:test
14
17
  gem "activerecord", "~> 2.3.18"
15
18
  gem "rails", "~> 2.3.18"
16
19
 
@@ -14,7 +14,9 @@ GEM
14
14
  appraisal (0.5.2)
15
15
  bundler
16
16
  rake
17
+ atomic (1.1.10)
17
18
  atomic (1.1.10-java)
19
+ bcrypt-ruby (3.0.1)
18
20
  bcrypt-ruby (3.0.1-java)
19
21
  bouncy-castle-java (1.5.0147)
20
22
  jruby-openssl (0.8.8)
@@ -39,11 +41,14 @@ GEM
39
41
  test-unit (2.5.4)
40
42
  test-unit-context (0.3.1)
41
43
  test-unit (>= 2.4.0)
44
+ thread_safe (0.1.2)
45
+ atomic
42
46
  thread_safe (0.1.2-java)
43
47
  atomic
44
48
 
45
49
  PLATFORMS
46
50
  java
51
+ ruby
47
52
 
48
53
  DEPENDENCIES
49
54
  activerecord (~> 2.3.18)
@@ -51,9 +56,12 @@ DEPENDENCIES
51
56
  bcrypt-ruby (~> 3.0.0)
52
57
  jruby-openssl
53
58
  mocha (~> 0.13.1)
59
+ mysql2
60
+ pg
54
61
  rails (~> 2.3.18)
55
62
  rake
56
63
  simplecov
64
+ sqlite3
57
65
  test-unit (= 2.5.4)
58
66
  test-unit-context (>= 0.3.0)
59
67
  thread_safe
@@ -11,5 +11,8 @@ gem "test-unit-context", ">= 0.3.0", :group=>:test
11
11
  gem "mocha", "~> 0.13.1", :require=>nil, :group=>:test
12
12
  gem "simplecov", :require=>nil, :group=>:test
13
13
  gem "bcrypt-ruby", "~> 3.0.0", :require=>nil, :group=>:test
14
+ gem "mysql2", :require=>nil, :platform=>:mri, :group=>:test
15
+ gem "pg", :require=>nil, :platform=>:mri, :group=>:test
16
+ gem "sqlite3", :require=>nil, :platform=>:mri, :group=>:test
14
17
  gem "activerecord", "~> 3.0.20"
15
18
 
@@ -15,7 +15,9 @@ GEM
15
15
  bundler
16
16
  rake
17
17
  arel (2.0.10)
18
+ atomic (1.1.10)
18
19
  atomic (1.1.10-java)
20
+ bcrypt-ruby (3.0.1)
19
21
  bcrypt-ruby (3.0.1-java)
20
22
  bouncy-castle-java (1.5.0147)
21
23
  builder (2.1.2)
@@ -26,20 +28,26 @@ GEM
26
28
  mocha (0.13.3)
27
29
  metaclass (~> 0.0.1)
28
30
  multi_json (1.7.7)
31
+ mysql2 (0.3.13)
32
+ pg (0.16.0)
29
33
  rake (10.1.0)
30
34
  simplecov (0.7.1)
31
35
  multi_json (~> 1.0)
32
36
  simplecov-html (~> 0.7.1)
33
37
  simplecov-html (0.7.1)
38
+ sqlite3 (1.3.8)
34
39
  test-unit (2.5.4)
35
40
  test-unit-context (0.3.1)
36
41
  test-unit (>= 2.4.0)
42
+ thread_safe (0.1.2)
43
+ atomic
37
44
  thread_safe (0.1.2-java)
38
45
  atomic
39
46
  tzinfo (0.3.37)
40
47
 
41
48
  PLATFORMS
42
49
  java
50
+ ruby
43
51
 
44
52
  DEPENDENCIES
45
53
  activerecord (~> 3.0.20)
@@ -47,8 +55,11 @@ DEPENDENCIES
47
55
  bcrypt-ruby (~> 3.0.0)
48
56
  jruby-openssl
49
57
  mocha (~> 0.13.1)
58
+ mysql2
59
+ pg
50
60
  rake
51
61
  simplecov
62
+ sqlite3
52
63
  test-unit (= 2.5.4)
53
64
  test-unit-context (>= 0.3.0)
54
65
  thread_safe
@@ -11,5 +11,8 @@ gem "test-unit-context", ">= 0.3.0", :group=>:test
11
11
  gem "mocha", "~> 0.13.1", :require=>nil, :group=>:test
12
12
  gem "simplecov", :require=>nil, :group=>:test
13
13
  gem "bcrypt-ruby", "~> 3.0.0", :require=>nil, :group=>:test
14
+ gem "mysql2", :require=>nil, :platform=>:mri, :group=>:test
15
+ gem "pg", :require=>nil, :platform=>:mri, :group=>:test
16
+ gem "sqlite3", :require=>nil, :platform=>:mri, :group=>:test
14
17
  gem "activerecord", "~> 3.1.12"
15
18
 
@@ -16,7 +16,9 @@ GEM
16
16
  bundler
17
17
  rake
18
18
  arel (2.2.3)
19
+ atomic (1.1.10)
19
20
  atomic (1.1.10-java)
21
+ bcrypt-ruby (3.0.1)
20
22
  bcrypt-ruby (3.0.1-java)
21
23
  bouncy-castle-java (1.5.0147)
22
24
  builder (3.0.4)
@@ -35,12 +37,15 @@ GEM
35
37
  test-unit (2.5.4)
36
38
  test-unit-context (0.3.1)
37
39
  test-unit (>= 2.4.0)
40
+ thread_safe (0.1.2)
41
+ atomic
38
42
  thread_safe (0.1.2-java)
39
43
  atomic
40
44
  tzinfo (0.3.37)
41
45
 
42
46
  PLATFORMS
43
47
  java
48
+ ruby
44
49
 
45
50
  DEPENDENCIES
46
51
  activerecord (~> 3.1.12)
@@ -48,8 +53,11 @@ DEPENDENCIES
48
53
  bcrypt-ruby (~> 3.0.0)
49
54
  jruby-openssl
50
55
  mocha (~> 0.13.1)
56
+ mysql2
57
+ pg
51
58
  rake
52
59
  simplecov
60
+ sqlite3
53
61
  test-unit (= 2.5.4)
54
62
  test-unit-context (>= 0.3.0)
55
63
  thread_safe
@@ -11,5 +11,8 @@ gem "test-unit-context", ">= 0.3.0", :group=>:test
11
11
  gem "mocha", "~> 0.13.1", :require=>nil, :group=>:test
12
12
  gem "simplecov", :require=>nil, :group=>:test
13
13
  gem "bcrypt-ruby", "~> 3.0.0", :require=>nil, :group=>:test
14
+ gem "mysql2", :require=>nil, :platform=>:mri, :group=>:test
15
+ gem "pg", :require=>nil, :platform=>:mri, :group=>:test
16
+ gem "sqlite3", :require=>nil, :platform=>:mri, :group=>:test
14
17
  gem "activerecord", "~> 3.2.13"
15
18
 
@@ -16,7 +16,9 @@ GEM
16
16
  bundler
17
17
  rake
18
18
  arel (3.0.2)
19
+ atomic (1.1.10)
19
20
  atomic (1.1.10-java)
21
+ bcrypt-ruby (3.0.1)
20
22
  bcrypt-ruby (3.0.1-java)
21
23
  bouncy-castle-java (1.5.0147)
22
24
  builder (3.0.4)
@@ -27,20 +29,26 @@ GEM
27
29
  mocha (0.13.3)
28
30
  metaclass (~> 0.0.1)
29
31
  multi_json (1.7.7)
32
+ mysql2 (0.3.13)
33
+ pg (0.16.0)
30
34
  rake (10.1.0)
31
35
  simplecov (0.7.1)
32
36
  multi_json (~> 1.0)
33
37
  simplecov-html (~> 0.7.1)
34
38
  simplecov-html (0.7.1)
39
+ sqlite3 (1.3.8)
35
40
  test-unit (2.5.4)
36
41
  test-unit-context (0.3.1)
37
42
  test-unit (>= 2.4.0)
43
+ thread_safe (0.1.2)
44
+ atomic
38
45
  thread_safe (0.1.2-java)
39
46
  atomic
40
47
  tzinfo (0.3.37)
41
48
 
42
49
  PLATFORMS
43
50
  java
51
+ ruby
44
52
 
45
53
  DEPENDENCIES
46
54
  activerecord (~> 3.2.13)
@@ -48,8 +56,11 @@ DEPENDENCIES
48
56
  bcrypt-ruby (~> 3.0.0)
49
57
  jruby-openssl
50
58
  mocha (~> 0.13.1)
59
+ mysql2
60
+ pg
51
61
  rake
52
62
  simplecov
63
+ sqlite3
53
64
  test-unit (= 2.5.4)
54
65
  test-unit-context (>= 0.3.0)
55
66
  thread_safe
@@ -11,5 +11,8 @@ gem "test-unit-context", ">= 0.3.0", :group=>:test
11
11
  gem "mocha", "~> 0.13.1", :require=>nil, :group=>:test
12
12
  gem "simplecov", :require=>nil, :group=>:test
13
13
  gem "bcrypt-ruby", "~> 3.0.0", :require=>nil, :group=>:test
14
+ gem "mysql2", :require=>nil, :platform=>:mri, :group=>:test
15
+ gem "pg", :require=>nil, :platform=>:mri, :group=>:test
16
+ gem "sqlite3", :require=>nil, :platform=>:mri, :group=>:test
14
17
  gem "activerecord", "~> 4.0.0"
15
18
 
@@ -20,7 +20,9 @@ GEM
20
20
  bundler
21
21
  rake
22
22
  arel (4.0.0)
23
+ atomic (1.1.10)
23
24
  atomic (1.1.10-java)
25
+ bcrypt-ruby (3.0.1)
24
26
  bcrypt-ruby (3.0.1-java)
25
27
  bouncy-castle-java (1.5.0147)
26
28
  builder (3.1.4)
@@ -46,6 +48,7 @@ GEM
46
48
 
47
49
  PLATFORMS
48
50
  java
51
+ ruby
49
52
 
50
53
  DEPENDENCIES
51
54
  activerecord (~> 4.0.0)
@@ -53,8 +56,11 @@ DEPENDENCIES
53
56
  bcrypt-ruby (~> 3.0.0)
54
57
  jruby-openssl
55
58
  mocha (~> 0.13.1)
59
+ mysql2
60
+ pg
56
61
  rake
57
62
  simplecov
63
+ sqlite3
58
64
  test-unit (= 2.5.4)
59
65
  test-unit-context (>= 0.3.0)
60
66
  thread_safe
@@ -16,19 +16,8 @@ module ArJdbc
16
16
  def self.initialize!
17
17
  return if @@_initialized; @@_initialized = true
18
18
 
19
- require 'arjdbc/jdbc/serialized_attributes_helper'
20
- ActiveRecord::Base.class_eval do
21
- def after_save_with_db2_lob
22
- lob_columns = self.class.columns.select { |c| c.sql_type =~ /blob|clob/i }
23
- lob_columns.each do |column|
24
- value = ::ArJdbc::SerializedAttributesHelper.dump_column_value(self, column)
25
- next if value.nil? # already set NULL
26
-
27
- self.class.connection.update_lob_value(self, column, value)
28
- end
29
- end
30
- end
31
- ActiveRecord::Base.after_save :after_save_with_db2_lob
19
+ require 'arjdbc/util/serialized_attributes'
20
+ Util::SerializedAttributes.setup /blob|clob/i, 'after_save_with_db2_lob'
32
21
  end
33
22
 
34
23
  # @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_connection_class
@@ -52,9 +41,6 @@ module ArJdbc
52
41
  { 'db2' => arel_visitor_type }
53
42
  end
54
43
 
55
- # @private
56
- def self.handle_lobs?; true; end
57
-
58
44
  # @private
59
45
  @@emulate_booleans = true
60
46
 
@@ -62,9 +48,38 @@ module ArJdbc
62
48
  #
63
49
  # ArJdbc::DB2.emulate_booleans = false
64
50
  #
51
+ def self.emulate_booleans?; @@emulate_booleans; end
52
+ # @deprecated Use {#emulate_booleans?} instead.
65
53
  def self.emulate_booleans; @@emulate_booleans; end
54
+ # @see #emulate_booleans?
66
55
  def self.emulate_booleans=(emulate); @@emulate_booleans = emulate; end
67
56
 
57
+ # @private
58
+ @@update_lob_values = true
59
+
60
+ # Updating records with LOB values (binary/text columns) in a separate
61
+ # statement can be disabled using :
62
+ #
63
+ # ArJdbc::DB2.update_lob_values = false
64
+ #
65
+ # @note This only applies when prepared statements are not used.
66
+ def self.update_lob_values?; @@update_lob_values; end
67
+ # @see #update_lob_values?
68
+ def self.update_lob_values=(update); @@update_lob_values = update; end
69
+
70
+ # @see #update_lob_values?
71
+ # @see ArJdbc::Util::SerializedAttributes#update_lob_columns
72
+ def update_lob_value?(value, column = nil)
73
+ DB2.update_lob_values? && ! prepared_statements? # && value
74
+ end
75
+
76
+ # @see #quote
77
+ # @private
78
+ BLOB_VALUE_MARKER = "BLOB('')"
79
+ # @see #quote
80
+ # @private
81
+ CLOB_VALUE_MARKER = "''"
82
+
68
83
  def configure_connection
69
84
  schema = self.schema
70
85
  set_schema(schema) if schema && schema != config[:username]
@@ -248,6 +263,7 @@ module ArJdbc
248
263
  # @override
249
264
  def quote(value, column = nil)
250
265
  return value.quoted_id if value.respond_to?(:quoted_id)
266
+ return value if sql_literal?(value)
251
267
 
252
268
  if column
253
269
  if column.respond_to?(:primary) && column.primary && column.klass != String
@@ -261,7 +277,7 @@ module ArJdbc
261
277
  column_type = column && column.type.to_sym
262
278
 
263
279
  case value
264
- when nil then "NULL"
280
+ when nil then 'NULL'
265
281
  when Numeric # IBM_DB doesn't accept quotes on numeric types
266
282
  # if the column type is text or string, return the quote value
267
283
  if column_type == :text || column_type == :string
@@ -270,20 +286,20 @@ module ArJdbc
270
286
  value.to_s
271
287
  end
272
288
  when String, ActiveSupport::Multibyte::Chars
273
- if column_type == :binary && !(column.sql_type =~ /for bit data/i)
274
- if ArJdbc::DB2.handle_lobs?
275
- "NULL" # '@@@IBMBINARY@@@'"
289
+ if column_type == :binary && column.sql_type !~ /for bit data/i
290
+ if update_lob_value?(value, column)
291
+ value.nil? ? 'NULL' : BLOB_VALUE_MARKER # '@@@IBMBINARY@@@'"
276
292
  else
277
293
  "BLOB('#{quote_string(value)}')"
278
294
  end
279
295
  elsif column && column.sql_type =~ /clob/ # :text
280
- if ArJdbc::DB2.handle_lobs?
281
- "NULL" # "'@@@IBMTEXT@@@'"
296
+ if update_lob_value?(value, column)
297
+ value.nil? ? 'NULL' : CLOB_VALUE_MARKER # "'@@@IBMTEXT@@@'"
282
298
  else
283
299
  "'#{quote_string(value)}'"
284
300
  end
285
301
  elsif column_type == :xml
286
- value.nil? ? "NULL" : "'#{quote_string(value)}'" # "'<ibm>@@@IBMXML@@@</ibm>'"
302
+ value.nil? ? 'NULL' : "'#{quote_string(value)}'" # "'<ibm>@@@IBMXML@@@</ibm>'"
287
303
  else
288
304
  "'#{quote_string(value)}'"
289
305
  end