Open serch opened 4 years ago
@serch Could you write a test case for this scenario? It is rather complex.
We need to create some tests for multiple databases scenario to prioritize it
@gurkanindibay I'm really sorry but I can't, I'm swamped atm 🤷♂️
There is an issue when having multiple databases with tables with the same name.
The case I experienced is the following: I have 2 databases, the main postgres database that uses the citus extension, and a smaller sqlite db. There are some tables in both databases that have the same name.
I set up Active Record 6 to work with both databases and I use the multi-tenant extension in the main db. When I try to delete a record in the sqlite db the multi-tenant gem picks the model from the main db (that has a table with the same name) and inserts the tenant clause causing the query to fail.
I believe this comes from the fact that the multi tenant models are stored in a hash indexed by table name https://github.com/citusdata/activerecord-multi-tenant/blob/master/lib/activerecord-multi-tenant/multi_tenant.rb#L27-L30