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

Incompatible with Rails 7.2 #256

Open
jerometremblay opened this issue Aug 20, 2024 · 2 comments
Open

Incompatible with Rails 7.2 #256

jerometremblay opened this issue Aug 20, 2024 · 2 comments

Comments

@jerometremblay
Copy link

I had activerecord-multi-tenant referenced in my Gemfile but did not actually use it.

It broke when I updated my application to Rails 7.2.

Removing the gem fixed my application. So there must be some problem with the gem with this latest Rails version.

@kapso
Copy link

kapso commented Sep 2, 2024

Running into same issue, are there any plans for keeping this gem updated. The last release was a year ago.

@Laykou
Copy link
Contributor

Laykou commented Sep 5, 2024

I found out additional issue in Rails 7.2 with counter_cache where this gem overrides the update_all method in #223 which then calls

UPDATE posts SET comments_count = NULL WHERE ...

instead of

UPDATE posts SET comments_count = COALESCE(comments_count, 0) + $1 WHERE ...

at least in Rspecs we could observe this behavior. This is because the Arel::Node::Addition object is being type-casted by the Integer class (in sanitize_sql_for_assignment method) and since it is an object and not a number, it is sanitized to NULL instead of the valid SQL syntax.

I addressed it in this comment https://github.com/citusdata/activerecord-multi-tenant/pull/223/files#r1743665204. Rails distinguishes whether the updates object is a Hash and they have different logic on how to evaluate it in update_all.

I'm not sure if this can be somehow modified too.

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

No branches or pull requests

3 participants