提交 1492e83e 编写于 作者: S Sean Griffin

rm `Type#number?`

This predicate is only used in `query_attribute`, and is relatively easy
to remove without adding a bunch of is a checks.
上级 16629c09
......@@ -15,7 +15,6 @@ def query_attribute(attr_name)
when false, nil then false
else
column = self.class.columns_hash[attr_name]
type = self.class.type_for_attribute(attr_name)
if column.nil?
if Numeric === value || value !~ /[^0-9]/
!value.to_i.zero?
......@@ -23,7 +22,7 @@ def query_attribute(attr_name)
return false if ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(value)
!value.blank?
end
elsif type.number?
elsif value.respond_to?(:zero?)
!value.zero?
else
!value.blank?
......
......@@ -2,10 +2,6 @@ module ActiveRecord
module Type
module Helpers
module Numeric # :nodoc:
def number?
true
end
def type_cast(value)
value = case value
when true then 1
......
......@@ -52,10 +52,6 @@ def type_cast_for_schema(value) # :nodoc:
# These predicates are not documented, as I need to look further into
# their use, and see if they can be removed entirely.
def number? # :nodoc:
false
end
def binary? # :nodoc:
false
end
......
......@@ -36,14 +36,12 @@ def test_column
assert_equal :string, @column.type
assert_equal "character varying", @column.sql_type
assert @column.array?
assert_not @type.number?
assert_not @type.binary?
ratings_column = PgArray.columns_hash['ratings']
assert_equal :integer, ratings_column.type
type = PgArray.type_for_attribute("ratings")
assert ratings_column.array?
assert_not type.number?
end
def test_default
......
......@@ -30,7 +30,6 @@ def test_bit_string_column
assert_not column.array?
type = PostgresqlBitString.type_for_attribute("a_bit")
assert_not type.number?
assert_not type.binary?
end
......@@ -41,7 +40,6 @@ def test_bit_string_varying_column
assert_not column.array?
type = PostgresqlBitString.type_for_attribute("a_bit_varying")
assert_not type.number?
assert_not type.binary?
end
......
......@@ -34,7 +34,6 @@ def test_column
assert_not column.array?
type = Citext.type_for_attribute('cival')
assert_not type.number?
assert_not type.binary?
end
......
......@@ -52,7 +52,6 @@ def test_column
assert_not column.array?
type = PostgresqlComposite.type_for_attribute("address")
assert_not type.number?
assert_not type.binary?
end
......@@ -115,7 +114,6 @@ def test_column
assert_not column.array?
type = PostgresqlComposite.type_for_attribute("address")
assert_not type.number?
assert_not type.binary?
end
......
......@@ -31,7 +31,6 @@ def test_column
assert_not column.array?
type = PostgresqlDomain.type_for_attribute("price")
assert type.number?
assert_not type.binary?
end
......
......@@ -33,7 +33,6 @@ def test_column
assert_not column.array?
type = PostgresqlEnum.type_for_attribute("current_mood")
assert_not type.number?
assert_not type.binary?
end
......
......@@ -23,7 +23,6 @@ def test_tsvector_column
assert_not column.array?
type = Tsvector.type_for_attribute("text_vector")
assert_not type.number?
assert_not type.binary?
end
......
......@@ -28,7 +28,6 @@ def test_column
assert_not column.array?
type = PostgresqlPoint.type_for_attribute("x")
assert_not type.number?
assert_not type.binary?
end
......
......@@ -56,7 +56,6 @@ def test_column
assert_equal "hstore", @column.sql_type
assert_not @column.array?
assert_not @type.number?
assert_not @type.binary?
end
......
......@@ -36,7 +36,6 @@ def test_column
assert_not column.array?
type = JsonDataType.type_for_attribute("payload")
assert_not type.number?
assert_not type.binary?
end
......
......@@ -32,7 +32,6 @@ def test_column
assert_not column.array?
type = Ltree.type_for_attribute('path')
assert_not type.number?
assert_not type.binary?
end
......
......@@ -27,7 +27,6 @@ def test_column
assert_not column.array?
type = PostgresqlMoney.type_for_attribute("wealth")
assert type.number?
assert_not type.binary?
end
......
......@@ -25,7 +25,6 @@ def test_cidr_column
assert_not column.array?
type = PostgresqlNetworkAddress.type_for_attribute("cidr_address")
assert_not type.number?
assert_not type.binary?
end
......@@ -36,7 +35,6 @@ def test_inet_column
assert_not column.array?
type = PostgresqlNetworkAddress.type_for_attribute("inet_address")
assert_not type.number?
assert_not type.binary?
end
......@@ -47,7 +45,6 @@ def test_macaddr_column
assert_not column.array?
type = PostgresqlNetworkAddress.type_for_attribute("mac_address")
assert_not type.number?
assert_not type.binary?
end
......
......@@ -51,7 +51,6 @@ def test_data_type_of_uuid_types
assert_not column.array?
type = UUIDType.type_for_attribute("guid")
assert_not type.number?
assert_not type.binary?
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册