Skip to content

Fixes issues with update_all, increment, and decrement#15

Merged
serch merged 5 commits intomasterfrom
serch/fix-update-all
Dec 8, 2025
Merged

Fixes issues with update_all, increment, and decrement#15
serch merged 5 commits intomasterfrom
serch/fix-update-all

Conversation

@serch
Copy link
Copy Markdown
Member

@serch serch commented Dec 7, 2025

This upstream PR citusdata#223 broke some usages of update_all. Both increment and decrement use update_all.

For example a call to model.decrement!(:counter) generates an UPDATE query with SET "counter" = NULL instead of the correct SET "counter" = COALESCE("counter", 0).

The bug was noticed 7 months after the PR that introduced it was created

https://github.com/citusdata/activerecord-multi-tenant/pull/223/files#r1743665204

the author of the above comment Laykou and another user Amit909Singh discussed the issue (all comments can be seen in the PR citusdata#223) and Amit909Singh mentioned they fixed it in citusdata#223 (comment)

I cherry-picked his commit Amit909Singh@c08b636

and

  • removed rails and activerecord 6.0 and 6.1 from the test suite (tests were failing)
  • added ruby 3.4, rails 8.1, and activerecord 8.1 to the github actions workflow
  • added instructions on how to run the tests locally and brought back the appraisal gemfiles
  • added tests for increment and decrement
  • fixed warnings in the docker-compose file

I also submitted a PR upstream, but the gem is abandoned so I doubt it will ever get merged.
citusdata#282

@serch serch self-assigned this Dec 7, 2025
@serch serch changed the title Serch/fix update all Fix update_all, increment, and decrement Dec 7, 2025
@serch serch changed the title Fix update_all, increment, and decrement Fixes issues with update_all, increment, and decrement Dec 7, 2025
@serch serch marked this pull request as ready for review December 7, 2025 13:33
@serch serch requested a review from a team December 8, 2025 09:47
@serch serch merged commit c0cc30f into master Dec 8, 2025
2 checks passed
@serch serch deleted the serch/fix-update-all branch December 8, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants