Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
732a3f95
Commit
732a3f95
authored
2 years ago
by
Erwan Rouchet
Committed by
Bastien Abadie
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Handle Decimal values when saving rows to SQLite databases
parent
a6506333
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1798
Handle Decimal values when saving rows to SQLite databases
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+1
-1
1 addition, 1 deletion
.gitlab-ci.yml
arkindex/documents/export/__init__.py
+10
-0
10 additions, 0 deletions
arkindex/documents/export/__init__.py
with
11 additions
and
1 deletion
.gitlab-ci.yml
+
1
−
1
View file @
732a3f95
...
...
@@ -51,7 +51,7 @@ backend-tests:
stage
:
test
services
:
-
name
:
postgis/postgis:1
2
-3.
1
-
name
:
postgis/postgis:1
4
-3.
2
alias
:
postgres
artifacts
:
...
...
This diff is collapsed.
Click to expand it.
arkindex/documents/export/__init__.py
+
10
−
0
View file @
732a3f95
...
...
@@ -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
=
[
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment