Code

Ticket #17278: 17278-1.diff

File 17278-1.diff, 2.0 KB (added by ramiro, 2 years ago)
Line 
1diff --git a/django/contrib/gis/db/backends/spatialite/base.py b/django/contrib/gis/db/backends/spatialite/base.py
2--- a/django/contrib/gis/db/backends/spatialite/base.py
3+++ b/django/contrib/gis/db/backends/spatialite/base.py
4@@ -59,6 +59,10 @@
5             except Exception, msg:
6                 raise ImproperlyConfigured('Unable to load the SpatiaLite library extension '
7                                            '"%s" because: %s' % (self.spatialite_lib, msg))
8+
9+            # Populate and check spatial stack components versions
10+            self.ops.confirm_spatial_components_versions()
11+
12             return cur
13         else:
14             return self.connection.cursor(factory=SQLiteCursorWrapper)
15diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py
16--- a/django/contrib/gis/db/backends/spatialite/operations.py
17+++ b/django/contrib/gis/db/backends/spatialite/operations.py
18@@ -112,6 +112,12 @@
19     def __init__(self, connection):
20         super(DatabaseOperations, self).__init__(connection)
21 
22+        # Creating the GIS terms dictionary.
23+        gis_terms = ['isnull']
24+        gis_terms += self.geometry_functions.keys()
25+        self.gis_terms = dict([(term, None) for term in gis_terms])
26+
27+    def confirm_spatial_components_versions(self):
28         # Determine the version of the SpatiaLite library.
29         try:
30             vtup = self.spatialite_version_tuple()
31@@ -128,11 +134,6 @@
32                                        'SQL loaded on this database?' %
33                                        (self.connection.settings_dict['NAME'], msg))
34 
35-        # Creating the GIS terms dictionary.
36-        gis_terms = ['isnull']
37-        gis_terms += self.geometry_functions.keys()
38-        self.gis_terms = dict([(term, None) for term in gis_terms])
39-
40         if version >= (2, 4, 0):
41             # Spatialite 2.4.0-RC4 added AsGML and AsKML, however both
42             # RC2 (shipped in popular Debian/Ubuntu packages) and RC4