Opened 13 years ago

Closed 12 years ago

#17278 closed Cleanup/optimization (fixed)

Unlike sqlite, spatialite requires NAME to be set to run the tests

Reported by: Aymeric Augustin Owned by: nobody
Component: GIS Version:
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

Attachments (2)

17278-1.diff (2.0 KB ) - added by Ramiro Morales 13 years ago.
17278-spatialite-settings.diff (2.1 KB ) - added by Julien Phalip 12 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by Aymeric Augustin, 13 years ago

Triage Stage: UnreviewedAccepted

by Ramiro Morales, 13 years ago

Attachment: 17278-1.diff added

comment:2 by Ramiro Morales, 13 years ago

Has patch: set

This happens because SpatiaLite backend's DatabaseOperations tries to query and verify the version of the SpatiaLite library in its __init__() method.

This must be done with a SELECT query (hence, a cursor and a connection to the database are needed). For this, it creates disposable connection+cursor well before DatabaseWrapper creates the main, 'official' connection (remember DatabaseOperations instance self.ops is instantiated in DatabaseWrapper.__init__(). This works because, even when the interface is a SELECT SQL query, no actual database is needed to query for the SpatiaLite library version.

All this doesn't cause problems with a normal project/application setup because there settings.DATABASES['whatever']['NAME'] are expected to have valid values.

Problem occurs with the test database setup with no settings.DATABASES['whatever']['NAME'] because in that scenario, when DatabaseWrapper.__init__() gets executed, the test DB creation machinery hasn't had a chance to run yet and so the database name hasn't been set to the fallback ':memory:' value.

The attached patch moves the SpatiaLite version querying/checking tasks to a separate internal method and inserts a call to it right after the connection to the database and SpatiaLite initialization have been performed.

Version 0, edited 13 years ago by Ramiro Morales (next)

comment:3 by Claude Paroz, 13 years ago

Triage Stage: AcceptedReady for checkin

Looks good

by Julien Phalip, 12 years ago

comment:4 by Julien Phalip, 12 years ago

Triage Stage: Ready for checkinAccepted

I've updated the patch to avoid a problem with the 'spatial_version' variable not being set at the right time.

comment:5 by Julien Phalip <jphalip@…>, 12 years ago

Resolution: fixed
Status: newclosed

In [675431dfaaa7fc9fbd89be2602332287489ee04f]:

Fixed #17278 -- Enabled the spatialite GIS tests to run without having to specify a database name in the settings. Thanks to Aymeric for the report and to Ramiro for the initial patch.

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