Opened 7 years ago
Closed 6 years ago
#29451 closed Cleanup/optimization (fixed)
Add compatibility with MySQL 8
Reported by: | Tim Graham | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Adam Johnson | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
See attached log for some test failures I experienced with MySQL 8.0.11.
It seems there's at least some changes in how regular expression matching works.
Attachments (1)
Change History (21)
by , 7 years ago
Attachment: | mysql-failures.log added |
---|
comment:1 by , 7 years ago
Cc: | added |
---|
comment:2 by , 7 years ago
comment:5 by , 7 years ago
I was investigating this and was surprised to see that REGEXP BINARY '.*'
matched nothing when using MySQL 8. I thought there might be a bug with MySQL but could not find much online other than this cryptic commit entitled Work around REGEXP BINARY not working correctly on MySQL 8 by using REGEXP_LIKE
:
https://github.com/jeremyevans/sequel/commit/ba3ea1c218d10bbab3f2b48039faedd4859865f8
After copying the Oracle regex_lookup
method which does exactly this all tests pass on 8, however the REGEXP_LIKE function does not exist in MySQL 5.6.
comment:6 by , 7 years ago
My brief investigation led to a similar uncertain conclusion. Making the method's operation conditional on the MySQL version is okay with me.
comment:8 by , 7 years ago
Looks good. I see one remaining GIS failure:
====================================================================== FAIL: test_isvalid_lookup (gis_tests.geoapp.tests.GeoLookupTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/media/sf_django/django/test/testcases.py", line 1096, in skip_wrapper return test_func(*args, **kwargs) File "/media/sf_django/tests/gis_tests/geoapp/tests.py", line 308, in test_isvalid_lookup self.assertEqual(State.objects.filter(name='Kansas', poly__isvalid=False).count(), 1) AssertionError: 0 != 1
If you try to run the GIS tests use:
'OPTIONS': { 'init_command': 'SET default_storage_engine=MyISAM', },
in your settings and use runtests.py gis_tests
, otherwise the test suite takes quite a long time.
comment:14 by , 6 years ago
Regarding the test_isvalid_lookup
failure, thankfully it seems that it's not really a failure. A comment in the test says:
# Kansas has adjacent vertices with distance 6.99244813842e-12 # which is smaller than the default Oracle tolerance. # It's invalid on MySQL too.
This doesn't seem to be the case anymore. Skipping that branch, where the failure originates, makes the test pass just fine. I'll prepare a PR now.
comment:15 by , 6 years ago
https://github.com/django/django/pull/10134
I get two other failures locally, but I assume they are to do with my environment:
====================================================================== FAIL: test_raster_transform (gis_tests.gdal_tests.test_raster.GDALRasterTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/tom/PycharmProjects/django/tests/gis_tests/gdal_tests/test_raster.py", line 517, in test_raster_transform self.assertAlmostEqual(target.origin[0], 9124842.791079799) AssertionError: 9124842.791069634 != 9124842.791079799 within 7 places ---------------------------------------------------------------------- ====================================================================== FAIL: test_transform_3d (gis_tests.geos_tests.test_geos.GEOSTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/tom/PycharmProjects/django/tests/gis_tests/geos_tests/test_geos.py", line 1121, in test_transform_3d self.assertEqual(p3d.z, 100) AssertionError: 100.00001595821232 != 100 ----------------------------------------------------------------------
comment:16 by , 6 years ago
Yes, those failures look unrelated to the database engine. Probably related to your GDAL and GEOS versions.
comment:20 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Got a small patch to fix the syntax errors: https://github.com/django/django/pull/10021
Seems you need to quote the column names in mysql 8