#29461 closed Bug (fixed)
ogrinspect test_time_field failure on SpatiaLite
Reported by: | Tim Graham | Owned by: | nobody |
---|---|---|---|
Component: | GIS | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Claude Paroz | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
On Ubuntu 18.04, I see this test failure:
====================================================================== FAIL: test_time_field (gis_tests.inspectapp.tests.OGRInspectTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/media/sf_django/tests/gis_tests/inspectapp/tests.py", line 137, in test_time_field self.assertIn(' f_decimal = models.DecimalField(max_digits=0, decimal_places=0)', model_def) AssertionError: ' f_decimal = models.DecimalField(max_digits=0, decimal_places=0)' not found in '# This is an auto-generated Django model module created by ogrinspect.\nfrom django.contrib.gis.db import models\n\n\nclass Measurement(models.Model):\n f_decimal = models.CharField(max_length=0)\n f_float = models.CharField(max_length=0)\n f_int = models.IntegerField()\n f_char = models.CharField(max_length=0)\n f_date = models.DateField()\n f_datetime = models.DateTimeField()\n f_time = models.TimeField()\n geom = models.PolygonField()'
Here's a diff that shows the actual results:
-
tests/gis_tests/inspectapp/tests.py
diff --git a/tests/gis_tests/inspectapp/tests.py b/tests/gis_tests/inspectapp/tests.py index 51bb363..c63c841 100644
a b class OGRInspectTest(TestCase): 134 134 )) 135 135 136 136 # The ordering of model fields might vary depending on several factors (version of GDAL, etc.) 137 self.assertIn(' f_decimal = models. DecimalField(max_digits=0, decimal_places=0)', model_def)137 self.assertIn(' f_decimal = models.CharField(max_length=0)', model_def) 138 138 self.assertIn(' f_int = models.IntegerField()', model_def) 139 139 self.assertIn(' f_datetime = models.DateTimeField()', model_def) 140 140 self.assertIn(' f_time = models.TimeField()', model_def) 141 self.assertIn(' f_float = models. FloatField()', model_def)142 self.assertIn(' f_char = models.CharField(max_length= 10)', model_def)141 self.assertIn(' f_float = models.CharField(max_length=0)', model_def) 142 self.assertIn(' f_char = models.CharField(max_length=0)', model_def) 143 143 self.assertIn(' f_date = models.DateField()', model_def) 144 144 145 145 # Some backends may have srid=-1
I'm not sure if the test ever ran on SpatiaLite. On older versions of Ubuntu (16.04) the test is skipped. The original exception that's caught says "Could not open the datasource at "file:memorydb_default?mode=memory&cache=shared"". The behavior changed in GDAL 2.1.0.
Note:
See TracTickets
for help on using tickets.
For the DecimalField failure, we can use
connection.features.can_introspect_decimal_field
like inInspectDBTestCase.test_number_field_types
.For the other failures, I'm almost sure they are limitations of the GDAL SQLite introspection:
My opinion is that we should skip those tests on Spatialite waiting for GDAL introspection progress with this driver.
We could workaround those limitations by resorting to standard SQLite introspection for non-geometry fields, but I'm not sure if it's worth it.