Opened 9 years ago

Closed 9 years ago

#16240 closed Bug (invalid)

Querying models with foreign keys in multidb doesn't use right DB

Reported by:… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.3
Severity: Normal Keywords: multidb foreignkey
Cc:… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: 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?

Change History (1)

comment:1 Changed 9 years ago by Luke Plant

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top