aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb54
1 files changed, 8 insertions, 46 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
index 4caed77952..f9541b437a 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
@@ -27,17 +27,9 @@ module ActiveRecord
else
super
end
- when Array
- case sql_type
- when 'point' then super(PostgreSQLColumn.point_to_string(value))
- when 'json' then super(PostgreSQLColumn.json_to_string(value))
- else
- super(value, array_column(column))
- end
when Hash
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 Float
@@ -71,39 +63,29 @@ module ActiveRecord
end
end
- def type_cast(value, column, array_member = false)
- return super(value, column) unless column
+ def type_cast(value, column)
+ return super unless column
case value
when Range
if /range$/ =~ column.sql_type
PostgreSQLColumn.range_to_string(value)
else
- super(value, column)
+ super
end
when NilClass
- if column.array && array_member
- 'NULL'
- elsif column.array
+ if column.array
value
else
- super(value, column)
- end
- when Array
- case column.sql_type
- when 'point' then PostgreSQLColumn.point_to_string(value)
- when 'json' then PostgreSQLColumn.json_to_string(value)
- else
- super(value, array_column(column))
+ super
end
when Hash
case column.sql_type
- when 'hstore' then PostgreSQLColumn.hstore_to_string(value, array_member)
- when 'json' then PostgreSQLColumn.json_to_string(value)
- else super(value, column)
+ when 'hstore' then PostgreSQLColumn.hstore_to_string(value)
+ else super
end
else
- super(value, column)
+ super
end
end
@@ -177,26 +159,6 @@ module ActiveRecord
super
end
end
-
- def array_column(column)
- if column.array && !column.respond_to?(:cast_type)
- Column.new('', nil, OID::Array.new(AdapterProxyType.new(column, self)))
- else
- column
- end
- end
-
- class AdapterProxyType < SimpleDelegator # :nodoc:
- def initialize(column, adapter)
- @column = column
- @adapter = adapter
- super(column)
- end
-
- def type_cast_for_database(value)
- @adapter.type_cast(value, @column)
- end
- end
end
end
end