diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6b89fb1da8592f34838b69bc0b8b6948fa0d767d..51bdc21217f2395e24a4c0735d1ef42ca8719e76 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -51,7 +51,7 @@ backend-tests: stage: test services: - - name: postgis/postgis:12-3.1 + - name: postgis/postgis:14-3.2 alias: postgres artifacts: diff --git a/arkindex/documents/export/__init__.py b/arkindex/documents/export/__init__.py index 78c8fbfbda2f64f9a5e225a5f12dbd7ce0c1a32f..02ac0cf7156f67fe1e69e78b0e45d03ff4bb362f 100644 --- a/arkindex/documents/export/__init__.py +++ b/arkindex/documents/export/__init__.py @@ -5,6 +5,7 @@ import sqlite3 import tempfile import uuid from datetime import datetime, timezone +from decimal import Decimal from pathlib import Path from django.conf import settings @@ -70,6 +71,15 @@ def save_sqlite(rows, table, cursor): if isinstance(value, (list, dict)): return json.dumps(value) + # Serialize Decimal numbers as regular floats + # We don't care about any loss of precision because SQLite will loose that precision anyway + if isinstance(value, Decimal): + return float(value) + + # Show very explicit error messages if we stumble upon an unexpected type + # https://docs.python.org/3.8/library/sqlite3.html#sqlite-and-python-types + assert value is None or isinstance(value, (int, float, str, bytes)), f'Type {type(value)} is not supported by sqlite3' + return value rows = [