@@ -21,6 +21,9 @@ def self.jdbc_connection_class
2121 ::ActiveRecord ::ConnectionAdapters ::PostgreSQLJdbcConnection
2222 end
2323
24+ # @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_column_class
25+ def jdbc_column_class ; ::ActiveRecord ::ConnectionAdapters ::PostgreSQLColumn end
26+
2427 # @private
2528 def init_connection ( jdbc_connection )
2629 meta = jdbc_connection . meta_data
@@ -159,12 +162,12 @@ def type_cast(value, column, array_member = false)
159162 when Array
160163 case column . sql_type
161164 when 'point'
162- Column . point_to_string ( value )
165+ jdbc_column_class . point_to_string ( value )
163166 when 'json'
164- Column . json_to_string ( value )
167+ jdbc_column_class . json_to_string ( value )
165168 else
166169 return super ( value , column ) unless column . array?
167- Column . array_to_string ( value , column , self )
170+ jdbc_column_class . array_to_string ( value , column , self )
168171 end
169172 when NilClass
170173 if column . array? && array_member
@@ -177,17 +180,17 @@ def type_cast(value, column, array_member = false)
177180 when Hash
178181 case column . sql_type
179182 when 'hstore'
180- Column . hstore_to_string ( value )
183+ jdbc_column_class . hstore_to_string ( value )
181184 when 'json'
182- Column . json_to_string ( value )
185+ jdbc_column_class . json_to_string ( value )
183186 else super ( value , column )
184187 end
185188 when IPAddr
186189 return super unless column . sql_type == 'inet' || column . sql_type == 'cidr'
187- Column . cidr_to_string ( value )
190+ jdbc_column_class . cidr_to_string ( value )
188191 when Range
189192 return super ( value , column ) unless /range$/ =~ column . sql_type
190- Column . range_to_string ( value )
193+ jdbc_column_class . range_to_string ( value )
191194 else
192195 super ( value , column )
193196 end
@@ -826,30 +829,30 @@ def quote(value, column = nil)
826829 sql_type && sql_type [ 0 , 3 ] == 'bit' ? quote_bit ( value ) : super
827830 when Array
828831 if AR4_COMPAT && column . array? # will be always falsy in AR < 4.0
829- "'#{ Column . array_to_string ( value , column , self ) . gsub ( /'/ , "''" ) } '"
832+ "'#{ jdbc_column_class . array_to_string ( value , column , self ) . gsub ( /'/ , "''" ) } '"
830833 elsif column . type == :json # only in AR-4.0
831- super ( Column . json_to_string ( value ) , column )
834+ super ( jdbc_column_class . json_to_string ( value ) , column )
832835 elsif column . type == :point # only in AR-4.0
833- super ( Column . point_to_string ( value ) , column )
836+ super ( jdbc_column_class . point_to_string ( value ) , column )
834837 else super
835838 end
836839 when Hash
837840 if column . type == :hstore # only in AR-4.0
838- super ( Column . hstore_to_string ( value ) , column )
841+ super ( jdbc_column_class . hstore_to_string ( value ) , column )
839842 elsif column . type == :json # only in AR-4.0
840- super ( Column . json_to_string ( value ) , column )
843+ super ( jdbc_column_class . json_to_string ( value ) , column )
841844 else super
842845 end
843846 when Range
844847 sql_type = column . respond_to? ( :sql_type ) && column . sql_type
845848 if sql_type && sql_type [ -5 , 5 ] == 'range' && AR4_COMPAT
846- escaped = quote_string ( Column . range_to_string ( value ) )
849+ escaped = quote_string ( jdbc_column_class . range_to_string ( value ) )
847850 "'#{ escaped } '::#{ sql_type } "
848851 else super
849852 end
850853 when IPAddr
851854 if column . type == :inet || column . type == :cidr # only in AR-4.0
852- super ( Column . cidr_to_string ( value ) , column )
855+ super ( jdbc_column_class . cidr_to_string ( value ) , column )
853856 else super
854857 end
855858 else
@@ -1079,6 +1082,7 @@ def index_name_length
10791082
10801083 # Returns the list of all column definitions for a table.
10811084 def columns ( table_name , name = nil )
1085+ column = jdbc_column_class
10821086 pass_cast_type = respond_to? ( :lookup_cast_type )
10831087 column_definitions ( table_name ) . map do |row |
10841088 # name, type, default, notnull, oid, fmod
@@ -1095,9 +1099,9 @@ def columns(table_name, name = nil)
10951099 end
10961100 if pass_cast_type
10971101 cast_type = lookup_cast_type ( type )
1098- Column . new ( name , default , cast_type , type , ! notnull , fmod , self )
1102+ column . new ( name , default , cast_type , type , ! notnull , fmod , self )
10991103 else
1100- Column . new ( name , default , oid , type , ! notnull , fmod , self )
1104+ column . new ( name , default , oid , type , ! notnull , fmod , self )
11011105 end
11021106 end
11031107 end
@@ -1483,21 +1487,10 @@ def jdbc_connection_class(spec)
14831487 ::ArJdbc ::PostgreSQL . jdbc_connection_class
14841488 end
14851489
1486- # @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_column_class
1487- def jdbc_column_class
1488- ::ActiveRecord ::ConnectionAdapters ::PostgreSQLColumn
1489- end
1490-
14911490 if ::ActiveRecord ::VERSION ::MAJOR < 4 # Rails 3.x compatibility
14921491 PostgreSQLJdbcConnection . raw_array_type = true if PostgreSQLJdbcConnection . raw_array_type? == nil
14931492 PostgreSQLJdbcConnection . raw_hstore_type = true if PostgreSQLJdbcConnection . raw_hstore_type? == nil
14941493 end
14951494
14961495 end
14971496end
1498-
1499- module ArJdbc
1500- module PostgreSQL
1501- Column = ::ActiveRecord ::ConnectionAdapters ::PostgreSQLColumn
1502- end
1503- end
0 commit comments