Querying models with foreign keys in multidb doesn't use right DB
|Reported by:||aviv.by@…||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.3|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I've got a setup with multidb and a router that splits traffic between two connections by tables.
The problem I'm seeing is that, say I've got a Book model that has a foreign key to an Author model, and each one is managed in a different DB connection (as is decided by the router I created), the following query works correctly:
That works as expected since the IDs of author are also present in the Book table, but every other attribute I attempt to access is being fetched from Book's DB instead of Author's DB, which causes broken behavior. For example, this will fetch both objects from the same DB:
Is there some kind of workaround to get this to work as it should?