citusdata / citusdata/activerecord-multi-tenant
Auto Insert tenant_id Problem when filtering with ActiveRecord asociation
- Dominant language
- Ruby
- Stars
- 759
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Description
I have activerecord-multi-tenant with following code in Gemfile.
so that I have to use it with Rails7.2
```
gem 'activerecord-multi-tenant', git: 'https://github.com/citusdata/activerecord-multi-tenant.git', ref: '0ac43aa98334a29ed3e5b33e0bcc5ee281f97254'
```
but in this version activerecord relation like following does not work propery.
```ruby
class Hoge < ApplicationRecord
multi_tenant :tenant
belongs_to :fuga
belongs_to :tenant
end
```
```ruby
class FishType < ApplicationRecord
multi_tenant :tenant
belongs_to :tenant
has_many :hoges
end
```
with these association, in MultiTenant.without scope, I got following result
```
[5] pry(main)> Hoge.first.fuga
Fuga Load (2.8ms) SELECT "fugas".* FROM "fugas" WHERE "fugas"."tenant_id" = 1 AND "fugas"."id" = $1 LIMIT $2 [["id", 10605], ["LIMIT", 1]]
=> nil
```
expected result i guess
```
[5] pry(main)> Hoge.first.fuga
SELECT "fugas".* FROM "fugas" WHERE "fugas"."id" = $1 LIMIT $2 [["id", 101], ["LIMIT", 1]
```
I would like to filter fugas without tenant_id clause.
In Rails6.1.7 and activerecord-multi-tenant(1.2.0), I can get expected result
How can I solve this problem?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.