activerecord-jdbc-adapter 1.3.25 → 5.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +57 -72
- data/Appraisals +7 -2
- data/Gemfile +3 -7
- data/History.md +0 -50
- data/RUNNING_TESTS.md +4 -0
- data/activerecord-jdbc-adapter.gemspec +2 -1
- data/lib/arjdbc/common_jdbc_methods.rb +89 -0
- data/lib/arjdbc/db2/adapter.rb +58 -69
- data/lib/arjdbc/db2/as400.rb +2 -13
- data/lib/arjdbc/db2/column.rb +1 -1
- data/lib/arjdbc/derby/adapter.rb +2 -6
- data/lib/arjdbc/firebird/adapter.rb +7 -16
- data/lib/arjdbc/h2/adapter.rb +4 -13
- data/lib/arjdbc/hsqldb/adapter.rb +5 -5
- data/lib/arjdbc/jdbc/adapter.rb +15 -76
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/adapter_require.rb +12 -31
- data/lib/arjdbc/jdbc/base_ext.rb +6 -25
- data/lib/arjdbc/jdbc/column.rb +15 -1
- data/lib/arjdbc/jdbc/connection_methods.rb +7 -1
- data/lib/arjdbc/jdbc/type_cast.rb +16 -4
- data/lib/arjdbc/jdbc/type_converter.rb +0 -1
- data/lib/arjdbc/mssql/adapter.rb +9 -21
- data/lib/arjdbc/mysql/adapter.rb +14 -19
- data/lib/arjdbc/mysql/connection_methods.rb +3 -5
- data/lib/arjdbc/oracle/adapter.rb +4 -38
- data/lib/arjdbc/oracle/connection_methods.rb +0 -4
- data/lib/arjdbc/postgresql/adapter.rb +18 -22
- data/lib/arjdbc/postgresql/connection_methods.rb +2 -5
- data/lib/arjdbc/postgresql/oid/bytea.rb +0 -1
- data/lib/arjdbc/postgresql/oid_types.rb +6 -6
- data/lib/arjdbc/sqlite3/adapter.rb +493 -404
- data/lib/arjdbc/tasks/database_tasks.rb +1 -1
- data/lib/arjdbc/tasks/databases3.rake +1 -1
- data/lib/arjdbc/tasks/databases4.rake +3 -8
- data/lib/arjdbc/version.rb +1 -1
- data/rakelib/db.rake +5 -8
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +102 -37
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +0 -7
- metadata +10 -17
- data/lib/arjdbc/jdbc/arel_support.rb +0 -133
- data/lib/arjdbc/mssql/attributes_for_update.rb +0 -22
- data/lib/arjdbc/sqlite3/explain_support.rb +0 -29
data/lib/arjdbc/jdbc/column.rb
CHANGED
@@ -25,10 +25,24 @@ module ActiveRecord
|
|
25
25
|
default = args.shift
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
|
+
if ArJdbc::AR50
|
30
|
+
default = args[0].cast(default)
|
31
|
+
|
32
|
+
sql_type = args.delete_at(1)
|
33
|
+
type = args.delete_at(0)
|
34
|
+
|
35
|
+
args.unshift(SqlTypeMetadata.new(:sql_type => sql_type, :type => type))
|
36
|
+
elsif ArJdbc::AR42
|
37
|
+
default = args[0].type_cast_from_database(default)
|
38
|
+
else
|
39
|
+
default = default_value(default)
|
40
|
+
end
|
29
41
|
|
30
42
|
# super <= 4.1: (name, default, sql_type = nil, null = true)
|
31
43
|
# super >= 4.2: (name, default, cast_type, sql_type = nil, null = true)
|
44
|
+
# super >= 5.0: (name, default, sql_type_metadata = nil, null = true)
|
45
|
+
|
32
46
|
super(name, default, *args)
|
33
47
|
init_column(name, default, *args)
|
34
48
|
end
|
@@ -9,7 +9,13 @@ module ArJdbc
|
|
9
9
|
def jdbc_connection(config)
|
10
10
|
adapter_class = config[:adapter_class]
|
11
11
|
adapter_class ||= ::ActiveRecord::ConnectionAdapters::JdbcAdapter
|
12
|
-
|
12
|
+
|
13
|
+
# Once all adapters converted to AR5 then this rescue can be removed
|
14
|
+
begin
|
15
|
+
adapter_class.new(nil, logger, nil, config)
|
16
|
+
rescue ArgumentError
|
17
|
+
adapter_class.new(nil, logger, config)
|
18
|
+
end
|
13
19
|
end
|
14
20
|
|
15
21
|
def jndi_connection(config); jdbc_connection(config) end
|
@@ -5,13 +5,25 @@ module ActiveRecord::ConnectionAdapters
|
|
5
5
|
# Type casting methods taken from AR 4.1's Column class.
|
6
6
|
# @private Simply to quickly "hack-in" 4.2 compatibility.
|
7
7
|
module TypeCast
|
8
|
-
|
9
8
|
TRUE_VALUES = Column::TRUE_VALUES if Column.const_defined?(:TRUE_VALUES)
|
10
|
-
FALSE_VALUES =
|
9
|
+
FALSE_VALUES = if defined?(ActiveModel::Type::Boolean::FALSE_VALUES)
|
10
|
+
ActiveModel::Type::Boolean::FALSE_VALUES
|
11
|
+
else
|
12
|
+
Column::FALSE_VALUES
|
13
|
+
end
|
11
14
|
|
12
15
|
#module Format
|
13
|
-
ISO_DATE =
|
14
|
-
|
16
|
+
ISO_DATE = if defined?(ActiveModel::Type::Date::ISO_DATE)
|
17
|
+
ActiveModel::Type::Date::ISO_DATE
|
18
|
+
else
|
19
|
+
Column::Format::ISO_DATE
|
20
|
+
end
|
21
|
+
|
22
|
+
ISO_DATETIME = if defined?(ActiveModel::Type::Helpers::TimeValue::ISO_DATETIME)
|
23
|
+
ActiveModel::Type::Helpers::TimeValue::ISO_DATETIME
|
24
|
+
else
|
25
|
+
Column::Format::ISO_DATETIME
|
26
|
+
end
|
15
27
|
#end
|
16
28
|
|
17
29
|
# Used to convert from BLOBs to Strings
|
@@ -34,7 +34,6 @@ module ActiveRecord
|
|
34
34
|
:text => [ lambda {|r| TEXT_TYPES.include?(r['data_type'].to_i)},
|
35
35
|
lambda {|r| r['type_name'] =~ /^text$/i}, # For Informix
|
36
36
|
lambda {|r| r['type_name'] =~ /sub_type 1$/i}, # For FireBird
|
37
|
-
lambda {|r| r['type_name'] =~ /^long varchar$/i}, # Legacy Sybase/SqlAnywhere
|
38
37
|
lambda {|r| r['type_name'] =~ /^(text|clob)$/i},
|
39
38
|
lambda {|r| r['type_name'] =~ /^character large object$/i},
|
40
39
|
lambda {|r| r['sql_data_type'] == 2005}],
|
data/lib/arjdbc/mssql/adapter.rb
CHANGED
@@ -35,7 +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 '
|
38
|
+
require 'arel/visitors/sql_server'
|
39
39
|
|
40
40
|
include LimitHelpers
|
41
41
|
include Utils
|
@@ -102,24 +102,6 @@ module ArJdbc
|
|
102
102
|
# @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_column_class
|
103
103
|
def jdbc_column_class; ::ActiveRecord::ConnectionAdapters::MSSQLColumn end
|
104
104
|
|
105
|
-
# @see ActiveRecord::ConnectionAdapters::Jdbc::ArelSupport
|
106
|
-
def self.arel_visitor_type(config)
|
107
|
-
require 'arel/visitors/sql_server'
|
108
|
-
( config && config[:sqlserver_version].to_s == '2000' ) ?
|
109
|
-
::Arel::Visitors::SQLServer2000 : ::Arel::Visitors::SQLServer
|
110
|
-
end
|
111
|
-
|
112
|
-
def self.arel_visitor_type(config)
|
113
|
-
require 'arel/visitors/sql_server'; ::Arel::Visitors::SQLServerNG
|
114
|
-
end if AR42
|
115
|
-
|
116
|
-
# @deprecated no longer used
|
117
|
-
# @see ActiveRecord::ConnectionAdapters::JdbcAdapter#arel2_visitors
|
118
|
-
def self.arel2_visitors(config)
|
119
|
-
visitor = arel_visitor_type(config)
|
120
|
-
{ 'mssql' => visitor, 'jdbcmssql' => visitor, 'sqlserver' => visitor }
|
121
|
-
end
|
122
|
-
|
123
105
|
def configure_connection
|
124
106
|
use_database # config[:database]
|
125
107
|
end
|
@@ -575,7 +557,7 @@ module ArJdbc
|
|
575
557
|
def remove_check_constraints(table_name, column_name)
|
576
558
|
clear_cached_table(table_name)
|
577
559
|
constraints = select_values "SELECT constraint_name" <<
|
578
|
-
" FROM
|
560
|
+
" FROM information_schema.constraint_column_usage" <<
|
579
561
|
" WHERE table_name = '#{table_name}' AND column_name = '#{column_name}'"
|
580
562
|
constraints.each do |constraint_name|
|
581
563
|
execute "ALTER TABLE #{table_name} DROP CONSTRAINT #{constraint_name}"
|
@@ -656,7 +638,7 @@ module ArJdbc
|
|
656
638
|
unless primary_column # look for an id column and return it,
|
657
639
|
# without changing case, to cover DBs with a case-sensitive collation :
|
658
640
|
primary_column = columns.find { |column| column.name =~ /^id$/i }
|
659
|
-
raise "no columns for table: #{table_name}" if columns.empty?
|
641
|
+
raise "no columns for table: #{table_name} (SQL query: ' #{sql} ')" if columns.empty?
|
660
642
|
end
|
661
643
|
# NOTE: if still no PK column simply get something for ORDER BY ...
|
662
644
|
"#{quote_table_name(table_name)}.#{quote_column_name((primary_column || columns.first).name)}"
|
@@ -808,6 +790,12 @@ module ActiveRecord::ConnectionAdapters
|
|
808
790
|
setup_limit_offset!
|
809
791
|
end
|
810
792
|
|
793
|
+
def arel_visitor # :nodoc:
|
794
|
+
( config && config[:sqlserver_version].to_s == '2000' ) ?
|
795
|
+
::Arel::Visitors::SQLServer2000.new(self) :
|
796
|
+
::Arel::Visitors::SQLServer.new(self)
|
797
|
+
end
|
798
|
+
|
811
799
|
def self.cs_equality_operator; ::ArJdbc::MSSQL.cs_equality_operator end
|
812
800
|
def self.cs_equality_operator=(operator); ::ArJdbc::MSSQL.cs_equality_operator = operator end
|
813
801
|
|
data/lib/arjdbc/mysql/adapter.rb
CHANGED
@@ -28,7 +28,12 @@ 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 ==
|
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
|
32
37
|
config[:connection_alive_sql] ||= 'SELECT 1' # need 5.1 for JDBC 4.0
|
33
38
|
else
|
34
39
|
# NOTE: since the loaded Java driver class can't change :
|
@@ -44,7 +49,7 @@ module ArJdbc
|
|
44
49
|
# Increase timeout so the server doesn't disconnect us.
|
45
50
|
wait_timeout = config[:wait_timeout]
|
46
51
|
wait_timeout = self.class.type_cast_config_to_integer(wait_timeout)
|
47
|
-
variables[:wait_timeout] = wait_timeout.is_a?(
|
52
|
+
variables[:wait_timeout] = wait_timeout.is_a?(Fixnum) ? wait_timeout : 2147483
|
48
53
|
|
49
54
|
# Make MySQL reject illegal values rather than truncating or blanking them, see
|
50
55
|
# http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_strict_all_tables
|
@@ -52,15 +57,11 @@ module ArJdbc
|
|
52
57
|
if strict_mode? && ! variables.has_key?(:sql_mode)
|
53
58
|
variables[:sql_mode] = 'STRICT_ALL_TABLES' # SET SQL_MODE='STRICT_ALL_TABLES'
|
54
59
|
end
|
55
|
-
|
60
|
+
|
56
61
|
# NAMES does not have an equals sign, see
|
57
62
|
# http://dev.mysql.com/doc/refman/5.0/en/set-statement.html#id944430
|
58
63
|
# (trailing comma because variable_assignments will always have content)
|
59
|
-
if
|
60
|
-
encoding = "NAMES #{@config[:encoding]}"
|
61
|
-
encoding << " COLLATE #{@config[:collation]}" if @config[:collation]
|
62
|
-
encoding << ", "
|
63
|
-
end
|
64
|
+
encoding = "NAMES #{config[:encoding]}, " if config[:encoding]
|
64
65
|
|
65
66
|
# Gather up all of the SET variables...
|
66
67
|
variable_assignments = variables.map do |k, v|
|
@@ -132,16 +133,6 @@ module ArJdbc
|
|
132
133
|
ADAPTER_NAME
|
133
134
|
end
|
134
135
|
|
135
|
-
def self.arel_visitor_type(config = nil)
|
136
|
-
::Arel::Visitors::MySQL
|
137
|
-
end
|
138
|
-
|
139
|
-
# @see ActiveRecord::ConnectionAdapters::JdbcAdapter#bind_substitution
|
140
|
-
# @private
|
141
|
-
class BindSubstitution < Arel::Visitors::MySQL
|
142
|
-
include Arel::Visitors::BindVisitor
|
143
|
-
end if defined? Arel::Visitors::BindVisitor
|
144
|
-
|
145
136
|
def case_sensitive_equality_operator
|
146
137
|
"= BINARY"
|
147
138
|
end
|
@@ -849,7 +840,7 @@ module ArJdbc
|
|
849
840
|
case length
|
850
841
|
when Hash
|
851
842
|
column_names.map { |name| length[name] ? "#{quote_column_name(name)}(#{length[name]})" : quote_column_name(name) }
|
852
|
-
when
|
843
|
+
when Fixnum
|
853
844
|
column_names.map { |name| "#{quote_column_name(name)}(#{length})" }
|
854
845
|
else
|
855
846
|
column_names.map { |name| quote_column_name(name) }
|
@@ -953,6 +944,10 @@ module ActiveRecord
|
|
953
944
|
include ::ArJdbc::MySQL
|
954
945
|
include ::ArJdbc::MySQL::ExplainSupport
|
955
946
|
|
947
|
+
def arel_visitor # :nodoc:
|
948
|
+
Arel::Visitors::MySQL.new(self)
|
949
|
+
end
|
950
|
+
|
956
951
|
# By default, the MysqlAdapter will consider all columns of type
|
957
952
|
# __tinyint(1)__ as boolean. If you wish to disable this :
|
958
953
|
# ```
|
@@ -63,11 +63,9 @@ ArJdbc::ConnectionMethods.module_eval do
|
|
63
63
|
properties['verifyServerCertificate'] ||= false if mysql_driver
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
# must be established by default if explicit option isn't set :
|
70
|
-
properties[mariadb_driver ? 'useSsl' : 'useSSL'] ||= false
|
66
|
+
if mariadb_driver
|
67
|
+
properties['verifyServerCertificate'] ||= false
|
68
|
+
end
|
71
69
|
end
|
72
70
|
if socket = config[:socket]
|
73
71
|
properties['localSocket'] ||= socket if mariadb_driver
|
@@ -57,25 +57,6 @@ 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
|
-
|
79
60
|
# @private
|
80
61
|
@@update_lob_values = true
|
81
62
|
|
@@ -142,16 +123,6 @@ module ArJdbc
|
|
142
123
|
TableDefinition.new native_database_types, name, temporary, options, as
|
143
124
|
end if AR42
|
144
125
|
|
145
|
-
def self.arel_visitor_type(config = nil)
|
146
|
-
::Arel::Visitors::Oracle
|
147
|
-
end
|
148
|
-
|
149
|
-
# @see ActiveRecord::ConnectionAdapters::JdbcAdapter#bind_substitution
|
150
|
-
# @private
|
151
|
-
class BindSubstitution < ::Arel::Visitors::Oracle
|
152
|
-
include ::Arel::Visitors::BindVisitor
|
153
|
-
end if defined? ::Arel::Visitors::BindVisitor
|
154
|
-
|
155
126
|
ADAPTER_NAME = 'Oracle'.freeze
|
156
127
|
|
157
128
|
def adapter_name
|
@@ -921,13 +892,9 @@ module ArJdbc
|
|
921
892
|
# default schema owner
|
922
893
|
def schema_owner(force = true)
|
923
894
|
unless defined? @schema_owner
|
924
|
-
|
925
|
-
|
926
|
-
|
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
|
895
|
+
username = config[:username] ? config[:username].to_s : nil
|
896
|
+
username = jdbc_connection.meta_data.user_name if force && username.nil?
|
897
|
+
@schema_owner = username.nil? ? nil : username.upcase
|
931
898
|
end
|
932
899
|
@schema_owner
|
933
900
|
end
|
@@ -966,11 +933,10 @@ module ActiveRecord::ConnectionAdapters
|
|
966
933
|
|
967
934
|
def initialize(*args)
|
968
935
|
::ArJdbc::Oracle.initialize!
|
936
|
+
super # configure_connection happens in super
|
969
937
|
|
970
938
|
@use_insert_returning = config.key?(:insert_returning) ?
|
971
939
|
self.class.type_cast_config_to_boolean(config[:insert_returning]) : nil
|
972
|
-
|
973
|
-
super # configure_connection happens in super
|
974
940
|
end
|
975
941
|
|
976
942
|
end
|
@@ -15,10 +15,6 @@ 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
|
22
18
|
jdbc_connection(config)
|
23
19
|
end
|
24
20
|
alias_method :jdbcoracle_connection, :oracle_connection
|
@@ -17,6 +17,7 @@ module ArJdbc
|
|
17
17
|
require 'arjdbc/postgresql/column'
|
18
18
|
require 'arjdbc/postgresql/explain_support'
|
19
19
|
require 'arjdbc/postgresql/schema_creation' # AR 4.x
|
20
|
+
require 'arel/visitors/postgresql_jdbc'
|
20
21
|
# @private
|
21
22
|
IndexDefinition = ::ActiveRecord::ConnectionAdapters::IndexDefinition
|
22
23
|
|
@@ -45,18 +46,6 @@ module ArJdbc
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
|
-
# @see ActiveRecord::ConnectionAdapters::Jdbc::ArelSupport
|
49
|
-
def self.arel_visitor_type(config = nil)
|
50
|
-
require 'arel/visitors/postgresql_jdbc'
|
51
|
-
::Arel::Visitors::PostgreSQL
|
52
|
-
end
|
53
|
-
|
54
|
-
# @see ActiveRecord::ConnectionAdapters::JdbcAdapter#bind_substitution
|
55
|
-
# @private
|
56
|
-
class BindSubstitution < ::Arel::Visitors::PostgreSQL
|
57
|
-
include ::Arel::Visitors::BindVisitor
|
58
|
-
end if defined? ::Arel::Visitors::BindVisitor
|
59
|
-
|
60
49
|
ADAPTER_NAME = 'PostgreSQL'.freeze
|
61
50
|
|
62
51
|
def adapter_name
|
@@ -67,7 +56,7 @@ module ArJdbc
|
|
67
56
|
@postgresql_version ||=
|
68
57
|
begin
|
69
58
|
version = select_version
|
70
|
-
if version =~ /PostgreSQL (\d+)\.(\d+)(
|
59
|
+
if version =~ /PostgreSQL (\d+)\.(\d+)\.(\d+)/
|
71
60
|
($1.to_i * 10000) + ($2.to_i * 100) + $3.to_i
|
72
61
|
else
|
73
62
|
0
|
@@ -165,7 +154,7 @@ module ArJdbc
|
|
165
154
|
when 1, 2; 'smallint'
|
166
155
|
when 3, 4; 'integer'
|
167
156
|
when 5..8; 'bigint'
|
168
|
-
else raise(ActiveRecordError, "No integer type has byte size #{limit}. Use a numeric with
|
157
|
+
else raise(ActiveRecordError, "No integer type has byte size #{limit}. Use a numeric with precision 0 instead.")
|
169
158
|
end
|
170
159
|
when 'datetime'
|
171
160
|
return super unless precision
|
@@ -286,8 +275,7 @@ module ArJdbc
|
|
286
275
|
:bigserial => "bigserial",
|
287
276
|
:bigint => { :name => "bigint" },
|
288
277
|
:bit => { :name => "bit" },
|
289
|
-
:bit_varying => { :name => "bit varying" }
|
290
|
-
:citext => { :name => "citext" }
|
278
|
+
:bit_varying => { :name => "bit varying" }
|
291
279
|
) if AR42
|
292
280
|
|
293
281
|
def native_database_types
|
@@ -388,6 +376,12 @@ module ArJdbc
|
|
388
376
|
|
389
377
|
# @override
|
390
378
|
def supports_views?; true end
|
379
|
+
|
380
|
+
if ArJdbc::AR50
|
381
|
+
def views
|
382
|
+
select_values("SELECT table_name FROM INFORMATION_SCHEMA.views WHERE table_schema = ANY (current_schemas(false))")
|
383
|
+
end
|
384
|
+
end
|
391
385
|
|
392
386
|
# NOTE: handled by JdbcAdapter we override only to have save-point in logs :
|
393
387
|
|
@@ -571,8 +565,7 @@ module ArJdbc
|
|
571
565
|
end
|
572
566
|
|
573
567
|
if pk && use_insert_returning?
|
574
|
-
|
575
|
-
sql = "#{sql} RETURNING (#{returning})"
|
568
|
+
sql = "#{sql} RETURNING #{quote_column_name(pk)}"
|
576
569
|
end
|
577
570
|
|
578
571
|
[ sql, binds ]
|
@@ -590,7 +583,7 @@ module ArJdbc
|
|
590
583
|
exec_query(sql, name, binds) # due RETURNING clause returns a result set
|
591
584
|
else
|
592
585
|
result = super
|
593
|
-
if pk
|
586
|
+
if pk
|
594
587
|
unless sequence_name
|
595
588
|
table_ref = extract_table_ref_from_insert_sql(sql)
|
596
589
|
sequence_name = default_sequence_name(table_ref, pk)
|
@@ -688,8 +681,7 @@ module ArJdbc
|
|
688
681
|
return result if result.is_a? Integer
|
689
682
|
# <ActiveRecord::Result @hash_rows=nil, @columns=["id"], @rows=[[3]]>
|
690
683
|
# but it will work with [{ 'id' => 1 }] Hash wrapped results as well
|
691
|
-
|
692
|
-
row && row.first[1] # .first = { "id"=>1 } .first = [ "id", 1 ]
|
684
|
+
result.first.first[1] # .first = { "id"=>1 } .first = [ "id", 1 ]
|
693
685
|
end
|
694
686
|
|
695
687
|
def last_insert_id(table, sequence_name = nil)
|
@@ -1021,7 +1013,7 @@ module ArJdbc
|
|
1021
1013
|
# @override
|
1022
1014
|
def quoted_date(value)
|
1023
1015
|
result = super
|
1024
|
-
if value.acts_like?(:time) && value.respond_to?(:usec)
|
1016
|
+
if value.acts_like?(:time) && value.respond_to?(:usec) && !AR50
|
1025
1017
|
result = "#{result}.#{sprintf("%06d", value.usec)}"
|
1026
1018
|
end
|
1027
1019
|
result = "#{result.sub(/^-/, '')} BC" if value.year < 0
|
@@ -1522,6 +1514,10 @@ module ActiveRecord::ConnectionAdapters
|
|
1522
1514
|
self.class.type_cast_config_to_boolean(@config[:insert_returning]) : nil
|
1523
1515
|
end
|
1524
1516
|
|
1517
|
+
def arel_visitor # :nodoc:
|
1518
|
+
Arel::Visitors::PostgreSQL.new(self)
|
1519
|
+
end
|
1520
|
+
|
1525
1521
|
if ::ArJdbc::AR42
|
1526
1522
|
require 'active_record/connection_adapters/postgresql/schema_definitions'
|
1527
1523
|
else
|
@@ -31,16 +31,13 @@ ArJdbc::ConnectionMethods.module_eval do
|
|
31
31
|
end
|
32
32
|
sslmode = config.key?(:sslmode) ? config[:sslmode] : config[:requiressl]
|
33
33
|
# NOTE: makes not much sense since this needs some JVM options :
|
34
|
-
sslmode = ENV['PGSSLMODE'] || ENV['PGREQUIRESSL'] if sslmode.nil?
|
34
|
+
# sslmode = ENV['PGSSLMODE'] || ENV['PGREQUIRESSL'] if sslmode.nil?
|
35
35
|
unless sslmode.nil? # PG :sslmode - disable|allow|prefer|require
|
36
36
|
# JRuby/JVM needs to be started with :
|
37
37
|
# -Djavax.net.ssl.trustStore=mystore -Djavax.net.ssl.trustStorePassword=...
|
38
38
|
# or a non-validating connection might be used (for testing) :
|
39
39
|
# :sslfactory = 'org.postgresql.ssl.NonValidatingFactory'
|
40
|
-
if sslmode == true || sslmode.to_s == 'require'
|
41
|
-
properties['sslfactory'] ||= 'org.postgresql.ssl.NonValidatingFactory'
|
42
|
-
properties['ssl'] ||= 'true'
|
43
|
-
end
|
40
|
+
properties['ssl'] ||= 'true' if sslmode == true || sslmode.to_s == 'require'
|
44
41
|
end
|
45
42
|
properties['tcpKeepAlive'] ||= config[:keepalives] if config.key?(:keepalives)
|
46
43
|
properties['kerberosServerName'] ||= config[:krbsrvname] if config[:krbsrvname]
|