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

Ensure that ids_writer and ids_reader is working for CPK #47925

Conversation

eileencodes
Copy link
Member

This fixes ids_writer so that it can handle a composite primary key. Using a CPK model associated with a non-CPK model was working correctly (which I added a test for). Using a CPK model associated with another CPK model was not working correctly. It now takes it into account to write the correct ids.

While working on ids_reader I found that pluck is not working for CPK because it's passing an array of attributes and that's not supported by disallow_raw_sql!. I chose to call flatten in pluck but not conditionally because this seems like it could be a problem elsewhere as well. This fixes pluck by CPK overall and fixes a test in the calculations test file.

cc/ @nvasilevski @paarthmadan

This fixes `ids_writer` so that it can handle a composite primary key.
Using a CPK model associated with a non-CPK model was working correctly
(which I added a test for). Using a CPK model associated with another
CPK model was not working correctly. It now takes it into account to
write the correct ids.

While working on `ids_reader` I found that `pluck` is not working for
CPK because it's passing an array of attributes and that's not supported
by `disallow_raw_sql!`. I chose to call `flatten` in `pluck` but not
conditionally because this seems like it could be a problem elsewhere as
well. This fixes pluck by CPK overall and fixes a test in the
calculations test file.
@eileencodes eileencodes merged commit 3859037 into rails:main Apr 12, 2023
@eileencodes eileencodes deleted the ensure-ids_writer-and-ids_reader-accomodate-cpk branch April 12, 2023 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant