File tree Expand file tree Collapse file tree 5 files changed +37
-28
lines changed Expand file tree Collapse file tree 5 files changed +37
-28
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ def disconnect!
40
40
41
41
# DIFFERENCE: we delve into jdbc shared code and this does self.class.new_client.
42
42
def connect
43
- @raw_connection = jdbc_connection_class . new ( @connection_parameters , self )
43
+ @raw_connection = self . class . new_client ( @connection_parameters , self )
44
44
rescue ConnectionNotEstablished => ex
45
45
raise ex . set_pool ( @pool )
46
46
end
Original file line number Diff line number Diff line change @@ -33,6 +33,16 @@ class Mysql2Adapter < AbstractMysqlAdapter
33
33
34
34
include ArJdbc ::MySQL
35
35
36
+ class << self
37
+ def jdbc_connection_class
38
+ ::ActiveRecord ::ConnectionAdapters ::MySQLJdbcConnection
39
+ end
40
+
41
+ def new_client ( conn_params , adapter_instance )
42
+ jdbc_connection_class . new ( conn_params , adapter_instance )
43
+ end
44
+ end
45
+
36
46
def initialize ( ...)
37
47
super
38
48
@@ -221,10 +231,6 @@ def get_full_version
221
231
@full_version ||= any_raw_connection . full_version
222
232
end
223
233
224
- def jdbc_connection_class
225
- ::ActiveRecord ::ConnectionAdapters ::MySQLJdbcConnection
226
- end
227
-
228
234
def jdbc_column_class
229
235
::ActiveRecord ::ConnectionAdapters ::MySQL ::Column
230
236
end
Original file line number Diff line number Diff line change @@ -35,11 +35,6 @@ module PostgreSQL
35
35
# @private
36
36
Type = ::ActiveRecord ::Type
37
37
38
- # @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_connection_class
39
- def self . jdbc_connection_class
40
- ::ActiveRecord ::ConnectionAdapters ::PostgreSQLJdbcConnection
41
- end
42
-
43
38
# @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_column_class
44
39
def jdbc_column_class ; ::ActiveRecord ::ConnectionAdapters ::PostgreSQLColumn end
45
40
@@ -763,6 +758,16 @@ class PostgreSQLAdapter < AbstractAdapter
763
758
# AR expects OID to be available on the adapter
764
759
OID = ActiveRecord ::ConnectionAdapters ::PostgreSQL ::OID
765
760
761
+ class << self
762
+ def jdbc_connection_class
763
+ ::ActiveRecord ::ConnectionAdapters ::PostgreSQLJdbcConnection
764
+ end
765
+
766
+ def new_client ( conn_params , adapter_instance )
767
+ jdbc_connection_class . new ( conn_params , adapter_instance )
768
+ end
769
+ end
770
+
766
771
def initialize ( ...)
767
772
super
768
773
@@ -796,10 +801,6 @@ def self.database_exists?(config)
796
801
public :sql_for_insert
797
802
alias :postgresql_version :database_version
798
803
799
- def jdbc_connection_class
800
- ::ArJdbc ::PostgreSQL . jdbc_connection_class
801
- end
802
-
803
804
private
804
805
805
806
FEATURE_NOT_SUPPORTED = "0A000" # :nodoc:
Original file line number Diff line number Diff line change @@ -825,15 +825,6 @@ def jdbc_column_class
825
825
::ActiveRecord ::ConnectionAdapters ::SQLite3Column
826
826
end
827
827
828
- def jdbc_connection_class
829
- self . class . jdbc_connection_class
830
- end
831
-
832
- # @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_connection_class
833
- def self . jdbc_connection_class
834
- ::ActiveRecord ::ConnectionAdapters ::SQLite3JdbcConnection
835
- end
836
-
837
828
# 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).
838
829
# ActiveSupport.run_load_hooks(:active_record_sqlite3adapter, SQLite3Adapter)
839
830
@@ -851,6 +842,14 @@ def _limit
851
842
::ActiveRecord ::Type . register ( :integer , SQLite3Integer , adapter : :sqlite3 )
852
843
853
844
class << self
845
+ def jdbc_connection_class
846
+ ::ActiveRecord ::ConnectionAdapters ::SQLite3JdbcConnection
847
+ end
848
+
849
+ def new_client ( conn_params , adapter_instance )
850
+ jdbc_connection_class . new ( conn_params , adapter_instance )
851
+ end
852
+
854
853
def dbconsole ( config , options = { } )
855
854
args = [ ]
856
855
Original file line number Diff line number Diff line change @@ -50,12 +50,15 @@ def test_pg_single_version
50
50
private
51
51
52
52
def connection_stub ( version , full_version = false )
53
- connection = mock ( 'connection' )
54
- connection . stubs ( :jndi? )
55
- connection . stubs ( :configure_connection )
56
- connection . expects ( :database_product ) . returns full_version ? version . to_s : "PostgreSQL #{ version } "
53
+ raw_connection = mock ( 'raw_connection' )
54
+ raw_connection . stubs ( :execute )
55
+ raw_connection . stubs ( :exec_params )
56
+
57
+ ActiveRecord ::ConnectionAdapters ::PostgreSQLAdapter . stubs ( :new_client ) . returns ( raw_connection )
57
58
ActiveRecord ::ConnectionAdapters ::PostgreSQLAdapter . any_instance . stubs ( :initialize_type_map )
58
- pg_connection = ActiveRecord ::ConnectionAdapters ::PostgreSQLAdapter . new ( connection , nil , { } )
59
+
60
+ raw_connection . expects ( :database_product ) . returns ( full_version ? version . to_s : "PostgreSQL #{ version } " ) . at_least_once
61
+ pg_connection = ActiveRecord ::ConnectionAdapters ::PostgreSQLAdapter . new ( { } )
59
62
pg_connection . database_version
60
63
end
61
64
end
You can’t perform that action at this time.
0 commit comments