Skip to content
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 ActiveRecordRelation compiler's handling of composite primary keys #1966

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

bitwise-aiden
Copy link
Contributor

Motivation

During ActiveRecordRelation compiler's decorate it generates the wrong method signature of the #find method for records with composite keys. The signature for the method appears to have been updated when multiple values are passed (i.e. array of arrays), but the singular value still shows as T.any(....) when it should be wrapped in an array.

Implementation

I've updated the handling so if #composite_primary_key? is present and returns a truthy value then the value of ids will be updated to be an array of instead. This then works forward so that the value for an array of composite keys is correct too.

Tests

Updated tests to reflect changes.

@bitwise-aiden bitwise-aiden requested a review from a team as a code owner July 21, 2024 01:26
Copy link
Member

@paracycle paracycle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good catch!

@paracycle paracycle merged commit 75c89e3 into main Jul 22, 2024
31 of 32 checks passed
@paracycle paracycle deleted the ba-fix-arr-composite-key branch July 22, 2024 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants