activerecord-jdbc-adapter 1.3.24 → 1.3.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03de925ceee26187bae69a5e29fe1b3a0b23214b
4
- data.tar.gz: b46c3b722e5399ce64b20cd949c07abed5170563
3
+ metadata.gz: 281e8f3a4a07822db0e22d4ccddcab3cfac306df
4
+ data.tar.gz: 6272c2231879854604d74b03720a6759f1e601ac
5
5
  SHA512:
6
- metadata.gz: a4ddbaa31377d0a6168a9a2968c549018c4cdcd9db2d5320f4a1cb9e291dbf6d7cc8b6909da14e0b41e8e7da72cb04d3a7131a8cb80450debc2af6eaf8ade15e
7
- data.tar.gz: faee7550a6863ec808c0024451af4632212509cbb7801f5434752790b7cf9bee037381cba269125c89dd0c80a6a860e2f72289f4b8658545db3c261a6f469310
6
+ metadata.gz: bb5752131090b67b4724e34ced5ce7ca04eab6b5f593e2b99d95d7b8914ec20b90a96d0e1820c09bcbea7ad145819cb3349155ef0986cf26d9943cfad080972f
7
+ data.tar.gz: 8a9cc04265ff89f82356d99c8418a7203269146462aae805f302aefb2b799f810421f526dc1989b96d543a365e5f964f1d9ac444890053374f6725c22f6fc905
@@ -1,3 +1,8 @@
1
+ addons:
2
+ apt:
3
+ packages:
4
+ - openjdk-6-jdk
5
+
1
6
  language: ruby
2
7
  sudo: false
3
8
  bundler_args: --without development
@@ -46,42 +51,44 @@ branches:
46
51
  - /^test-.*/
47
52
  matrix:
48
53
  allow_failures:
49
- - env: DB=mariadb
50
- - env: DB=mariadb PREPARED_STATEMENTS=true
54
+ # NOTE: failing HStore inserts for whatever reason - hopefully someone will investigate ...
55
+ - env: JRUBY_OPTS="--1.9 $JRUBY_OPTS" DB=postgresql PREPARED_STATEMENTS=true
56
+ - env: JRUBY_OPTS="--1.9 $JRUBY_OPTS" DB=postgresql PREPARED_STATEMENTS=true INSERT_RETURNING=true
57
+ - env: JRUBY_OPTS="$JRUBY_OPTS" DB=postgresql PREPARED_STATEMENTS=true
51
58
  include:
52
59
  # testing against MariaDB
53
60
  - addons:
54
- mariadb: '5.5'
61
+ mariadb: '10.0'
55
62
  rvm: jruby-1.7.24
56
63
  gemfile: gemfiles/rails32.gemfile
57
64
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql
58
- jdk: openjdk6
65
+ jdk: openjdk8 # MariaDB 2.x assumes JDK 8
59
66
  - addons:
60
67
  mariadb: '10.1'
61
68
  rvm: jruby-1.7.24
62
69
  gemfile: gemfiles/rails42.gemfile
63
70
  env: DB=mariadb
64
- jdk: openjdk7
71
+ jdk: openjdk8
65
72
  - addons:
66
- mariadb: '10.1'
73
+ mariadb: '10.2'
67
74
  rvm: jruby-1.7.24
68
75
  gemfile: gemfiles/rails41.gemfile
69
76
  env: DB=mariadb PREPARED_STATEMENTS=true
70
77
  jdk: oraclejdk8
71
78
  # include some tests on JDK 6 :
72
- - rvm: jruby-1.7.26
79
+ - rvm: jruby-1.7.27
73
80
  gemfile: gemfiles/rails42.gemfile
74
- env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql
81
+ env: JRUBY_OPTS="--2.0 $JRUBY_OPTS" DB=mysql
75
82
  jdk: openjdk6
76
- - rvm: jruby-1.7.26
83
+ - rvm: jruby-1.7.27
77
84
  gemfile: gemfiles/rails42.gemfile
