mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix typo in inet and cidr saving
This commit is contained in:
parent
8fb841bdde
commit
6f400dabf7
2 changed files with 14 additions and 1 deletions
|
@ -90,7 +90,7 @@ module ActiveRecord
|
||||||
else super(value, column)
|
else super(value, column)
|
||||||
end
|
end
|
||||||
when IPAddr
|
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)
|
PostgreSQLColumn.cidr_to_string(value)
|
||||||
else
|
else
|
||||||
super(value, column)
|
super(value, column)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require "cases/helper"
|
require "cases/helper"
|
||||||
|
require 'ipaddr'
|
||||||
|
|
||||||
module ActiveRecord
|
module ActiveRecord
|
||||||
module ConnectionAdapters
|
module ConnectionAdapters
|
||||||
|
@ -20,6 +21,18 @@ module ActiveRecord
|
||||||
assert_equal 'f', @conn.type_cast(false, c)
|
assert_equal 'f', @conn.type_cast(false, c)
|
||||||
end
|
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
|
def test_quote_float_nan
|
||||||
nan = 0.0/0
|
nan = 0.0/0
|
||||||
c = Column.new(nil, 1, 'float')
|
c = Column.new(nil, 1, 'float')
|
||||||
|
|
Loading…
Reference in a new issue