diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-06-29 13:07:53 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-06-29 15:53:47 -0600 |
commit | 167201b5c7534465c6c3ae64770f3fe8a39abade (patch) | |
tree | f591eb4aac44819275b43c7841a6b4196c59325d | |
parent | 7a52d6bba0f3db1d1f145e80d161446668393410 (diff) | |
download | rails-167201b5c7534465c6c3ae64770f3fe8a39abade.tar.gz rails-167201b5c7534465c6c3ae64770f3fe8a39abade.tar.bz2 rails-167201b5c7534465c6c3ae64770f3fe8a39abade.zip |
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.
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/cast.rb | 3 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb | 18 |
2 files changed, 9 insertions, 12 deletions
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 |