78
- env: JRUBY_OPTS="$JRUBY_OPTS" DB=postgresql
85
+ env: JRUBY_OPTS="--2.0 $JRUBY_OPTS" DB=postgresql
79
86
  jdk: openjdk6
80
- - rvm: jruby-1.7.26
87
+ - rvm: jruby-1.7.27
81
88
  gemfile: gemfiles/rails42.gemfile
82
89
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=sqlite3
83
90
  jdk: openjdk6
84
- - rvm: jruby-1.7.26
91
+ - rvm: jruby-1.7.27
85
92
  gemfile: gemfiles/rails42.gemfile
86
93
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=derby
87
94
  jdk: openjdk6
@@ -93,40 +100,61 @@ matrix:
93
100
  gemfile: gemfiles/rails42.gemfile
94
101
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=hsqldb
95
102
  jdk: openjdk6
103
+ # include some (more) --2.0 testing :
104
+ - rvm: jruby-1.7.27
105
+ gemfile: gemfiles/rails41.gemfile
106
+ env: JRUBY_OPTS="--2.0 $JRUBY_OPTS" DB=mysql
107
+ jdk: openjdk8
108
+ - rvm: jruby-1.7.27
109
+ gemfile: gemfiles/rails41.gemfile
110
+ env: JRUBY_OPTS="--2.0 $JRUBY_OPTS" DB=postgresql
111
+ jdk: openjdk7
112
+ - rvm: jruby-1.7.27
113
+ gemfile: gemfiles/rails41.gemfile
114
+ env: JRUBY_OPTS="--2.0 $JRUBY_OPTS" DB=sqlite3
115
+ jdk: openjdk7
96
116
  # include testing with JRuby 9K (4.2) :
97
- - rvm: jruby-9.1.8.0
117
+ - rvm: jruby-9.1.12.0
98
118
  gemfile: gemfiles/rails42.gemfile
99
119
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql PREPARED_STATEMENTS=true
100
- jdk: oraclejdk7
101
- - rvm: jruby-9.1.6.0
120
+ jdk: openjdk7
121
+ - rvm: jruby-9.1.13.0
122
+ gemfile: gemfiles/rails42.gemfile
123
+ env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql DRIVER=MariaDB PREPARED_STATEMENTS=true
124
+ jdk: openjdk8
125
+ - rvm: jruby-9.1.12.0
102
126
  gemfile: gemfiles/rails42.gemfile
103
127
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=postgresql PREPARED_STATEMENTS=true
104
- jdk: oraclejdk7
105
- - rvm: jruby-9.1.8.0
128
+ jdk: openjdk7
129
+ - rvm: jruby-9.1.13.0
106
130
  gemfile: gemfiles/rails42.gemfile
107
131
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=sqlite3
108
- jdk: oraclejdk7
109
- - rvm: jruby-9.1.6.0
132
+ jdk: openjdk7
133
+ - rvm: jruby-9.1.13.0
110
134
  gemfile: gemfiles/rails42.gemfile
111
135
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql
112
136
  jdk: oraclejdk8
113
- - rvm: jruby-9.1.8.0
137
+ - rvm: jruby-9.1.12.0
138
+ gemfile: gemfiles/rails42.gemfile
139
+ env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql DRIVER=MariaDB
140
+ jdk: oraclejdk8
141
+ - rvm: jruby-9.1.13.0
114
142
  gemfile: gemfiles/rails42.gemfile
115
143
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=postgresql
116
144
  jdk: oraclejdk8
117
- - rvm: jruby-9.1.6.0
145
+ - rvm: jruby-9.1.8.0
118
146
  gemfile: gemfiles/rails42.gemfile
119
147
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=sqlite3
120
148
  jdk: oraclejdk8
121
- - rvm: jruby-9.1.8.0
149
+ - rvm: jruby-9.1.13.0
122
150
  gemfile: gemfiles/rails42.gemfile
123
151
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=derby
124
152
  jdk: oraclejdk8
125
- - rvm: jruby-9.1.8.0
153
+ - rvm: jruby-9.1.13.0
126
154
  gemfile: gemfiles/rails42.gemfile
