New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ActiveRecord::Relation#cache_key for loaded empty collection #23080

Merged
merged 1 commit into from Jan 22, 2016

Conversation

Projects
None yet
3 participants
@prathamesh-sonpatki
Member

prathamesh-sonpatki commented Jan 16, 2016

  • Before this patch if we try to find cache_key of a loaded but empty
    collection it used to give error because of trying to call updated_at
    on nil value generated by
    collection.max_by(&timestamp_column).public_send(timestamp_column).
  • This commit fixes above error by checking if size is greater than zero
    or not.

r? @matthewd

Fix ActiveRecord::Relation#cache_key for loaded empty collection
- Before this patch if we try to find cache_key of a loaded but empty
  collection it used to give error because of trying to call `updated_at`
  on `nil` value generated by
  `collection.max_by(&timestamp_column).public_send(timestamp_column)`.
- This commit fixes above error by checking if size is greater than zero
  or not.
@prathamesh-sonpatki

This comment has been minimized.

Member

prathamesh-sonpatki commented Jan 22, 2016

@matthewd Should I combine #23081 in this PR itself?

matthewd added a commit that referenced this pull request Jan 22, 2016

Merge pull request #23080 from prathamesh-sonpatki/fix-cache-key-for-…
…loaded-empty-collection

Fix ActiveRecord::Relation#cache_key for loaded empty collection

@matthewd matthewd merged commit a688c03 into rails:master Jan 22, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@prathamesh-sonpatki prathamesh-sonpatki deleted the prathamesh-sonpatki:fix-cache-key-for-loaded-empty-collection branch Jan 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment