Skip to content

Conversation

@serch
Copy link
Contributor

@serch serch commented Dec 8, 2025

Hi all, I'm well aware that this gem is abandoned, yet I'm submitting this PR in case someone runs into the same problem as me and comes here to the PRs section looking for answers.

This upstream PR #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).

@Laykou first noticed this problem https://github.com/citusdata/activerecord-multi-tenant/pull/223/files#r1743665204 and @Amit909Singh mentioned they fixed it in #223 (comment).

In this PR, I cherry-picked his commit Amit909Singh@c08b636 and added tests for the increment and decrement cases.

All tests are passing for Rails/ActiveRecord versions 7.0, 7.1, 7.2, and 8.0.
The tests are failing for 6.0 and 6.1, but I didn't care much since they are old versions.
The tests are also failing for 8.1, I didn't look into it either since I'm still on 7.2.

I ran the tests manually instead of using Github actions, like so:

# 1. Start postgres and citus
docker-compose up -d
# or if you want to specify the citus version
CITUS_VERSION=12.1.6 docker-compose up -d

# 2. Install dependencies for all versions of Rails and ActiveRecord:
bundle exec appraisal install

# 3. Run tests
# run test suite with all versions of Rails and ActiveRecord:
bundle exec appraisal rspec

# or run a specific version of Rails or ActiveRecord:
# (see `Appraisals` file for available versions)
bundle exec appraisal rails-7.2 rspec

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.

2 participants