aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-03-15 19:29:23 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-03-22 16:21:59 -0700
commit4b4c8bdc776e2d42cd070d9cb1b3cc22f82469b1 (patch)
treeb81fe00af3d943409572c772ddb73bcd716bb91f
parent69ef76a6f8b1fbfdee81e753d6e50c3c0396d47c (diff)
downloadrails-4b4c8bdc776e2d42cd070d9cb1b3cc22f82469b1.tar.gz
rails-4b4c8bdc776e2d42cd070d9cb1b3cc22f82469b1.tar.bz2
rails-4b4c8bdc776e2d42cd070d9cb1b3cc22f82469b1.zip
stop depending on sql_type in pg
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
index 43f991b362..49b93e5626 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
@@ -18,10 +18,12 @@ module ActiveRecord
def quote(value, column = nil) #:nodoc:
return super unless column
+ sql_type = type_to_sql(column.type, column.limit, column.precision, column.scale)
+
case value
when Range
- if /range$/ =~ column.sql_type
- "'#{PostgreSQLColumn.range_to_string(value)}'::#{column.sql_type}"
+ if /range$/ =~ sql_type
+ "'#{PostgreSQLColumn.range_to_string(value)}'::#{sql_type}"
else
super
end
@@ -32,13 +34,13 @@ module ActiveRecord
super
end
when Hash
- case column.sql_type
+ case sql_type
when 'hstore' then super(PostgreSQLColumn.hstore_to_string(value), column)
when 'json' then super(PostgreSQLColumn.json_to_string(value), column)
else super
end
when IPAddr
- case column.sql_type
+ case sql_type
when 'inet', 'cidr' then super(PostgreSQLColumn.cidr_to_string(value), column)
else super
end
@@ -51,14 +53,14 @@ module ActiveRecord
super
end
when Numeric
- if column.sql_type == 'money' || [:string, :text].include?(column.type)
+ if sql_type == 'money' || [:string, :text].include?(column.type)
# Not truly string input, so doesn't require (or allow) escape string syntax.
"'#{value}'"
else
super
end
when String
- case column.sql_type
+ case sql_type
when 'bytea' then "'#{escape_bytea(value)}'"
when 'xml' then "xml '#{quote_string(value)}'"
when /^bit/