Added gis_tests.utils.mariadb hook.

This commit is contained in:
Mariusz Felisiak 2019-10-17 19:20:22 +02:00
parent ef4beafa2c
commit bebf61de11
4 changed files with 8 additions and 7 deletions

View File

@ -12,7 +12,7 @@ from django.db import NotSupportedError, connection
from django.db.models import Sum
from django.test import TestCase, skipUnlessDBFeature
from ..utils import FuncTestMixin, mysql, oracle, postgis, spatialite
from ..utils import FuncTestMixin, mariadb, mysql, oracle, postgis, spatialite
from .models import City, Country, CountryWebMercator, State, Track
@ -85,7 +85,7 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
# WHERE "geoapp_city"."name" = 'Chicago';
# Finally, we set every available keyword.
# MariaDB doesn't limit the number of decimals in bbox.
if mysql and connection.mysql_is_mariadb:
if mariadb:
chicago_json['bbox'] = [-87.650175, 41.850385, -87.650175, 41.850385]
self.assertJSONEqual(
City.objects.annotate(

View File

@ -13,7 +13,8 @@ from django.db import NotSupportedError, connection
from django.test import TestCase, skipUnlessDBFeature
from ..utils import (
mysql, no_oracle, oracle, postgis, skipUnlessGISLookup, spatialite,
mariadb, mysql, no_oracle, oracle, postgis, skipUnlessGISLookup,
spatialite,
)
from .models import (
City, Country, Feature, MinusOneSRID, NonConcreteModel, PennsylvaniaCity,
@ -227,8 +228,7 @@ class GeoLookupTest(TestCase):
def test_disjoint_lookup(self):
"Testing the `disjoint` lookup type."
if (connection.vendor == 'mysql' and not connection.mysql_is_mariadb and
connection.mysql_version < (8, 0, 0)):
if mysql and not mariadb and connection.mysql_version < (8, 0, 0):
raise unittest.SkipTest('MySQL < 8 gives different results.')
ptown = City.objects.get(name='Pueblo')
qs1 = City.objects.filter(point__disjoint=ptown.point)

View File

@ -10,7 +10,7 @@ from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
from django.test.utils import modify_settings
from ..test_data import TEST_DATA
from ..utils import postgis
from ..utils import mariadb, postgis
from .models import AllOGRFields
@ -141,7 +141,7 @@ class OGRInspectTest(SimpleTestCase):
else:
self.assertIn(' f_decimal = models.DecimalField(max_digits=0, decimal_places=0)', model_def)
self.assertIn(' f_int = models.IntegerField()', model_def)
if connection.vendor != 'mysql' or not connection.mysql_is_mariadb:
if not mariadb:
# Probably a bug between GDAL and MariaDB on time fields.
self.assertIn(' f_datetime = models.DateTimeField()', model_def)
self.assertIn(' f_time = models.TimeField()', model_def)

View File

@ -46,6 +46,7 @@ _default_db = settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1]
oracle = _default_db == 'oracle'
postgis = _default_db == 'postgis'
mysql = _default_db == 'mysql'
mariadb = mysql and connection.mysql_is_mariadb
spatialite = _default_db == 'spatialite'
# MySQL spatial indices can't handle NULL geometries.