Opened 8 years ago

Closed 8 years ago

#13706 closed (worksforme)

dbrouter uses wrong database on many2many addition

Reported by: cheerios Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


DATABASE_ROUTERS = ['dbrouter.BRouter', 'dbrouter.ARouter',]

(form submission) # B
paper = Paper() # B
item.attachments.add(paper)  # writes to A, fails

BRouter routes traffic to database B, Arouter falls back on 'default' database.
All models read/write fine (on both databases), but adding a many2many relation for a table that saves to B (with all FKs in B) won't work unless Arouter's (!) db_to_write() does assert/print model._meta.app_label

Attachments (1)

13706_tests.diff (2.6 KB) - added by Ramiro Morales 8 years ago.
Patch for multi-db tests showing things work as expected

Download all attachments as: .zip

Change History (3)

comment:1 Changed 8 years ago by Tobias McNulty

Please provide a more complete example.

Changed 8 years ago by Ramiro Morales

Attachment: 13706_tests.diff added

Patch for multi-db tests showing things work as expected

comment:2 Changed 8 years ago by Ramiro Morales

Resolution: worksforme
Status: newclosed

Can't reproduce what's been reported here with trunk as of now. Find attached the patch to our regressiontests/multiple_database tests implementing what I understand from the ticket description.

Please reopen only if you can provide a modified patch that shows your use case and error.

Note: See TracTickets for help on using tickets.
Back to Top