From 675431dfaaa7fc9fbd89be2602332287489ee04f Mon Sep 17 00:00:00 2001 From: Julien Phalip Date: Sun, 19 Aug 2012 02:17:45 -0700 Subject: [PATCH] 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. --- django/contrib/gis/db/backends/spatialite/creation.py | 1 + .../contrib/gis/db/backends/spatialite/operations.py | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/django/contrib/gis/db/backends/spatialite/creation.py b/django/contrib/gis/db/backends/spatialite/creation.py index d0a5f820332..27332b9b57f 100644 --- a/django/contrib/gis/db/backends/spatialite/creation.py +++ b/django/contrib/gis/db/backends/spatialite/creation.py @@ -30,6 +30,7 @@ class SpatiaLiteCreation(DatabaseCreation): self.connection.close() self.connection.settings_dict["NAME"] = test_database_name + self.connection.ops.confirm_spatial_components_versions() # Need to load the SpatiaLite initialization SQL before running `syncdb`. self.load_spatialite_sql() diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py index 60fe0a80696..80f05ef0762 100644 --- a/django/contrib/gis/db/backends/spatialite/operations.py +++ b/django/contrib/gis/db/backends/spatialite/operations.py @@ -113,6 +113,12 @@ class SpatiaLiteOperations(DatabaseOperations, BaseSpatialOperations): def __init__(self, connection): super(DatabaseOperations, self).__init__(connection) + # Creating the GIS terms dictionary. + gis_terms = ['isnull'] + gis_terms += self.geometry_functions.keys() + self.gis_terms = dict([(term, None) for term in gis_terms]) + + def confirm_spatial_components_versions(self): # Determine the version of the SpatiaLite library. try: vtup = self.spatialite_version_tuple() @@ -129,11 +135,6 @@ class SpatiaLiteOperations(DatabaseOperations, BaseSpatialOperations): 'SQL loaded on this database?' % (self.connection.settings_dict['NAME'], msg)) - # Creating the GIS terms dictionary. - gis_terms = ['isnull'] - gis_terms += list(self.geometry_functions) - self.gis_terms = dict([(term, None) for term in gis_terms]) - if version >= (2, 4, 0): # Spatialite 2.4.0-RC4 added AsGML and AsKML, however both # RC2 (shipped in popular Debian/Ubuntu packages) and RC4