Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#12729 closed (fixed)

contrib.auth on seperate db in multi-db setup fails

Reported by: dhageman Owned by: nobody
Component: contrib.auth Version: master
Severity: Keywords: multi-db
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

contrib.auth will break if you put it onto a database by itself. There is a hard coded SQL statement in contrib.auth.backends at line 27 (get_group_permissions) that joins the auth tables with django_content_type. This will obviously cause an error if the django_ tables are not in the same database with the auth_ tables.

Change History (4)

comment:1 Changed 5 years ago by dhageman

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Version changed from 1.1 to SVN

comment:2 Changed 5 years ago by jacob

  • milestone set to 1.2
  • Triage Stage changed from Unreviewed to Accepted

We're probably not going to tackle the "django_* tables on a different db from the auth_* tables" this time around. That requires figuring out foreign keys across databases, which probably is never going to work (think constraints), and hence is the topic of a *much* bigger problem.

For the purposes of this ticket, let's just tackle the fact that the ModelBackend hardcodes the default connection.

comment:3 Changed 5 years ago by russellm

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

(In [12509]) Fixed #12729 -- Replaced a hard-coded SQL statement with an ORM query so that the contrib.auth ModelBackend will work on a routed multi-db setup. Thanks to dhageman for the report.

Historical note: The SQL that was removed predates Django being open sourced.

comment:4 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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