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

Refactor ExtendedDeterministicQueries to not mutate the arguments #45722

Merged
merged 1 commit into from
Aug 1, 2022

Conversation

casperisfine
Copy link
Contributor

Ref: #41659

Mutating the attributes hash requires to workaround the mutation in find_or_create_by etc.

One extra Hash dup is not big deal.

As discussed in #45720

cc @matthewd @jorgemanrubia

Ref: rails#41659

Mutating the attributes hash requires to workaround the mutation
in `find_or_create_by` etc.

One extra Hash dup is not big deal.
@byroot
Copy link
Member

byroot commented Aug 1, 2022

Merging now since this is blocking #45720, but if there are any concerns please review the PR anyway and I'll address any concerns with this change.

@byroot byroot merged commit c6cbf8f into rails:main Aug 1, 2022
@ghiculescu
Copy link
Member

I know 7.1 is just around the corner, but any chance you could backport this to 7-0-stable @byroot?

Mutating the arguments is a bug IMO.

Here is a test you could add here:

  test "query params are not mutated" do
    b = EncryptedBook.create!(name: "Dune")
    
    props = { name: "Dune", id: b.id }
    p2 = props.dup

    assert_equal "Dune", EncryptedBook.find_by(props).name
    assert_equal p2, props
  end

@byroot
Copy link
Member

byroot commented Sep 12, 2023

If you make a backport PR I'll merge it.

ghiculescu added a commit to ghiculescu/rails that referenced this pull request Sep 12, 2023
byroot added a commit that referenced this pull request Sep 12, 2023
ghiculescu pushed a commit to ghiculescu/rails that referenced this pull request Sep 12, 2023
…-mutation

Refactor ExtendedDeterministicQueries to not mutate the arguments

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
@ghiculescu
Copy link
Member

Thanks. Made one to backport, and one to add a regression test to main.

byroot added a commit that referenced this pull request Sep 12, 2023
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

3 participants