Skip to content

Counter caches for associations with non-primary keys do not work. increment_counters only takes a primary key #22602

@amalagaura

Description

@amalagaura

Counter caches for associations with string keys have issues in at least 4.1. In 4.2 we noticed it because they throw exceptions when they try to use the string key to lookup the record on its primary key. This causes out of range exceptions if we have large numbers as string keys. Linked are test cases to reproduce. Throws exceptions in 4.2 and have test case failures in 4.1.

string_keys_and_counter_cache_4-1.rb
string_keys_and_counter_cache_4-2.rb

I tested 4.2.0 - 4.2.5. All with same behavior.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions