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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/activerecord-jdbc-adapter.gemspec +1 -3
- data/lib/arel/visitors/compat.rb +5 -33
- data/lib/arel/visitors/h2.rb +1 -13
- data/lib/arel/visitors/hsqldb.rb +1 -21
- data/lib/arel/visitors/sql_server.rb +2 -103
- data/lib/arjdbc/abstract/core.rb +8 -9
- data/lib/arjdbc/abstract/database_statements.rb +8 -0
- data/lib/arjdbc/discover.rb +0 -67
- data/lib/arjdbc/jdbc/adapter.rb +1 -1
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/column.rb +1 -26
- data/lib/arjdbc/jdbc.rb +0 -7
- data/lib/arjdbc/mysql/adapter.rb +2 -1
- data/lib/arjdbc/mysql/connection_methods.rb +43 -42
- data/lib/arjdbc/oracle/adapter.rb +4 -23
- data/lib/arjdbc/postgresql/adapter.rb +152 -3
- data/lib/arjdbc/postgresql/oid_types.rb +155 -108
- data/lib/arjdbc/sqlite3/adapter.rb +54 -36
- data/lib/arjdbc/tasks/database_tasks.rb +0 -15
- data/lib/arjdbc/util/serialized_attributes.rb +0 -22
- data/lib/arjdbc/util/table_copier.rb +2 -1
- data/lib/arjdbc/version.rb +1 -1
- data/rakelib/02-test.rake +3 -18
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +1 -1
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +5 -0
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +6 -1
- metadata +6 -39
- data/lib/active_record/connection_adapters/as400_adapter.rb +0 -2
- data/lib/active_record/connection_adapters/db2_adapter.rb +0 -1
- data/lib/active_record/connection_adapters/derby_adapter.rb +0 -1
- data/lib/active_record/connection_adapters/informix_adapter.rb +0 -1
- data/lib/arel/visitors/db2.rb +0 -137
- data/lib/arel/visitors/derby.rb +0 -112
- data/lib/arel/visitors/firebird.rb +0 -79
- data/lib/arjdbc/db2/adapter.rb +0 -808
- data/lib/arjdbc/db2/as400.rb +0 -142
- data/lib/arjdbc/db2/column.rb +0 -131
- data/lib/arjdbc/db2/connection_methods.rb +0 -48
- data/lib/arjdbc/db2.rb +0 -4
- data/lib/arjdbc/derby/active_record_patch.rb +0 -13
- data/lib/arjdbc/derby/adapter.rb +0 -521
- data/lib/arjdbc/derby/connection_methods.rb +0 -20
- data/lib/arjdbc/derby/schema_creation.rb +0 -15
- data/lib/arjdbc/derby.rb +0 -3
- data/lib/arjdbc/firebird/adapter.rb +0 -413
- data/lib/arjdbc/firebird/connection_methods.rb +0 -23
- data/lib/arjdbc/firebird.rb +0 -4
- data/lib/arjdbc/informix/adapter.rb +0 -139
- data/lib/arjdbc/informix/connection_methods.rb +0 -9
- data/lib/arjdbc/sybase/adapter.rb +0 -47
- data/lib/arjdbc/sybase.rb +0 -2
- data/lib/arjdbc/tasks/db2_database_tasks.rb +0 -104
- data/lib/arjdbc/tasks/derby_database_tasks.rb +0 -95
- data/src/java/arjdbc/derby/DerbyModule.java +0 -178
- data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +0 -152
- data/src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java +0 -174
- data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +0 -75
@@ -262,9 +262,7 @@ module ArJdbc
|
|
262
262
|
def remove_column(table_name, column_name, type = nil, **options) #:nodoc:
|
263
263
|
alter_table(table_name) do |definition|
|
264
264
|
definition.remove_column column_name
|
265
|
-
definition.foreign_keys.delete_if
|
266
|
-
fk_options[:column] == column_name.to_s
|
267
|
-
end
|
265
|
+
definition.foreign_keys.delete_if { |fk| fk.column == column_name.to_s }
|
268
266
|
end
|
269
267
|
end
|
270
268
|
|
@@ -298,8 +296,8 @@ module ArJdbc
|
|
298
296
|
def change_column(table_name, column_name, type, **options) #:nodoc:
|
299
297
|
alter_table(table_name) do |definition|
|
300
298
|
definition[column_name].instance_eval do
|
301
|
-
self.type
|
302
|
-
|
299
|
+
self.type = aliased_types(type.to_s, type)
|
300
|
+
self.options.merge!(options)
|
303
301
|
end
|
304
302
|
end
|
305
303
|
end
|
@@ -336,8 +334,12 @@ module ArJdbc
|
|
336
334
|
sql << " ON CONFLICT #{insert.conflict_target} DO NOTHING"
|
337
335
|
elsif insert.update_duplicates?
|
338
336
|
sql << " ON CONFLICT #{insert.conflict_target} DO UPDATE SET "
|
339
|
-
|
340
|
-
|
337
|
+
if insert.raw_update_sql?
|
338
|
+
sql << insert.raw_update_sql
|
339
|
+
else
|
340
|
+
sql << insert.touch_model_timestamps_unless { |column| "#{column} IS excluded.#{column}" }
|
341
|
+
sql << insert.updatable_columns.map { |column| "#{column}=excluded.#{column}" }.join(",")
|
342
|
+
end
|
341
343
|
end
|
342
344
|
|
343
345
|
sql
|
@@ -348,7 +350,7 @@ module ArJdbc
|
|
348
350
|
end
|
349
351
|
|
350
352
|
def get_database_version # :nodoc:
|
351
|
-
SQLite3Adapter::Version.new(query_value("SELECT sqlite_version(*)"))
|
353
|
+
SQLite3Adapter::Version.new(query_value("SELECT sqlite_version(*)", "SCHEMA"))
|
352
354
|
end
|
353
355
|
|
354
356
|
def check_version
|
@@ -459,8 +461,13 @@ module ArJdbc
|
|
459
461
|
options[:rename][column.name.to_sym] ||
|
460
462
|
column.name) : column.name
|
461
463
|
|
464
|
+
if column.has_default?
|
465
|
+
type = lookup_cast_type_from_column(column)
|
466
|
+
default = type.deserialize(column.default)
|
467
|
+
end
|
468
|
+
|
462
469
|
@definition.column(column_name, column.type,
|
463
|
-
limit: column.limit, default:
|
470
|
+
limit: column.limit, default: default,
|
464
471
|
precision: column.precision, scale: column.scale,
|
465
472
|
null: column.null, collation: column.collation,
|
466
473
|
primary_key: column_name == from_primary_key
|
@@ -478,9 +485,6 @@ module ArJdbc
|
|
478
485
|
def copy_table_indexes(from, to, rename = {})
|
479
486
|
indexes(from).each do |index|
|
480
487
|
name = index.name
|
481
|
-
# indexes sqlite creates for internal use start with `sqlite_` and
|
482
|
-
# don't need to be copied
|
483
|
-
next if name.start_with?("sqlite_")
|
484
488
|
if to == "a#{from}"
|
485
489
|
name = "t#{name}"
|
486
490
|
elsif from == "a#{to}"
|
@@ -520,20 +524,22 @@ module ArJdbc
|
|
520
524
|
end
|
521
525
|
|
522
526
|
def translate_exception(exception, message:, sql:, binds:)
|
523
|
-
case exception.message
|
524
527
|
# SQLite 3.8.2 returns a newly formatted error message:
|
525
528
|
# UNIQUE constraint failed: *table_name*.*column_name*
|
526
529
|
# Older versions of SQLite return:
|
527
530
|
# column *column_name* is not unique
|
528
|
-
|
531
|
+
if exception.message.match?(/(column(s)? .* (is|are) not unique|UNIQUE constraint failed: .*)/i)
|
529
532
|
# DIFFERENCE: FQN
|
530
533
|
::ActiveRecord::RecordNotUnique.new(message, sql: sql, binds: binds)
|
531
|
-
|
534
|
+
elsif exception.message.match?(/(.* may not be NULL|NOT NULL constraint failed: .*)/i)
|
532
535
|
# DIFFERENCE: FQN
|
533
536
|
::ActiveRecord::NotNullViolation.new(message, sql: sql, binds: binds)
|
534
|
-
|
537
|
+
elsif exception.message.match?(/FOREIGN KEY constraint failed/i)
|
535
538
|
# DIFFERENCE: FQN
|
536
539
|
::ActiveRecord::InvalidForeignKey.new(message, sql: sql, binds: binds)
|
540
|
+
elsif exception.message.match?(/called on a closed database/i)
|
541
|
+
# DIFFERENCE: FQN
|
542
|
+
::ActiveRecord::ConnectionNotEstablished.new(exception)
|
537
543
|
else
|
538
544
|
super
|
539
545
|
end
|
@@ -553,12 +559,12 @@ module ArJdbc
|
|
553
559
|
# Result will have following sample string
|
554
560
|
# CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
555
561
|
# "password_digest" varchar COLLATE "NOCASE");
|
556
|
-
result =
|
562
|
+
result = query_value(sql, "SCHEMA")
|
557
563
|
|
558
564
|
if result
|
559
565
|
# Splitting with left parentheses and discarding the first part will return all
|
560
566
|
# columns separated with comma(,).
|
561
|
-
columns_string = result
|
567
|
+
columns_string = result.split("(", 2).last
|
562
568
|
|
563
569
|
columns_string.split(",").each do |column_string|
|
564
570
|
# This regex will match the column name and collation type and will save
|
@@ -596,6 +602,9 @@ module ArJdbc
|
|
596
602
|
end
|
597
603
|
|
598
604
|
def configure_connection
|
605
|
+
# FIXME: missing from adapter
|
606
|
+
# @connection.busy_timeout(self.class.type_cast_config_to_integer(@config[:timeout])) if @config[:timeout]
|
607
|
+
|
599
608
|
execute("PRAGMA foreign_keys = ON", "SCHEMA")
|
600
609
|
end
|
601
610
|
|
@@ -747,6 +756,29 @@ module ActiveRecord::ConnectionAdapters
|
|
747
756
|
# Note: This is not an override of ours but a moved line from AR Sqlite3Adapter to register ours vs our copied module (which would be their class).
|
748
757
|
# ActiveSupport.run_load_hooks(:active_record_sqlite3adapter, SQLite3Adapter)
|
749
758
|
|
759
|
+
# DIFFERENCE: FQN
|
760
|
+
class SQLite3Integer < ::ActiveRecord::Type::Integer # :nodoc:
|
761
|
+
private
|
762
|
+
def _limit
|
763
|
+
# INTEGER storage class can be stored 8 bytes value.
|
764
|
+
# See https://www.sqlite.org/datatype3.html#storage_classes_and_datatypes
|
765
|
+
limit || 8
|
766
|
+
end
|
767
|
+
end
|
768
|
+
|
769
|
+
# DIFFERENCE: FQN
|
770
|
+
::ActiveRecord::Type.register(:integer, SQLite3Integer, adapter: :sqlite3)
|
771
|
+
|
772
|
+
class << self
|
773
|
+
private
|
774
|
+
def initialize_type_map(m)
|
775
|
+
super
|
776
|
+
register_class_with_limit m, %r(int)i, SQLite3Integer
|
777
|
+
end
|
778
|
+
end
|
779
|
+
|
780
|
+
TYPE_MAP = ActiveRecord::Type::TypeMap.new.tap { |m| initialize_type_map(m) }
|
781
|
+
|
750
782
|
private
|
751
783
|
|
752
784
|
# because the JDBC driver doesn't like multiple SQL statements in one JDBC statement
|
@@ -754,6 +786,10 @@ module ActiveRecord::ConnectionAdapters
|
|
754
786
|
total_sql
|
755
787
|
end
|
756
788
|
|
789
|
+
def type_map
|
790
|
+
TYPE_MAP
|
791
|
+
end
|
792
|
+
|
757
793
|
# combine
|
758
794
|
def write_query?(sql) # :nodoc:
|
759
795
|
return sql.any? { |stmt| super(stmt) } if sql.kind_of? Array
|
@@ -761,23 +797,5 @@ module ActiveRecord::ConnectionAdapters
|
|
761
797
|
rescue ArgumentError # Invalid encoding
|
762
798
|
!READ_QUERY.match?(sql.b)
|
763
799
|
end
|
764
|
-
|
765
|
-
def initialize_type_map(m = type_map)
|
766
|
-
super
|
767
|
-
register_class_with_limit m, %r(int)i, SQLite3Integer
|
768
|
-
end
|
769
|
-
|
770
|
-
# DIFFERENCE: FQN
|
771
|
-
class SQLite3Integer < ::ActiveRecord::Type::Integer # :nodoc:
|
772
|
-
private
|
773
|
-
def _limit
|
774
|
-
# INTEGER storage class can be stored 8 bytes value.
|
775
|
-
# See https://www.sqlite.org/datatype3.html#storage_classes_and_datatypes
|
776
|
-
limit || 8
|
777
|
-
end
|
778
|
-
end
|
779
|
-
|
780
|
-
# DIFFERENCE: FQN
|
781
|
-
::ActiveRecord::Type.register(:integer, SQLite3Integer, adapter: :sqlite3)
|
782
800
|
end
|
783
801
|
end
|
@@ -10,21 +10,6 @@ module ArJdbc
|
|
10
10
|
|
11
11
|
require 'arjdbc/tasks/jdbc_database_tasks'
|
12
12
|
require 'arjdbc/tasks/sqlite_database_tasks_patch'
|
13
|
-
#require 'arjdbc/tasks/db2_database_tasks'
|
14
|
-
#require 'arjdbc/tasks/derby_database_tasks'
|
15
|
-
#require 'arjdbc/tasks/h2_database_tasks'
|
16
|
-
#require 'arjdbc/tasks/hsqldb_database_tasks'
|
17
|
-
#require 'arjdbc/tasks/mssql_database_tasks'
|
18
|
-
|
19
|
-
# re-invent built-in (but deprecated on 4.0) tasks :
|
20
|
-
#register_tasks(/sqlserver/, MSSQLDatabaseTasks)
|
21
|
-
#register_tasks(/mssql/, MSSQLDatabaseTasks) # (built-in) alias
|
22
|
-
# tasks for custom (JDBC) adapters :
|
23
|
-
#register_tasks(/db2/, DB2DatabaseTasks)
|
24
|
-
#register_tasks(/derby/, DerbyDatabaseTasks)
|
25
|
-
#register_tasks(/h2/, H2DatabaseTasks)
|
26
|
-
#register_tasks(/hsqldb/, HSQLDBDatabaseTasks)
|
27
|
-
# (default) generic JDBC task :
|
28
13
|
register_tasks(/^jdbc$/, JdbcDatabaseTasks)
|
29
14
|
|
30
15
|
# NOTE: no need to register "built-in" adapters such as MySQL
|
@@ -31,33 +31,11 @@ module ArJdbc
|
|
31
31
|
SerializedAttributes.dump_column_value(self, column)
|
32
32
|
end
|
33
33
|
|
34
|
-
if defined? ActiveRecord::Type::Serialized # ArJdbc::AR42
|
35
|
-
|
36
34
|
def self.dump_column_value(record, column)
|
37
35
|
value = record[ column.name.to_s ]
|
38
36
|
column.cast_type.type_cast_for_database(value)
|
39
37
|
end
|
40
38
|
|
41
|
-
else
|
42
|
-
|
43
|
-
def self.dump_column_value(record, column)
|
44
|
-
value = record[ name = column.name.to_s ]
|
45
|
-
if record.class.respond_to?(:serialized_attributes)
|
46
|
-
if coder = record.class.serialized_attributes[name]
|
47
|
-
value = coder.respond_to?(:dump) ? coder.dump(value) : value.to_yaml
|
48
|
-
end
|
49
|
-
else
|
50
|
-
if record.respond_to?(:unserializable_attribute?)
|
51
|
-
value = value.to_yaml if record.unserializable_attribute?(name, column)
|
52
|
-
else
|
53
|
-
value = value.to_yaml if value.is_a?(Hash)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
value
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
39
|
def self.setup(lob_type = nil, after_save_alias = nil)
|
62
40
|
ActiveRecord::Base.send :include, self # include SerializedAttributes
|
63
41
|
ActiveRecord::Base.lob_type = lob_type unless lob_type.nil?
|
@@ -4,7 +4,8 @@ module ArJdbc
|
|
4
4
|
module Util
|
5
5
|
module TableCopier
|
6
6
|
|
7
|
-
# taken from SQLite adapter, code loosely based on
|
7
|
+
# taken from SQLite adapter, code loosely based on
|
8
|
+
# https://github.com/rails/rails/blob/d3e5118/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
|
8
9
|
|
9
10
|
# Performs changes for table by first copying (and preserving contents)
|
10
11
|
# into another (temporary) table, than alters and copies all data back.
|
data/lib/arjdbc/version.rb
CHANGED
data/rakelib/02-test.rake
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
test_tasks = [ 'test_mysql', 'test_sqlite3', 'test_postgresql_with_hint' ]
|
3
3
|
if defined?(JRUBY_VERSION)
|
4
|
-
test_tasks.push :
|
4
|
+
test_tasks.push :test_hsqldb, :test_h2
|
5
5
|
test_tasks.push :test_jndi, :test_jdbc
|
6
6
|
end
|
7
7
|
|
@@ -55,7 +55,6 @@ def test_task_for(adapter, options = {})
|
|
55
55
|
test_task
|
56
56
|
end
|
57
57
|
|
58
|
-
test_task_for :Derby, :desc => 'Run tests against (embedded) DerbyDB'
|
59
58
|
test_task_for :H2, :desc => 'Run tests against H2 database engine'
|
60
59
|
test_task_for :HSQLDB, :desc => 'Run tests against HyperSQL (Java) database'
|
61
60
|
test_task_for :MySQL #, :prereqs => 'db:mysql'
|
@@ -64,29 +63,22 @@ test_task_for :PostgreSQL, :driver => ENV['JDBC_POSTGRES_VERSION'] || 'postgres'
|
|
64
63
|
task :test_postgres => :test_postgresql # alias
|
65
64
|
test_task_for :SQLite3, :driver => ENV['JDBC_SQLITE_VERSION']
|
66
65
|
task :test_sqlite => :test_sqlite3 # alias
|
67
|
-
test_task_for :Firebird
|
68
66
|
|
69
67
|
test_task_for :MariaDB, :files => FileList["test/db/mysql/*_test.rb"] do |test_task| #, :prereqs => 'db:mysql'
|
70
68
|
test_task.ruby_opts << '-rdb/mariadb_config'
|
71
69
|
end
|
72
70
|
|
73
71
|
# ensure driver for these DBs is on your class-path
|
74
|
-
[ :Oracle
|
72
|
+
[ :Oracle ].each do |adapter|
|
75
73
|
test_task_for adapter, :desc => "Run tests against #{adapter} (ensure driver is on class-path)"
|
76
74
|
end
|
77
75
|
|
78
|
-
test_task_for :AS400, :desc => "Run tests against AS400 (DB2) (ensure driver is on class-path)",
|
79
|
-
:files => FileList["test/db2*_test.rb"] + FileList["test/db/db2/*_test.rb"]
|
80
|
-
|
81
|
-
#task :test_jdbc => [ :test_jdbc_mysql, :test_jdbc_derby ] if defined?(JRUBY_VERSION)
|
82
|
-
|
83
76
|
test_task_for 'JDBC', :desc => 'Run tests against plain JDBC adapter (uses MySQL and Derby)',
|
84
77
|
:prereqs => [ 'db:mysql' ], :files => FileList['test/*jdbc_*test.rb'] do |test_task|
|
85
|
-
test_task.libs << 'jdbc-mysql/lib'
|
78
|
+
test_task.libs << 'jdbc-mysql/lib'
|
86
79
|
end
|
87
80
|
|
88
81
|
# TODO since Derby AR 5.x support is not implemented we only run JNDI with MySQL :
|
89
|
-
#task :test_jndi => [ :test_jndi_mysql, :test_jndi_derby ] if defined?(JRUBY_VERSION)
|
90
82
|
task :test_jndi => [ :test_jndi_mysql ] if defined?(JRUBY_VERSION)
|
91
83
|
|
92
84
|
jndi_classpath = [ 'test/jars/tomcat-juli.jar', 'test/jars/tomcat-catalina.jar' ]
|
@@ -100,13 +92,6 @@ get_jndi_classpath_opt = lambda do
|
|
100
92
|
"-J-cp \"#{cp.join(File::PATH_SEPARATOR)}\""
|
101
93
|
end
|
102
94
|
|
103
|
-
test_task_for 'JNDI_Derby', :desc => 'Run tests against a Derby JNDI connection',
|
104
|
-
:prereqs => jndi_classpath, :files => FileList['test/*jndi_derby*test.rb'] do |test_task|
|
105
|
-
test_task.libs << 'jdbc-derby/lib'
|
106
|
-
test_task.ruby_opts << get_jndi_classpath_opt.call
|
107
|
-
#test_task.verbose = true
|
108
|
-
end
|
109
|
-
|
110
95
|
test_task_for 'JNDI_MySQL', :desc => 'Run tests against a MySQL JNDI connection',
|
111
96
|
:prereqs => [ 'db:mysql' ] + jndi_classpath, :files => FileList['test/*jndi_mysql*test.rb'] do |test_task|
|
112
97
|
test_task.libs << 'jdbc-mysql/lib'
|
@@ -2727,7 +2727,7 @@ public class RubyJdbcConnection extends RubyObject {
|
|
2727
2727
|
}
|
2728
2728
|
else { // e.g. `BigDecimal '42.00000000000000000001'`
|
2729
2729
|
statement.setBigDecimal(index,
|
2730
|
-
RubyBigDecimal.newInstance(context, context.runtime.getModule("BigDecimal"), value).getValue());
|
2730
|
+
RubyBigDecimal.newInstance(context, context.runtime.getModule("BigDecimal"), value, RubyFixnum.newFixnum(context.runtime, Integer.MAX_VALUE)).getValue());
|
2731
2731
|
}
|
2732
2732
|
}
|
2733
2733
|
|
@@ -214,6 +214,11 @@ public class PostgreSQLRubyJdbcConnection extends arjdbc.jdbc.RubyJdbcConnection
|
|
214
214
|
});
|
215
215
|
}
|
216
216
|
|
217
|
+
@JRubyMethod
|
218
|
+
public IRubyObject exec_params(ThreadContext context, IRubyObject sql, IRubyObject binds) {
|
219
|
+
return execute_prepared_query(context, sql, binds, null);
|
220
|
+
}
|
221
|
+
|
217
222
|
private transient RubyClass oidArray; // PostgreSQL::OID::Array
|
218
223
|
|
219
224
|
private RubyClass oidArray(final ThreadContext context) {
|
@@ -402,6 +402,11 @@ public class SQLite3RubyJdbcConnection extends RubyJdbcConnection {
|
|
402
402
|
finally { close(statement); }
|
403
403
|
}
|
404
404
|
|
405
|
+
@JRubyMethod
|
406
|
+
public IRubyObject filename(ThreadContext context) {
|
407
|
+
return getConfigValue(context, "database");
|
408
|
+
}
|
409
|
+
|
405
410
|
@Override
|
406
411
|
@JRubyMethod(name = "rollback_savepoint", required = 1)
|
407
412
|
public IRubyObject rollback_savepoint(final ThreadContext context, final IRubyObject name) {
|
@@ -506,7 +511,7 @@ public class SQLite3RubyJdbcConnection extends RubyJdbcConnection {
|
|
506
511
|
statement.setDouble(index, ((RubyNumeric) value).getDoubleValue());
|
507
512
|
}
|
508
513
|
else { // e.g. `BigDecimal '42.00000000000000000001'`
|
509
|
-
RubyBigDecimal val = RubyBigDecimal.newInstance(context, context.runtime.getModule("BigDecimal"), value);
|
514
|
+
RubyBigDecimal val = RubyBigDecimal.newInstance(context, context.runtime.getModule("BigDecimal"), value, RubyFixnum.newFixnum(context.runtime, Integer.MAX_VALUE));
|
510
515
|
statement.setString(index, val.getValue().toString());
|
511
516
|
}
|
512
517
|
}
|
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: 70.
|
4
|
+
version: '70.2'
|
5
5
|
platform: java
|
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:
|
11
|
+
date: 2024-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -17,8 +17,8 @@ dependencies:
|
|
17
17
|
- !ruby/object:Gem::Version
|
18
18
|
version: '7.0'
|
19
19
|
name: activerecord
|
20
|
-
prerelease: false
|
21
20
|
type: :runtime
|
21
|
+
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
@@ -48,13 +48,9 @@ files:
|
|
48
48
|
- Rakefile
|
49
49
|
- Rakefile.jdbc
|
50
50
|
- activerecord-jdbc-adapter.gemspec
|
51
|
-
- lib/active_record/connection_adapters/as400_adapter.rb
|
52
|
-
- lib/active_record/connection_adapters/db2_adapter.rb
|
53
|
-
- lib/active_record/connection_adapters/derby_adapter.rb
|
54
51
|
- lib/active_record/connection_adapters/firebird_adapter.rb
|
55
52
|
- lib/active_record/connection_adapters/h2_adapter.rb
|
56
53
|
- lib/active_record/connection_adapters/hsqldb_adapter.rb
|
57
|
-
- lib/active_record/connection_adapters/informix_adapter.rb
|
58
54
|
- lib/active_record/connection_adapters/jdbc_adapter.rb
|
59
55
|
- lib/active_record/connection_adapters/jndi_adapter.rb
|
60
56
|
- lib/active_record/connection_adapters/mariadb_adapter.rb
|
@@ -64,9 +60,6 @@ files:
|
|
64
60
|
- lib/active_record/connection_adapters/sqlite3_adapter.rb
|
65
61
|
- lib/activerecord-jdbc-adapter.rb
|
66
62
|
- lib/arel/visitors/compat.rb
|
67
|
-
- lib/arel/visitors/db2.rb
|
68
|
-
- lib/arel/visitors/derby.rb
|
69
|
-
- lib/arel/visitors/firebird.rb
|
70
63
|
- lib/arel/visitors/h2.rb
|
71
64
|
- lib/arel/visitors/hsqldb.rb
|
72
65
|
- lib/arel/visitors/postgresql_jdbc.rb
|
@@ -78,20 +71,7 @@ files:
|
|
78
71
|
- lib/arjdbc/abstract/database_statements.rb
|
79
72
|
- lib/arjdbc/abstract/statement_cache.rb
|
80
73
|
- lib/arjdbc/abstract/transaction_support.rb
|
81
|
-
- lib/arjdbc/db2.rb
|
82
|
-
- lib/arjdbc/db2/adapter.rb
|
83
|
-
- lib/arjdbc/db2/as400.rb
|
84
|
-
- lib/arjdbc/db2/column.rb
|
85
|
-
- lib/arjdbc/db2/connection_methods.rb
|
86
|
-
- lib/arjdbc/derby.rb
|
87
|
-
- lib/arjdbc/derby/active_record_patch.rb
|
88
|
-
- lib/arjdbc/derby/adapter.rb
|
89
|
-
- lib/arjdbc/derby/connection_methods.rb
|
90
|
-
- lib/arjdbc/derby/schema_creation.rb
|
91
74
|
- lib/arjdbc/discover.rb
|
92
|
-
- lib/arjdbc/firebird.rb
|
93
|
-
- lib/arjdbc/firebird/adapter.rb
|
94
|
-
- lib/arjdbc/firebird/connection_methods.rb
|
95
75
|
- lib/arjdbc/h2.rb
|
96
76
|
- lib/arjdbc/h2/adapter.rb
|
97
77
|
- lib/arjdbc/h2/connection_methods.rb
|
@@ -101,8 +81,6 @@ files:
|
|
101
81
|
- lib/arjdbc/hsqldb/explain_support.rb
|
102
82
|
- lib/arjdbc/hsqldb/schema_creation.rb
|
103
83
|
- lib/arjdbc/informix.rb
|
104
|
-
- lib/arjdbc/informix/adapter.rb
|
105
|
-
- lib/arjdbc/informix/connection_methods.rb
|
106
84
|
- lib/arjdbc/jdbc.rb
|
107
85
|
- lib/arjdbc/jdbc/adapter.rb
|
108
86
|
- lib/arjdbc/jdbc/adapter_java.jar
|
@@ -138,13 +116,9 @@ files:
|
|
138
116
|
- lib/arjdbc/sqlite3.rb
|
139
117
|
- lib/arjdbc/sqlite3/adapter.rb
|
140
118
|
- lib/arjdbc/sqlite3/connection_methods.rb
|
141
|
-
- lib/arjdbc/sybase.rb
|
142
|
-
- lib/arjdbc/sybase/adapter.rb
|
143
119
|
- lib/arjdbc/tasks.rb
|
144
120
|
- lib/arjdbc/tasks/database_tasks.rb
|
145
121
|
- lib/arjdbc/tasks/databases.rake
|
146
|
-
- lib/arjdbc/tasks/db2_database_tasks.rb
|
147
|
-
- lib/arjdbc/tasks/derby_database_tasks.rb
|
148
122
|
- lib/arjdbc/tasks/h2_database_tasks.rb
|
149
123
|
- lib/arjdbc/tasks/hsqldb_database_tasks.rb
|
150
124
|
- lib/arjdbc/tasks/jdbc_database_tasks.rb
|
@@ -171,13 +145,9 @@ files:
|
|
171
145
|
- src/java/arjdbc/ArJdbcModule.java
|
172
146
|
- src/java/arjdbc/db2/DB2Module.java
|
173
147
|
- src/java/arjdbc/db2/DB2RubyJdbcConnection.java
|
174
|
-
- src/java/arjdbc/derby/DerbyModule.java
|
175
|
-
- src/java/arjdbc/derby/DerbyRubyJdbcConnection.java
|
176
|
-
- src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java
|
177
148
|
- src/java/arjdbc/h2/H2Module.java
|
178
149
|
- src/java/arjdbc/h2/H2RubyJdbcConnection.java
|
179
150
|
- src/java/arjdbc/hsqldb/HSQLDBModule.java
|
180
|
-
- src/java/arjdbc/informix/InformixRubyJdbcConnection.java
|
181
151
|
- src/java/arjdbc/jdbc/AdapterJavaService.java
|
182
152
|
- src/java/arjdbc/jdbc/Callable.java
|
183
153
|
- src/java/arjdbc/jdbc/ConnectionFactory.java
|
@@ -215,9 +185,6 @@ post_install_message:
|
|
215
185
|
rdoc_options:
|
216
186
|
- "--main"
|
217
187
|
- README.md
|
218
|
-
- "-SHN"
|
219
|
-
- "-f"
|
220
|
-
- darkfish
|
221
188
|
require_paths:
|
222
189
|
- lib
|
223
190
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -227,11 +194,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
227
194
|
version: '0'
|
228
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
229
196
|
requirements:
|
230
|
-
- - "
|
197
|
+
- - ">="
|
231
198
|
- !ruby/object:Gem::Version
|
232
|
-
version:
|
199
|
+
version: '0'
|
233
200
|
requirements: []
|
234
|
-
rubygems_version: 3.3.
|
201
|
+
rubygems_version: 3.3.26
|
235
202
|
signing_key:
|
236
203
|
specification_version: 4
|
237
204
|
summary: JDBC adapter for ActiveRecord, for use within JRuby on Rails.
|
@@ -1 +0,0 @@
|
|
1
|
-
require 'arjdbc/db2'
|
@@ -1 +0,0 @@
|
|
1
|
-
require 'arjdbc/derby'
|
@@ -1 +0,0 @@
|
|
1
|
-
require 'arjdbc/informix'
|
data/lib/arel/visitors/db2.rb
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
# NOTE: file contains code adapted from **ruby-ibmdb**'s adapter, license follows
|
2
|
-
=begin
|
3
|
-
Copyright (c) 2006 - 2015 IBM Corporation
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
-
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
-
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
10
|
-
=end
|
11
|
-
|
12
|
-
require 'arel/visitors/compat'
|
13
|
-
|
14
|
-
module Arel
|
15
|
-
module Visitors
|
16
|
-
class DB2 < Arel::Visitors::ToSql
|
17
|
-
|
18
|
-
if ArJdbc::AR42
|
19
|
-
def visit_Arel_Nodes_SelectStatement(o, a = nil)
|
20
|
-
a = o.cores.inject(a) { |c, x| visit_Arel_Nodes_SelectCore(x, c) }
|
21
|
-
|
22
|
-
unless o.orders.empty?
|
23
|
-
a << ' ORDER BY '
|
24
|
-
last = o.orders.length - 1
|
25
|
-
o.orders.each_with_index do |x, i|
|
26
|
-
visit(x, a); a << ', ' unless last == i
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
if limit = o.limit
|
31
|
-
if limit = limit.value
|
32
|
-
limit = limit.to_i
|
33
|
-
end
|
34
|
-
end
|
35
|
-
if offset = o.offset
|
36
|
-
if offset = offset.value
|
37
|
-
offset = offset.to_i
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
if limit || offset
|
42
|
-
add_limit_offset(a, o, limit, offset)
|
43
|
-
else
|
44
|
-
a
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def visit_Arel_Nodes_Limit o, collector
|
49
|
-
# visit o.expr, collector
|
50
|
-
end
|
51
|
-
|
52
|
-
def visit_Arel_Nodes_Offset o, collector
|
53
|
-
# visit o.expr, collector
|
54
|
-
end
|
55
|
-
|
56
|
-
else
|
57
|
-
def visit_Arel_Nodes_SelectStatement o, a = nil
|
58
|
-
sql = o.cores.map { |x| do_visit_select_core x, a }.join
|
59
|
-
sql << " ORDER BY #{o.orders.map { |x| do_visit x, a }.join(', ')}" unless o.orders.empty?
|
60
|
-
|
61
|
-
if limit = o.limit
|
62
|
-
if limit = limit.value
|
63
|
-
limit = limit.to_i
|
64
|
-
end
|
65
|
-
end
|
66
|
-
if offset = o.offset
|
67
|
-
if offset = offset.value
|
68
|
-
offset = offset.to_i
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
if limit || offset
|
73
|
-
add_limit_offset(sql, o, limit, offset)
|
74
|
-
else
|
75
|
-
sql
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
if ArJdbc::AR42
|
81
|
-
def visit_Arel_Nodes_InsertStatement o, a = nil
|
82
|
-
a << "INSERT INTO "
|
83
|
-
visit(o.relation, a)
|
84
|
-
|
85
|
-
values = o.values
|
86
|
-
|
87
|
-
if o.columns.any?
|
88
|
-
cols = o.columns.map { |x| quote_column_name x.name }
|
89
|
-
a << ' (' << cols.join(', ') << ') '
|
90
|
-
elsif o.values.eql? ArJdbc::DB2::VALUES_DEFAULT
|
91
|
-
cols = o.relation.engine.columns.map { |c| c.name }
|
92
|
-
a << ' (' << cols.join(', ') << ')'
|
93
|
-
a << ' VALUES '
|
94
|
-
a << ' (' << cols.map { 'DEFAULT' }.join(', ') << ')'
|
95
|
-
values = false
|
96
|
-
end
|
97
|
-
visit(values, a) if values
|
98
|
-
a
|
99
|
-
end
|
100
|
-
elsif Arel::VERSION >= '4.0' # AR 4.0 ... AREL 5.0 since AR >= 4.1
|
101
|
-
def visit_Arel_Nodes_InsertStatement o, a = nil
|
102
|
-
sql = "INSERT INTO "
|
103
|
-
sql << visit(o.relation, a)
|
104
|
-
|
105
|
-
values = o.values
|
106
|
-
|
107
|
-
if o.columns.any?
|
108
|
-
cols = o.columns.map { |x| quote_column_name x.name }
|
109
|
-
sql << ' (' << cols.join(', ') << ') '
|
110
|
-
# should depend the other way around but who cares it's AR
|
111
|
-
elsif o.values.eql? ArJdbc::DB2::VALUES_DEFAULT
|
112
|
-
cols = o.relation.engine.columns.map { |c| c.name }
|
113
|
-
sql << ' (' << cols.join(', ') << ')'
|
114
|
-
sql << ' VALUES '
|
115
|
-
sql << ' (' << cols.map { 'DEFAULT' }.join(', ') << ')'
|
116
|
-
values = nil
|
117
|
-
end
|
118
|
-
|
119
|
-
sql << visit(values, a) if values
|
120
|
-
|
121
|
-
sql
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
private
|
126
|
-
|
127
|
-
def add_limit_offset(sql, o, limit, offset)
|
128
|
-
@connection.replace_limit_offset! sql, limit, offset, o.orders
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
Arel::Collectors::Bind.class_eval do
|
136
|
-
attr_reader :parts
|
137
|
-
end if defined? Arel::Collectors::Bind
|