127
155
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=h2
128
156
  jdk: oraclejdk8
129
- - rvm: jruby-9.1.8.0
157
+ - rvm: jruby-9.1.13.0
130
158
  gemfile: gemfiles/rails42.gemfile
131
159
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=hsqldb
132
160
  jdk: oraclejdk8
@@ -143,27 +171,31 @@ matrix:
143
171
  gemfile: gemfiles/rails41.gemfile
144
172
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=sqlite3
145
173
  jdk: oraclejdk8
146
- - rvm: jruby-9.1.8.0
174
+ - rvm: jruby-9.1.12.0
147
175
  gemfile: gemfiles/rails41.gemfile
148
176
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql
149
- jdk: oraclejdk7
150
- - rvm: jruby-9.1.8.0
177
+ jdk: openjdk7
178
+ - rvm: jruby-9.1.13.0
179
+ gemfile: gemfiles/rails41.gemfile
180
+ env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql DRIVER=MariaDB
181
+ jdk: openjdk8 # MariaDB 2.x assumes JDK 8
182
+ - rvm: jruby-9.1.13.0
151
183
  gemfile: gemfiles/rails41.gemfile
152
184
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=postgresql
153
- jdk: oraclejdk7
154
- - rvm: jruby-9.1.8.0
185
+ jdk: openjdk7
186
+ - rvm: jruby-9.1.13.0
155
187
  gemfile: gemfiles/rails41.gemfile
156
188
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=sqlite3
157
189
  jdk: oraclejdk8
158
- - rvm: jruby-9.1.8.0
190
+ - rvm: jruby-9.1.13.0
159
191
  gemfile: gemfiles/rails41.gemfile
160
192
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=derby
161
- jdk: oraclejdk7
162
- - rvm: jruby-9.1.8.0
193
+ jdk: openjdk7
194
+ - rvm: jruby-9.1.13.0
163
195
  gemfile: gemfiles/rails41.gemfile
164
196
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=h2
165
- jdk: oraclejdk7
166
- - rvm: jruby-9.1.8.0
197
+ jdk: openjdk7
198
+ - rvm: jruby-9.1.13.0
167
199
  gemfile: gemfiles/rails41.gemfile
168
200
  env: JRUBY_OPTS="$JRUBY_OPTS" DB=hsqldb
169
201
  jdk: oraclejdk8
