activerecord-jdbc-alt-adapter 50.7.0-java → 51.3.0-java
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.
- checksums.yaml +4 -4
- data/.gitignore +0 -3
- data/.travis.yml +24 -28
- data/Gemfile +5 -2
- data/README.md +26 -20
- data/Rakefile +4 -30
- data/activerecord-jdbc-adapter.gemspec +2 -2
- data/activerecord-jdbc-alt-adapter.gemspec +4 -3
- data/lib/arel/visitors/sqlserver.rb +17 -3
- data/lib/arjdbc/abstract/core.rb +4 -2
- data/lib/arjdbc/abstract/database_statements.rb +2 -8
- data/lib/arjdbc/abstract/transaction_support.rb +2 -9
- data/lib/arjdbc/db2/adapter.rb +2 -52
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/column.rb +11 -5
- data/lib/arjdbc/jdbc/error.rb +1 -1
- data/lib/arjdbc/jdbc.rb +4 -0
- data/lib/arjdbc/mssql/adapter.rb +33 -39
- data/lib/arjdbc/mssql/connection_methods.rb +0 -5
- data/lib/arjdbc/mssql/database_statements.rb +1 -1
- data/lib/arjdbc/mssql/explain_support.rb +1 -1
- data/lib/arjdbc/mssql/{extensions.rb → extensions/attribute_methods.rb} +0 -0
- data/lib/arjdbc/mssql/extensions/calculations.rb +29 -0
- data/lib/arjdbc/mssql/schema_creation.rb +12 -0
- data/lib/arjdbc/mssql/schema_definitions.rb +17 -0
- data/lib/arjdbc/mssql/schema_dumper.rb +37 -0
- data/lib/arjdbc/mssql/schema_statements.rb +73 -44
- data/lib/arjdbc/mssql/types/date_and_time_types.rb +9 -9
- data/lib/arjdbc/mssql/utils.rb +1 -0
- data/lib/arjdbc/mssql.rb +1 -1
- data/lib/arjdbc/mysql/adapter.rb +12 -1
- data/lib/arjdbc/mysql/connection_methods.rb +7 -13
- data/lib/arjdbc/postgresql/adapter.rb +29 -12
- data/lib/arjdbc/postgresql/column.rb +3 -6
- data/lib/arjdbc/postgresql/connection_methods.rb +1 -3
- data/lib/arjdbc/postgresql/oid_types.rb +7 -12
- data/lib/arjdbc/sqlite3/adapter.rb +169 -139
- data/lib/arjdbc/sqlite3/connection_methods.rb +1 -2
- data/lib/arjdbc/version.rb +1 -1
- data/rakelib/01-tomcat.rake +2 -2
- data/rakelib/02-test.rake +2 -0
- data/rakelib/rails.rake +1 -1
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +17 -68
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +38 -282
- data/src/java/arjdbc/postgresql/ByteaUtils.java +1 -0
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +3 -3
- data/src/java/arjdbc/util/DateTimeUtils.java +5 -22
- metadata +20 -12
- data/lib/activerecord-jdbc-alt-adapter.rb +0 -1
@@ -7,6 +7,7 @@ require 'active_record/connection_adapters/postgresql/column'
|
|
7
7
|
require 'active_record/connection_adapters/postgresql/explain_pretty_printer'
|
8
8
|
require 'active_record/connection_adapters/postgresql/quoting'
|
9
9
|
require 'active_record/connection_adapters/postgresql/referential_integrity'
|
10
|
+
require 'active_record/connection_adapters/postgresql/schema_creation'
|
10
11
|
require 'active_record/connection_adapters/postgresql/schema_dumper'
|
11
12
|
require 'active_record/connection_adapters/postgresql/schema_statements'
|
12
13
|
require 'active_record/connection_adapters/postgresql/type_metadata'
|
@@ -146,8 +147,7 @@ module ArJdbc
|
|
146
147
|
ActiveRecordError = ::ActiveRecord::ActiveRecordError
|
147
148
|
|
148
149
|
NATIVE_DATABASE_TYPES = {
|
149
|
-
|
150
|
-
primary_key: 'serial primary key',
|
150
|
+
primary_key: 'bigserial primary key',
|
151
151
|
bigint: { name: 'bigint' },
|
152
152
|
binary: { name: 'bytea' },
|
153
153
|
bit: { name: 'bit' },
|
@@ -178,10 +178,10 @@ module ArJdbc
|
|
178
178
|
money: { name: 'money' },
|
179
179
|
numeric: { name: 'numeric' },
|
180
180
|
numrange: { name: 'numrange' },
|
181
|
+
oid: { name: 'oid' },
|
181
182
|
path: { name: 'path' },
|
182
183
|
point: { name: 'point' },
|
183
184
|
polygon: { name: 'polygon' },
|
184
|
-
serial: { name: 'serial' }, # auto-inc integer, bigserial, smallserial
|
185
185
|
string: { name: 'character varying' },
|
186
186
|
text: { name: 'text' },
|
187
187
|
time: { name: 'time' },
|
@@ -249,15 +249,11 @@ module ArJdbc
|
|
249
249
|
|
250
250
|
def supports_index_sort_order?; true end
|
251
251
|
|
252
|
-
def supports_migrations?; true end
|
253
|
-
|
254
252
|
def supports_partial_index?; true end
|
255
253
|
|
256
|
-
def supports_primary_key?; true end # Supports finding primary key on non-Active Record tables
|
257
|
-
|
258
254
|
def supports_savepoints?; true end
|
259
255
|
|
260
|
-
def supports_transaction_isolation
|
256
|
+
def supports_transaction_isolation?; true end
|
261
257
|
|
262
258
|
def supports_views?; true end
|
263
259
|
|
@@ -287,6 +283,10 @@ module ArJdbc
|
|
287
283
|
postgresql_version >= 80200
|
288
284
|
end
|
289
285
|
|
286
|
+
def supports_pgcrypto_uuid?
|
287
|
+
postgresql_version >= 90400
|
288
|
+
end
|
289
|
+
|
290
290
|
# Range data-types weren't introduced until PostgreSQL 9.2.
|
291
291
|
def supports_ranges?
|
292
292
|
postgresql_version >= 90200
|
@@ -296,6 +296,11 @@ module ArJdbc
|
|
296
296
|
postgresql_version >= 90200
|
297
297
|
end
|
298
298
|
|
299
|
+
# From AR 5.1 postgres_adapter.rb
|
300
|
+
def default_index_type?(index) # :nodoc:
|
301
|
+
index.using == :btree || super
|
302
|
+
end
|
303
|
+
|
299
304
|
def enable_extension(name)
|
300
305
|
execute("CREATE EXTENSION IF NOT EXISTS \"#{name}\"")
|
301
306
|
end
|
@@ -347,7 +352,7 @@ module ArJdbc
|
|
347
352
|
select_value("SELECT pg_advisory_unlock(#{lock_id})")
|
348
353
|
end
|
349
354
|
|
350
|
-
# Returns the
|
355
|
+
# Returns the max identifier length supported by PostgreSQL
|
351
356
|
def max_identifier_length
|
352
357
|
@max_identifier_length ||= select_one('SHOW max_identifier_length', 'SCHEMA'.freeze)['max_identifier_length'].to_i
|
353
358
|
end
|
@@ -395,7 +400,8 @@ module ArJdbc
|
|
395
400
|
# 'DISCARD ALL' fails if we are inside a transaction
|
396
401
|
def clear_cache!
|
397
402
|
super
|
398
|
-
|
403
|
+
# Make sure all query plans are *really* gone
|
404
|
+
@connection.execute 'DEALLOCATE ALL' if active?
|
399
405
|
end
|
400
406
|
|
401
407
|
def reset!
|
@@ -511,7 +517,7 @@ module ArJdbc
|
|
511
517
|
col_description(a.attrelid, a.attnum) AS comment
|
512
518
|
FROM pg_attribute a
|
513
519
|
LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
|
514
|
-
WHERE a.attrelid =
|
520
|
+
WHERE a.attrelid = #{quote(quote_table_name(table_name))}::regclass
|
515
521
|
AND a.attnum > 0 AND NOT a.attisdropped
|
516
522
|
ORDER BY a.attnum
|
517
523
|
end_sql
|
@@ -556,13 +562,24 @@ module ArJdbc
|
|
556
562
|
end
|
557
563
|
|
558
564
|
def translate_exception(exception, message)
|
565
|
+
return super unless exception.is_a?(ActiveRecord::JDBCError)
|
566
|
+
|
567
|
+
# TODO: Can we base these on an error code of some kind?
|
559
568
|
case exception.message
|
560
569
|
when /duplicate key value violates unique constraint/
|
561
570
|
::ActiveRecord::RecordNotUnique.new(message)
|
571
|
+
when /violates not-null constraint/
|
572
|
+
::ActiveRecord::NotNullViolation.new(message)
|
562
573
|
when /violates foreign key constraint/
|
563
574
|
::ActiveRecord::InvalidForeignKey.new(message)
|
564
575
|
when /value too long/
|
565
576
|
::ActiveRecord::ValueTooLong.new(message)
|
577
|
+
when /out of range/
|
578
|
+
::ActiveRecord::RangeError.new(message)
|
579
|
+
when /could not serialize/
|
580
|
+
::ActiveRecord::SerializationFailure.new(message)
|
581
|
+
when /deadlock detected/
|
582
|
+
::ActiveRecord::Deadlocked.new(message)
|
566
583
|
else
|
567
584
|
super
|
568
585
|
end
|
@@ -637,6 +654,7 @@ module ActiveRecord::ConnectionAdapters
|
|
637
654
|
def initialize(connection, logger = nil, connection_parameters = nil, config = {})
|
638
655
|
# @local_tz is initialized as nil to avoid warnings when connect tries to use it
|
639
656
|
@local_tz = nil
|
657
|
+
@max_identifier_length = nil
|
640
658
|
|
641
659
|
super(connection, logger, config) # configure_connection happens in super
|
642
660
|
|
@@ -652,7 +670,6 @@ module ActiveRecord::ConnectionAdapters
|
|
652
670
|
|
653
671
|
require 'active_record/connection_adapters/postgresql/schema_definitions'
|
654
672
|
|
655
|
-
ColumnDefinition = ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnDefinition
|
656
673
|
ColumnMethods = ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnMethods
|
657
674
|
TableDefinition = ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition
|
658
675
|
Table = ActiveRecord::ConnectionAdapters::PostgreSQL::Table
|
@@ -15,7 +15,7 @@ module ArJdbc
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# Extracts the value from a PostgreSQL column default definition.
|
18
|
-
def extract_value_from_default(default)
|
18
|
+
def extract_value_from_default(default) # :nodoc:
|
19
19
|
case default
|
20
20
|
# Quoted types
|
21
21
|
when /\A[\(B]?'(.*)'.*::"?([\w. ]+)"?(?:\[\])?\z/m
|
@@ -41,13 +41,10 @@ module ArJdbc
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
def extract_default_function(default_value, default)
|
45
|
-
default if
|
44
|
+
def extract_default_function(default_value, default) # :nodoc:
|
45
|
+
default if ! default_value && ( %r{\w+\(.*\)|\(.*\)::\w+} === default )
|
46
46
|
end
|
47
47
|
|
48
|
-
def has_default_function?(default_value, default)
|
49
|
-
!default_value && %r{\w+\(.*\)|\(.*\)::\w+|CURRENT_DATE|CURRENT_TIMESTAMP} === default
|
50
|
-
end
|
51
48
|
end
|
52
49
|
|
53
50
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
ArJdbc::ConnectionMethods.module_eval do
|
3
3
|
def postgresql_connection(config)
|
4
|
-
config = config.deep_dup
|
5
4
|
# NOTE: this isn't "really" necessary but Rails (in tests) assumes being able to :
|
6
5
|
# ActiveRecord::Base.postgresql_connection ActiveRecord::Base.configurations['arunit'].merge(:insert_returning => false)
|
7
6
|
# ... while using symbols by default but than configurations returning string keys ;(
|
@@ -17,8 +16,7 @@ ArJdbc::ConnectionMethods.module_eval do
|
|
17
16
|
::Jdbc::Postgres.load_driver(:require) if defined?(::Jdbc::Postgres.load_driver)
|
18
17
|
rescue LoadError # assuming driver.jar is on the class-path
|
19
18
|
end
|
20
|
-
driver =
|
21
|
-
defined?(::Jdbc::Postgres.driver_name) ? ::Jdbc::Postgres.driver_name : 'org.postgresql.Driver')
|
19
|
+
driver = config[:driver] ||= 'org.postgresql.Driver'
|
22
20
|
|
23
21
|
host = config[:host] ||= ( config[:hostaddr] || ENV['PGHOST'] || 'localhost' )
|
24
22
|
port = config[:port] ||= ( ENV['PGPORT'] || 5432 )
|
@@ -124,7 +124,7 @@ module ArJdbc
|
|
124
124
|
register_class_with_limit m, 'int2', Type::Integer
|
125
125
|
register_class_with_limit m, 'int4', Type::Integer
|
126
126
|
register_class_with_limit m, 'int8', Type::Integer
|
127
|
-
m.
|
127
|
+
m.register_type 'oid', OID::Oid.new
|
128
128
|
m.register_type 'float4', Type::Float.new
|
129
129
|
m.alias_type 'float8', 'float4'
|
130
130
|
m.register_type 'text', Type::Text.new
|
@@ -159,15 +159,10 @@ module ArJdbc
|
|
159
159
|
m.register_type 'polygon', OID::SpecializedString.new(:polygon)
|
160
160
|
m.register_type 'circle', OID::SpecializedString.new(:circle)
|
161
161
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
# m.register_type 'interval' do |_, _, sql_type|
|
167
|
-
# precision = extract_precision(sql_type)
|
168
|
-
# OID::SpecializedString.new(:interval, precision: precision)
|
169
|
-
# end
|
170
|
-
m.register_type 'interval', OID::SpecializedString.new(:interval)
|
162
|
+
m.register_type 'interval' do |_, _, sql_type|
|
163
|
+
precision = extract_precision(sql_type)
|
164
|
+
OID::SpecializedString.new(:interval, precision: precision)
|
165
|
+
end
|
171
166
|
|
172
167
|
register_class_with_precision m, 'time', Type::Time
|
173
168
|
register_class_with_precision m, 'timestamp', OID::DateTime
|
@@ -255,8 +250,8 @@ module ArJdbc
|
|
255
250
|
ActiveRecord::Type.register(:json, OID::Json, adapter: :postgresql)
|
256
251
|
ActiveRecord::Type.register(:jsonb, OID::Jsonb, adapter: :postgresql)
|
257
252
|
ActiveRecord::Type.register(:money, OID::Money, adapter: :postgresql)
|
258
|
-
ActiveRecord::Type.register(:point, OID::
|
259
|
-
ActiveRecord::Type.register(:legacy_point, OID::
|
253
|
+
ActiveRecord::Type.register(:point, OID::Point, adapter: :postgresql)
|
254
|
+
ActiveRecord::Type.register(:legacy_point, OID::LegacyPoint, adapter: :postgresql)
|
260
255
|
ActiveRecord::Type.register(:uuid, OID::Uuid, adapter: :postgresql)
|
261
256
|
ActiveRecord::Type.register(:vector, OID::Vector, adapter: :postgresql)
|
262
257
|
ActiveRecord::Type.register(:xml, OID::Xml, adapter: :postgresql)
|