Opened 8 years ago

Closed 8 years ago

#10459 closed (fixed)

Database connections should know their own settings

Reported by: Alex Gaynor Owned by: Alex Gaynor
Component: Database layer (models, ORM) Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

Description

This makes both logical sense and it makes multidb way easier.

Attachments (1)

diff.diff (18.8 KB) - added by Alex Gaynor 8 years ago.
Hits this in every place(I think) but doesn't resolve issues with the test database, that neesd thought

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by Alex Gaynor

Attachment: diff.diff added

Hits this in every place(I think) but doesn't resolve issues with the test database, that neesd thought

comment:1 Changed 8 years ago by Alex Gaynor

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

comment:2 Changed 8 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [10026]) Fixed #10459 -- Refactored the internals of database connection objects so that connections know their own settings and pass around settings as dictionaries instead of passing around the Django settings module itself. This will make it easier for multiple database support. Thanks to Alex Gaynor for the initial patch.

This is backwards-compatible but will likely break third-party database backends. Specific API changes are:

  • BaseDatabaseWrapper.init() now takes a settings_dict instead of a settings module. It's called settings_dict to disambiguate, and for easy grepability. This should be a dictionary containing DATABASE_NAME, etc.
  • BaseDatabaseWrapper has a settings_dict attribute instead of an options attribute. BaseDatabaseWrapper.options is now BaseDatabaseWrapperDATABASE_OPTIONS?
  • BaseDatabaseWrapper._cursor() no longer takes a settings argument.
  • BaseDatabaseClient.init() now takes a connection argument (a DatabaseWrapper instance) instead of no arguments.
Note: See TracTickets for help on using tickets.
Back to Top