From 167201b5c7534465c6c3ae64770f3fe8a39abade Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Sun, 29 Jun 2014 13:07:53 -0600 Subject: Remove unused `array_member` from PG quoting for HStore columns Hstore no longer needs additional quoting to be used in an array, the array type handles it sufficiently. --- .../connection_adapters/postgresql/cast.rb | 3 +-- .../connection_adapters/postgresql/quoting.rb | 18 ++++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb index 95fc461bae..c916c0795d 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb @@ -2,10 +2,9 @@ module ActiveRecord module ConnectionAdapters module PostgreSQL module Cast # :nodoc: - def hstore_to_string(object, array_member = false) # :nodoc: + def hstore_to_string(object) # :nodoc: if Hash === object string = object.map { |k, v| "#{escape_hstore(k)}=>#{escape_hstore(v)}" }.join(', ') - string = escape_hstore(string) if array_member string else object diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb index 07171a75d5..5c9e74ba24 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb @@ -65,33 +65,31 @@ 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) + super end when Array super(value, array_column(column)) when Hash case column.sql_type - when 'hstore' then PostgreSQLColumn.hstore_to_string(value, array_member) - else super(value, column) + when 'hstore' then PostgreSQLColumn.hstore_to_string(value) + else super end else - super(value, column) + super end end -- cgit v1.2.3