Opened 8 years ago

Closed 8 years ago

#27077 closed Cleanup/optimization (fixed)

Simplify calls to is_in_memory_db() in SQLite's DatabaseCreation

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

Description

Currently, the SQLite backend's DatabaseCreation class calls self.connection.is_in_memory_db(database_name) in several spots (in five places to be precise). Here is a link to the class in the source code.

This is a bit confusing because is_in_memory_db() doesn't actually depend on the connection in any way. It's only a function of the database name. (Intuitively, one way to see this is that if you are using a different database name, then you must be using a different connection.)

This ticket is to simplify / clarify this by refactoring out a function that depends only on the database name, as well making the calls inside DatabaseCreation more DRY.

Change History (5)

comment:1 by Chris Jerdonek, 8 years ago

Owner: changed from nobody to Chris Jerdonek
Status: newassigned

comment:2 by Tim Graham, 8 years ago

Looking at the commit that introduced the method, 8c99b7920e8187f98cf4d7dbd9918bd6c6da1238, I think the database name is usually coming from the connection's SETTINGS_DICT though, perhaps with some adjustments by the database backend.

comment:3 by Tim Graham, 8 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Chris Jerdonek, 8 years ago

Has patch: set

I posted a PR for this here.

comment:5 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 3d0a3c5:

Fixed #27077 -- Made SQLite's in-memory database checks DRYer.

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