Opened 5 years ago

Closed 5 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: UI/UX:

Description

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

(form submission)
item.save() # B
paper = Paper()
paper.save() # 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 5 years ago.
Patch for multi-db tests showing things work as expected

Download all attachments as: .zip

Change History (3)

comment:1 Changed 5 years ago by tobias

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Please provide a more complete example.

Changed 5 years ago by ramiro

Patch for multi-db tests showing things work as expected

comment:2 Changed 5 years ago by ramiro

  • Resolution set to worksforme
  • Status changed from new to closed

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