Skip to content

Commit

Permalink
rm Type#number?
Browse files Browse the repository at this point in the history
This predicate is only used in `query_attribute`, and is relatively easy
to remove without adding a bunch of is a checks.
  • Loading branch information
sgrif committed Feb 8, 2015
1 parent 16629c0 commit 1492e83
Show file tree
Hide file tree
Showing 17 changed files with 1 addition and 29 deletions.
3 changes: 1 addition & 2 deletions activerecord/lib/active_record/attribute_methods/query.rb
Expand Up @@ -15,15 +15,14 @@ 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?
else
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?
Expand Down
4 changes: 0 additions & 4 deletions activerecord/lib/active_record/type/helpers/numeric.rb
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions activerecord/lib/active_record/type/value.rb
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions activerecord/test/cases/adapters/postgresql/array_test.rb
Expand Up @@ -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
Expand Down
Expand Up @@ -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

Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion activerecord/test/cases/adapters/postgresql/citext_test.rb
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions activerecord/test/cases/adapters/postgresql/composite_test.rb
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion activerecord/test/cases/adapters/postgresql/domain_test.rb
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion activerecord/test/cases/adapters/postgresql/enum_test.rb
Expand Up @@ -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

Expand Down
Expand Up @@ -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

Expand Down
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion activerecord/test/cases/adapters/postgresql/hstore_test.rb
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion activerecord/test/cases/adapters/postgresql/json_test.rb
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion activerecord/test/cases/adapters/postgresql/ltree_test.rb
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion activerecord/test/cases/adapters/postgresql/money_test.rb
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions activerecord/test/cases/adapters/postgresql/network_test.rb
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion activerecord/test/cases/adapters/postgresql/uuid_test.rb
Expand Up @@ -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

Expand Down

0 comments on commit 1492e83

Please sign in to comment.