diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-23 14:50:18 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-05-23 14:50:18 -0300 |
commit | a8931bd1f83d65d29ef33a8327ab0ca176c4ac30 (patch) | |
tree | 329a5ed63f70fac4b2e2adcae3343489f0de47fb /activerecord/lib/active_record | |
parent | 71cdad5a1fc1785353f0eb3a1a0717a046db1bd8 (diff) | |
parent | 28590664c97577608451fc1c879e51d945ba04f7 (diff) | |
download | rails-a8931bd1f83d65d29ef33a8327ab0ca176c4ac30.tar.gz rails-a8931bd1f83d65d29ef33a8327ab0ca176c4ac30.tar.bz2 rails-a8931bd1f83d65d29ef33a8327ab0ca176c4ac30.zip |
Merge pull request #15281 from sgrif/sg-inline-point-type-cast
Inline type cast method for PG points
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/cast.rb | 7 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rb | 5 |
2 files changed, 4 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb index 0cbedb0987..f7bad20f00 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb @@ -6,13 +6,6 @@ module ActiveRecord "(#{point[0]},#{point[1]})" end - def string_to_point(string) # :nodoc: - if string[0] == '(' && string[-1] == ')' - string = string[1...-1] - end - string.split(',').map{ |v| Float(v) } - end - def string_to_bit(value) # :nodoc: case value when /^0x/i diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rb index 2769a8d3b4..f9531ddee3 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rb @@ -5,7 +5,10 @@ module ActiveRecord class Point < Type::String def type_cast(value) if ::String === value - ConnectionAdapters::PostgreSQLColumn.string_to_point value + if value[0] == '(' && value[-1] == ')' + value = value[1...-1] + end + value.split(',').map{ |v| Float(v) } else value end |