Changes between Initial Version and Version 1 of Ticket #17278, comment 2


Ignore:
Timestamp:
Feb 11, 2012, 1:14:02 PM (13 years ago)
Author:
Ramiro Morales

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #17278, comment 2

    initial v1  
    11This happens because !SpatiaLite backend's !DatabaseOperations tries to query and verify the version of the !SpatiaLite library in its `__init__()` method.
    22
    3 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.
     3This 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 that !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.
    44
    55All this doesn't cause problems with a normal project/application setup because there `settings.DATABASES['whatever']['NAME']` are expected to have valid values.
    66
    7 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.
     7Problem 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 from `django.contrib.gis.db.backends.spatialite.creation` hasn't had a chance to run yet and so the database name hasn't been set to the fallback `':memory:'` value.
    88
    9 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.
     9The 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.
Back to Top