Skip to content

Commit

Permalink
drop primary_key_is_an_integer
Browse files Browse the repository at this point in the history
the casting is determined when creating the field
  • Loading branch information
kbrock committed Jun 20, 2020
1 parent eccb183 commit 5f66c82
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
10 changes: 0 additions & 10 deletions lib/ancestry/class_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,5 @@ def rebuild_depth_cache!
def unscoped_where
yield self.ancestry_base_class.unscope(:where)
end

ANCESTRY_UNCAST_TYPES = [:string, :uuid, :text].freeze

def primary_key_is_an_integer?
if defined?(@primary_key_is_an_integer)
@primary_key_is_an_integer
else
@primary_key_is_an_integer = !ANCESTRY_UNCAST_TYPES.include?(type_for_attribute(primary_key).type)
end
end
end
end
12 changes: 0 additions & 12 deletions test/concerns/has_ancestry_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,4 @@ def test_setup_test_nodes
end
end
end

def test_primary_key_is_an_integer
AncestryTestDatabase.with_model(extra_columns: { string_id: :string }) do |model|
model.primary_key = :string_id

assert !model.primary_key_is_an_integer?
end

AncestryTestDatabase.with_model do |model|
assert model.primary_key_is_an_integer?
end
end
end

0 comments on commit 5f66c82

Please sign in to comment.