mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-02-08 05:58:45 +00:00
MariaDB fix thanks to Google gemini
This commit is contained in:
@@ -11,6 +11,7 @@ from datetime import date, datetime, timezone
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
from django.db import connection
|
||||||
|
|
||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
from troggle.core.models.caves import Cave, Entrance, GetCaveLookup
|
from troggle.core.models.caves import Cave, Entrance, GetCaveLookup
|
||||||
@@ -731,8 +732,7 @@ class LoadingSurvex:
|
|||||||
print(message, file=sys.stderr)
|
print(message, file=sys.stderr)
|
||||||
stash_data_issue(
|
stash_data_issue(
|
||||||
parser="survex",
|
parser="survex",
|
||||||
message=message,
|
message=message
|
||||||
url=None,
|
|
||||||
)
|
)
|
||||||
qms = []
|
qms = []
|
||||||
for blk in self._pending_qm_saves:
|
for blk in self._pending_qm_saves:
|
||||||
@@ -743,11 +743,18 @@ class LoadingSurvex:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
bulk_kwargs = {
|
||||||
|
"update_conflicts": True,
|
||||||
|
"update_fields": ['block', 'cave', 'blockname', 'grade', 'number', 'expoyear'],
|
||||||
|
}
|
||||||
|
|
||||||
|
# MariaDB/MySQL do not support (and don't need) unique_fields here
|
||||||
|
if connection.vendor != 'mysql':
|
||||||
|
bulk_kwargs["unique_fields"] = ['cave', 'blockname', 'grade', 'number', 'expoyear']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
QM.objects.bulk_create(qms,
|
QM.objects.bulk_create(qms, **bulk_kwargs)
|
||||||
update_conflicts=True,
|
|
||||||
unique_fields=['cave', 'blockname', 'grade', 'number', 'expoyear'],
|
|
||||||
update_fields=['block', 'cave', 'blockname', 'grade', 'number', 'expoyear'] )
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
raise
|
raise
|
||||||
|
|||||||
Reference in New Issue
Block a user