activerecord-jdbc-adapter 1.3.23 → 1.3.24

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: 87ea17eefa2d7db8e501c87fa8a349d93b3b2eeb
4
- data.tar.gz: af9e8507422e47c0eea8b525b1f797b9ab67bcb7
3
+ metadata.gz: 03de925ceee26187bae69a5e29fe1b3a0b23214b
4
+ data.tar.gz: b46c3b722e5399ce64b20cd949c07abed5170563
5
5
  SHA512:
6
- metadata.gz: e3d85c46104e42aa4a1439e4a91c929bec9c5af3094c35999c784cfbbba97e837dbabf8d3627a38a5956bf7d69bad950c8621f74241733252582a70650c561d9
7
- data.tar.gz: 48bbbd8d3cf5647e26378fcf6d7b86d64d877632d5abc0acac694aad1936dcca7656061722eea6b41e3a536c3afad31c96de2c2655aec9c9b75d1cbc899c808a
6
+ metadata.gz: a4ddbaa31377d0a6168a9a2968c549018c4cdcd9db2d5320f4a1cb9e291dbf6d7cc8b6909da14e0b41e8e7da72cb04d3a7131a8cb80450debc2af6eaf8ade15e
7
+ data.tar.gz: faee7550a6863ec808c0024451af4632212509cbb7801f5434752790b7cf9bee037381cba269125c89dd0c80a6a860e2f72289f4b8658545db3c261a6f469310
data/History.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## 1.3.24 (09/24/17)
2
+
3
+ - [as400] Fixed ordering when limit and offset present (#789)
4
+ - [postgres] limit driver version correctly since > 9.4.1206 might break
5
+ - [db2] fixed issue with serialization not happening (#795)
6
+ resolves #725 (serialize with custom class not working on AR 4.2)
7
+ - reconnect!/disconnect! shall call super to reset cache/transaction state
8
+ - [oracle] some ~ enhanced adapter compatibility with configuration
9
+ - [mysql] support setting collation: xxx with config[:encoding] like AR 4.2
10
+ - [as400] Check if the exception thrown is a false-positive (#792)
11
+ - [as400] Added truncate functionality for DB2/AS400 (#793)
12
+ - [as400] Added DatabaseTasks for the as400 (#791)
13
+
1
14
  ## 1.3.23 (05/14/17)
2
15
 
3
16
  - specify gem 'activerecord' < 5 since 5.x is not supported in 1.3.x
@@ -363,6 +363,11 @@ module ArJdbc
363
363
  if column.respond_to?(:primary) && column.primary && column.klass != String
364
364
  return value.to_i.to_s
365
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
+
366
371
  if value && (column.type.to_sym == :decimal || column.type.to_sym == :integer)
367
372
  return value.to_s
368
373
  end
@@ -492,29 +497,26 @@ module ArJdbc
492
497
 
493
498
  # @private shared with {Arel::Visitors::DB2}
494
499
  def replace_limit_offset!(sql, limit, offset, orders = nil)
495
- limit = limit.to_i
500
+ # Ordering is done somewhere before this method gets called
496
501
 
497
- if offset # && limit
498
- over_order_by = nil # NOTE: orders matching got reverted as it was not complete and there were no case covering it ...
502
+ # Create the limit and offset sql
503
+ param_sql = ''
499
504
 
500
- start_sql = "SELECT B.* FROM (SELECT A.*, row_number() OVER (#{over_order_by}) AS internal$rownum FROM (SELECT"
501
- end_sql = ") A ) B WHERE B.internal$rownum > #{offset} AND B.internal$rownum <= #{limit + offset.to_i}"
502
-
503
- if sql.is_a?(String)
504
- sql.sub!(/SELECT/i, start_sql)
505
- sql << end_sql
506
- else # AR 4.2 sql.class ... Arel::Collectors::Bind
507
- sql.parts[0] = start_sql # sql.sub! /SELECT/i
508
- sql.parts[ sql.parts.length ] = end_sql
509
- end
505
+ if offset.present? && limit.present?
506
+ param_sql << " LIMIT #{limit} OFFSET #{offset} "
510
507
  else
511
- limit_sql = limit == 1 ? " FETCH FIRST ROW ONLY" : " FETCH FIRST #{limit} ROWS ONLY"
512
- if sql.is_a?(String)
513
- sql << limit_sql
514
- else # AR 4.2 sql.class ... Arel::Collectors::Bind
515
- sql.parts[ sql.parts.length ] = limit_sql
516
- end
508
+ 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
512
+ end
513
+
514
+ if sql.is_a?(String)
515
+ sql << param_sql
516
+ else # AR 4.2 sql.class ... Arel::Collectors::Bind
517
+ sql.parts[sql.parts.length] = param_sql
517
518
  end
519
+
518
520
  sql
519
521
  end
520
522
 
@@ -60,8 +60,11 @@ module ArJdbc
60
60
  @connection.execute_update "call qsys.qcmdexc('QSYS/CHGJOB INQMSGRPY(*SYSRPYL)',0000000031.00000)"
61
61
  @connection.execute_update "call qsys.qcmdexc('ADDRPYLE SEQNBR(9876) MSGID(CPA32B2) RPY(''I'')',0000000045.00000)"
62
62
  rescue Exception => e
63
- raise "Could not call CHGJOB INQMSGRPY(*SYSRPYL) and ADDRPYLE SEQNBR(9876) MSGID(CPA32B2) RPY('I').\n" +
64
- "Do you have authority to do this?\n\n#{e.inspect}"
63
+ # Sometimes the exception can be a false-positive when we already ran the second command
64
+ unless e.message.include? 'Sequence number 9876 already defined in system reply list.'
65
+ raise "Could not call CHGJOB INQMSGRPY(*SYSRPYL) and ADDRPYLE SEQNBR(9876) MSGID(CPA32B2) RPY('I').\n" +
66
+ "Do you have authority to do this?\n\n#{e.inspect}"
67
+ end
65
68
  end
66
69
 
67
70
  begin
@@ -100,6 +103,11 @@ module ArJdbc
100
103
  true
101
104
  end
102
105
 
106
+ # AS400 does not support TRUNCATE command. Deleting everything from the table is should be close enough
107
+ def truncate(table_name, name = nil)
108
+ @connection.execute_update "DELETE FROM #{table_name}"
109
+ end
110
+
103
111
  private
104
112
 
105
113
  # @override
@@ -296,12 +296,15 @@ module ActiveRecord
296
296
 
297
297
  # @override
298
298
  def reconnect!
299
+ super # clear_cache! && reset_transaction
299
300
  @connection.reconnect! # handles adapter.configure_connection
300
301
  @connection
301
302
  end
302
303
 
303
304
  # @override
304
305
  def disconnect!
306
+ super # clear_cache! && reset_transaction
307
+ return unless @connection
305
308
  @connection.disconnect!
306
309
  end
307
310
 
@@ -57,11 +57,15 @@ module ArJdbc
57
57
  if strict_mode? && ! variables.has_key?(:sql_mode)
58
58
  variables[:sql_mode] = 'STRICT_ALL_TABLES' # SET SQL_MODE='STRICT_ALL_TABLES'
59
59
  end
60
-
60
+
61
61
  # NAMES does not have an equals sign, see
62
62
  # http://dev.mysql.com/doc/refman/5.0/en/set-statement.html#id944430
63
63
  # (trailing comma because variable_assignments will always have content)
64
- encoding = "NAMES #{config[:encoding]}, " if config[:encoding]
64
+ if @config[:encoding]
65
+ encoding = "NAMES #{@config[:encoding]}"
66
+ encoding << " COLLATE #{@config[:collation]}" if @config[:collation]
67
+ encoding << ", "
68
+ end
65
69
 
66
70
  # Gather up all of the SET variables...
67
71
  variable_assignments = variables.map do |k, v|
@@ -57,6 +57,25 @@ module ArJdbc
57
57
  # @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_column_class
58
58
  def jdbc_column_class; ::ActiveRecord::ConnectionAdapters::OracleColumn end
59
59
 
60
+ def configure_connection # mostly oracle-enhanced config compatibility
61
+ jdbc_connection = nil
62
+ if time_zone = config[:time_zone] # || ENV['TZ']
63
+ jdbc_connection ||= jdbc_connection(true)
64
+ jdbc_connection.setSessionTimeZone(time_zone)
65
+ end
66
+
67
+ cursor_sharing = config[:cursor_sharing] # || 'force'
68
+ execute "ALTER SESSION SET cursor_sharing = #{cursor_sharing}" if cursor_sharing
69
+
70
+ schema = config[:schema] && config[:schema].to_s
71
+ if schema.blank? # default schema owner
72
+ # @owner = username.upcase unless username.nil?
73
+ else
74
+ self.current_schema = schema
75
+ # @owner = schema
76
+ end
77
+ end
78
+
60
79
  # @private
61
80
  @@update_lob_values = true
62
81
 
@@ -943,10 +962,11 @@ module ActiveRecord::ConnectionAdapters
943
962
 
944
963
  def initialize(*args)
945
964
  ::ArJdbc::Oracle.initialize!
946
- super # configure_connection happens in super
947
965
 
948
966
  @use_insert_returning = config.key?(:insert_returning) ?
949
967
  self.class.type_cast_config_to_boolean(config[:insert_returning]) : nil
968
+
969
+ super # configure_connection happens in super
950
970
  end
951
971
 
952
972
  end
@@ -15,6 +15,10 @@ ArJdbc::ConnectionMethods.module_eval do
15
15
  unless config.key?(:statement_escape_processing)
16
16
  config[:statement_escape_processing] = true
17
17
  end
18
+ properties = ( config[:properties] ||= {} )
19
+ if prefetch_rows = config[:prefetch_rows] # || 100 (oracle-enhanced)
20
+ properties['defaultRowPrefetch'] = prefetch_rows
21
+ end
18
22
  jdbc_connection(config)
19
23
  end
20
24
  alias_method :jdbcoracle_connection, :oracle_connection
@@ -39,7 +39,7 @@ module ArJdbc
39
39
  register_tasks(/(oci|oracle)/, OracleDatabaseTasks)
40
40
  register_tasks(/mssql/, MSSQLDatabaseTasks) # (built-in) alias
41
41
  # tasks for custom (JDBC) adapters :
42
- register_tasks(/db2/, DB2DatabaseTasks)
42
+ register_tasks(/(db2|as400)/, DB2DatabaseTasks)
43
43
  register_tasks(/derby/, DerbyDatabaseTasks)
44
44
  register_tasks(/h2/, H2DatabaseTasks)
45
45
  register_tasks(/hsqldb/, HSQLDBDatabaseTasks)
@@ -1,5 +1,5 @@
1
1
  module ArJdbc
2
- VERSION = "1.3.23"
2
+ VERSION = "1.3.24"
3
3
  # @deprecated
4
4
  module Version
5
5
  # @private 1.2.x compatibility
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.23
4
+ version: 1.3.24
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-05-14 00:00:00.000000000 Z
11
+ date: 2017-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -255,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
255
255
  version: '0'
256
256
  requirements: []
257
257
  rubyforge_project: jruby-extras
258
- rubygems_version: 2.4.8
258
+ rubygems_version: 2.6.12
259
259
  signing_key:
260
260
  specification_version: 4
261
261
  summary: JDBC adapter for ActiveRecord, for use within JRuby on Rails.