diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-06-29 14:56:09 -0700 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-06-29 14:56:09 -0700 |
commit | e4ad47fac52d4a385e206bd231a696d884736a01 (patch) | |
tree | f591eb4aac44819275b43c7841a6b4196c59325d | |
parent | 7a52d6bba0f3db1d1f145e80d161446668393410 (diff) | |
parent | 167201b5c7534465c6c3ae64770f3fe8a39abade (diff) | |
download | rails-e4ad47fac52d4a385e206bd231a696d884736a01.tar.gz rails-e4ad47fac52d4a385e206bd231a696d884736a01.tar.bz2 rails-e4ad47fac52d4a385e206bd231a696d884736a01.zip |
Merge pull request #15978 from sgrif/sg-pg-array-member
Remove unused `array_member` from PG quoting for HStore columns
-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 |