Skip to content

Commit

Permalink
Merge pull request rails#7942 from IPGlider/master
Browse files Browse the repository at this point in the history
Fix typo in inet and cidr saving
  • Loading branch information
rafaelfranca committed Oct 14, 2012
2 parents 4e8cf43 + 6f400da commit ae61c03
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Expand Up @@ -90,7 +90,7 @@ def type_cast(value, column, array_member = false)
else super(value, column)
end
when IPAddr
return super(value, column) unless ['inet','cidr'].includes? column.sql_type
return super(value, column) unless ['inet','cidr'].include? column.sql_type
PostgreSQLColumn.cidr_to_string(value)
else
super(value, column)
Expand Down
13 changes: 13 additions & 0 deletions activerecord/test/cases/adapters/postgresql/quoting_test.rb
@@ -1,4 +1,5 @@
require "cases/helper"
require 'ipaddr'

module ActiveRecord
module ConnectionAdapters
Expand All @@ -20,6 +21,18 @@ def test_type_cast_false
assert_equal 'f', @conn.type_cast(false, c)
end

def test_type_cast_cidr
ip = IPAddr.new('255.0.0.0/8')
c = Column.new(nil, ip, 'cidr')
assert_equal ip, @conn.type_cast(ip, c)
end

def test_type_cast_inet
ip = IPAddr.new('255.1.0.0/8')
c = Column.new(nil, ip, 'inet')
assert_equal ip, @conn.type_cast(ip, c)
end

def test_quote_float_nan
nan = 0.0/0
c = Column.new(nil, 1, 'float')
Expand Down

0 comments on commit ae61c03

Please sign in to comment.