data/History.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 1.3.25 (08/22/18)
2
+
3
+ - [mysql] get rid of official driver < 5 checking on conn initialization
4
+ - [oracle] fix Oracle adapter not suing schema config properly (#869)
5
+ - [db2] refactor db2 quote (to avoid SQL injection) (#861)
6
+ - [db2] Fix a TypeError that happens when offset is used without limit (#873)
7
+ - [mssql] automatically remove identity columns from AR generated UPDATE (#872)
8
+ - [db2] Errors when dealing with blobs in jruby 9.2k (#902)
9
+
1
10
  ## 1.3.24 (09/24/17)
2
11
 
3
12
  - [as400] Fixed ordering when limit and offset present (#789)
@@ -356,62 +356,49 @@ module ArJdbc
356
356
  # @param column (optional) contains info on the field
357
357
  # @override
358
358
  def quote(value, column = nil)
359
- return value.quoted_id if value.respond_to?(:quoted_id)
360
359
  return value if sql_literal?(value)
361
360
 
362
- if column
363
- if column.respond_to?(:primary) && column.primary && column.klass != String
364
- return value.to_i.to_s
365
- end
366
-
367
- if column.respond_to?(:cast_type) && column.cast_type.is_a?(ActiveRecord::Type::Serialized)
368
- return quote(column.cast_type.type_cast_for_database(value))
369
- end if ::ActiveRecord::VERSION::MAJOR >= 4
370
-
371
- if value && (column.type.to_sym == :decimal || column.type.to_sym == :integer)
372
- return value.to_s
373
- end
361
+ # Can anyone explain what this is for?
362
+ if column && column.respond_to?(:primary) && column.primary && column.klass != String
363
+ return value.to_i.to_s
374
364
  end
375
365
 
376
366
  column_type = column && column.type.to_sym
377
367
 
378
368
  case value
379
- when nil then 'NULL'
380
- when Numeric # IBM_DB doesn't accept quotes on numeric types
381
- # if the column type is text or string, return the quote value
382
- if column_type == :text || column_type == :string
383
- "'#{value}'"
384
- else
385
- value.to_s
386
- end
387
- when String, ActiveSupport::Multibyte::Chars
388
- if column_type == :binary && column.sql_type !~ /for bit data/i
389
- if update_lob_value?(value, column)
390
- value.nil? ? 'NULL' : BLOB_VALUE_MARKER # '@@@IBMBINARY@@@'"
369
+ when Numeric # IBM_DB doesn't accept quotes on numeric types
370
+ # if the column type is text or string, return the quote value
371
+ if column_type == :text || column_type == :string
372
+ "'#{value}'"
391
373
  else
392
- "BLOB('#{quote_string(value)}')"
374
+ super
393
375
  end
394
- elsif column && column.sql_type =~ /clob/ # :text
395
- if update_lob_value?(value, column)
396
- value.nil? ? 'NULL' : CLOB_VALUE_MARKER # "'@@@IBMTEXT@@@'"
376
+
377
+ when String, ActiveSupport::Multibyte::Chars
378
+ if column_type == :binary && column.sql_type !~ /for bit data/i
379
+ if update_lob_value?(value, column)
380
+ BLOB_VALUE_MARKER # '@@@IBMBINARY@@@'"
381
+ else
382
+ "BLOB('#{super}')"
383
+ end
384
+ elsif column && column.sql_type =~ /clob/ # :text
385
+ CLOB_VALUE_MARKER if update_lob_value?(value, column)# "'@@@IBMTEXT@@@'"
397
386
  else
398
- "'#{quote_string(value)}'"
387
+ super
399
388
  end
400
- elsif column_type == :xml
401
- value.nil? ? 'NULL' : "'#{quote_string(value)}'" # "'<ibm>@@@IBMXML@@@</ibm>'"
402
- else
403
- "'#{quote_string(value)}'"
404
- end
405
- when Symbol then "'#{quote_string(value.to_s)}'"
406
- when Time
407
- # AS400 doesn't support date in time column
408
- if column_type == :time
409
- quote_time(value)
389
+
390
+ when Time
391
+ # AS400 doesn't support date in time column
392
+ if column_type == :time
393
+ quote_time(value)
394
+ else
395
+ super
396
+ end
397
+
410
398
  else
411
399
  super
412
- end
413
- else super
414
400
  end
401
+
415
402
  end
416
403
 
417
404
  # @override
@@ -506,9 +493,9 @@ module ArJdbc
506
493
  param_sql << " LIMIT #{limit} OFFSET #{offset} "
507
494
  else
508
495
  param_sql << " OFFSET #{offset}" if offset.present?
509
- param_sql << if limit.present?
510
- limit == 1 ? ' FETCH FIRST ROW ONLY' : " FETCH FIRST #{limit} ROWS ONLY"
511
- end
496
+ if limit.present?
497
+ param_sql << (limit == 1 ? ' FETCH FIRST ROW ONLY' : " FETCH FIRST #{limit} ROWS ONLY")
498
+ end
512
499
  end
513
500
 
514
501
  if sql.is_a?(String)
@@ -35,6 +35,7 @@ module ArJdbc
35
35
  require 'arjdbc/mssql/column'
36
36
  require 'arjdbc/mssql/explain_support'
37
37
  require 'arjdbc/mssql/types' if AR42
38
+ require 'arjdbc/mssql/attributes_for_update'
38
39
 
39
40
  include LimitHelpers
40
41
  include Utils
@@ -0,0 +1,22 @@
1
+ module ActiveRecord
2
+ module ConnectionAdapters
3
+ module SQLServer
4
+ module CoreExt
5
+ module AttributeMethods
6
+
7
+
8
+ private
9
+
10
+ def attributes_for_update(attribute_names)
11
+ super.reject do |name|
12
+ column = self.class.columns_hash[name]
13
+ column && column.respond_to?(:identity?) && column.identity?
14
+ end
15
+ end
16
+
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ ActiveRecord::Base.send :include, ActiveRecord::ConnectionAdapters::SQLServer::CoreExt::AttributeMethods
@@ -28,12 +28,7 @@ module ArJdbc
28
28
  # @private
29
29
  def init_connection(jdbc_connection)
30
30
  meta = jdbc_connection.meta_data
31
- if meta.driver_major_version == 1 # TODO check in driver code
32
- # assumes MariaDB 1.x currently
33
- elsif meta.driver_major_version < 5
34
- raise ::ActiveRecord::ConnectionNotEstablished,
35
- "MySQL adapter requires driver >= 5.0 got: '#{meta.driver_version}'"
36
- elsif meta.driver_major_version == 5 && meta.driver_minor_version < 1
31
+ if meta.driver_major_version == 5 && meta.driver_minor_version < 1
37
32
  config[:connection_alive_sql] ||= 'SELECT 1' # need 5.1 for JDBC 4.0
38
33
  else
39
34
  # NOTE: since the loaded Java driver class can't change :
@@ -67,7 +67,7 @@ ArJdbc::ConnectionMethods.module_eval do
67
67
  else
68
68
  # According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection
69
69
  # must be established by default if explicit option isn't set :
70
- properties['useSSL'] ||= false
70
+ properties[mariadb_driver ? 'useSsl' : 'useSSL'] ||= false
71
71
  end
72
72
  if socket = config[:socket]
73
73
  properties['localSocket'] ||= socket if mariadb_driver
@@ -921,9 +921,13 @@ module ArJdbc
921
921
  # default schema owner
922
922
  def schema_owner(force = true)
923
923
  unless defined? @schema_owner
924
- username = config[:username] ? config[:username].to_s : nil
925
- username = jdbc_connection.meta_data.user_name if force && username.nil?
926
- @schema_owner = username.nil? ? nil : username.upcase
924
+ if !config[:schema].nil?
925
+ @schema_owner = config[:schema].upcase
926
+ else
927
+ username = config[:username] ? config[:username].to_s : nil
928
+ username = jdbc_connection.meta_data.user_name if force && username.nil?
929
+ @schema_owner = username.nil? ? nil : username.upcase
930
+ end
927
931
  end
928
932
  @schema_owner
929
933
  end
@@ -1,5 +1,5 @@
1
1
  module ArJdbc
2
- VERSION = "1.3.24"
2
+ VERSION = "1.3.25"
3
3
  # @deprecated
4
4
  module Version
5
5
  # @private 1.2.x compatibility
@@ -1473,8 +1473,8 @@ public class RubyJdbcConnection extends RubyObject {
1473
1473
  final IRubyObject record, final IRubyObject column, final IRubyObject value)
1474
1474
  throws SQLException {
1475
1475
 
1476
- final boolean binary = // column.type == :binary
1477
- column.callMethod(context, "type").toString() == (Object) "binary";
1476
+ // column.type == :binary
1477
+ final boolean binary = column.callMethod(context, "type").toString().equals("binary");
1478
1478
 
1479
1479
  final IRubyObject recordClass = record.callMethod(context, "class");
1480
1480
  final IRubyObject adapter = recordClass.callMethod(context, "connection");
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-jdbc-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.24
4
+ version: 1.3.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sieger, Ola Bini, Karol Bucek and JRuby contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-24 00:00:00.000000000 Z
11
+ date: 2018-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -134,6 +134,7 @@ files:
134
134
  - lib/arjdbc/mimer/adapter.rb
135
135
  - lib/arjdbc/mssql.rb
136
136
  - lib/arjdbc/mssql/adapter.rb
137
+ - lib/arjdbc/mssql/attributes_for_update.rb
137
138
  - lib/arjdbc/mssql/column.rb
138
139
  - lib/arjdbc/mssql/connection_methods.rb
139
140
  - lib/arjdbc/mssql/explain_support.rb