@@ -991,12 +991,18 @@ def add_order_by_for_association_limiting!(sql, options)
991991 sql . replace "SELECT * FROM (#{ sql } ) AS id_list ORDER BY #{ order } "
992992 end
993993
994- # from postgres_adapter.rb in rails project
995- # https://github.com/rails/rails/blob/3-1-stable/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L412
996- # Quotes PostgreSQL-specific data types for SQL input.
997994 def quote ( value , column = nil ) #:nodoc:
998995 return super unless column
999996
997+ # TODO recent 4.0 (master) seems to be passing a ColumnDefinition here :
998+ # NoMethodError: undefined method `sql_type' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::ColumnDefinition:0x634f6b>
999+ # .../activerecord-jdbc-adapter/lib/arjdbc/postgresql/adapter.rb:1014:in `quote'
1000+ # .../gems/rails-817e8fad5a84/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:698:in `add_column_options!'
1001+ # .../activerecord-jdbc-adapter/lib/arjdbc/postgresql/adapter.rb:507:in `add_column_options!'
1002+ # .../gems/rails-817e8fad5a84/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:168:in `add_column_options!'
1003+ # .../gems/rails-817e8fad5a84/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:135:in `visit_ColumnDefinition'
1004+ sql_type = column . sql_type rescue nil
1005+
10001006 case value
10011007 when Float
10021008 if value . infinite? && column . type == :datetime
@@ -1007,11 +1013,11 @@ def quote(value, column = nil) #:nodoc:
10071013 super
10081014 end
10091015 when Numeric
1010- return super unless column . sql_type == 'money'
1016+ return super unless sql_type == 'money'
10111017 # Not truly string input, so doesn't require (or allow) escape string syntax.
10121018 ( column . type == :string || column . type == :text ) ? "'#{ value } '" : super
10131019 when String
1014- case column . sql_type
1020+ case sql_type
10151021 when 'bytea' then "E'#{ escape_bytea ( value ) } '::bytea" # "'#{escape_bytea(value)}'"
10161022 when 'xml' then "xml '#{ quote_string ( value ) } '"
10171023 when /^bit/
@@ -1036,23 +1042,23 @@ def quote(value, column = nil) #:nodoc:
10361042 super
10371043 end
10381044 when Hash
1039- if column . sql_type == 'hstore' && AR4_COMPAT
1045+ if sql_type == 'hstore' && AR4_COMPAT
10401046 column_class = ::ActiveRecord ::ConnectionAdapters ::PostgreSQLColumn
10411047 super ( column_class . hstore_to_string ( value ) , column )
1042- elsif column . sql_type == 'json' && AR4_COMPAT
1048+ elsif sql_type == 'json' && AR4_COMPAT
10431049 column_class = ::ActiveRecord ::ConnectionAdapters ::PostgreSQLColumn
10441050 super ( column_class . json_to_string ( value ) , column )
10451051 else super
10461052 end
10471053 when Range
1048- if /range$/ =~ column . sql_type && AR4_COMPAT
1054+ if /range$/ =~ sql_type && AR4_COMPAT
10491055 column_class = ::ActiveRecord ::ConnectionAdapters ::PostgreSQLColumn
1050- "'#{ column_class . range_to_string ( value ) } '::#{ column . sql_type } "
1056+ "'#{ column_class . range_to_string ( value ) } '::#{ sql_type } "
10511057 else
10521058 super
10531059 end
10541060 when IPAddr
1055- if ( column . sql_type == 'inet' || column . sql_type == 'cidr' ) && AR4_COMPAT
1061+ if ( sql_type == 'inet' || sql_type == 'cidr' ) && AR4_COMPAT
10561062 column_class = ::ActiveRecord ::ConnectionAdapters ::PostgreSQLColumn
10571063 super ( column_class . cidr_to_string ( value ) , column )
10581064 else super
0 commit comments