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
73fbf1ee
Commit
73fbf1ee
authored
3 years ago
by
Bastien Abadie
Browse files
Options
Downloads
Patches
Plain Diff
Support dict & list through json
parent
97f85431
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex/documents/export/__init__.py
+12
-5
12 additions, 5 deletions
arkindex/documents/export/__init__.py
with
12 additions
and
5 deletions
arkindex/documents/export/__init__.py
+
12
−
5
View file @
73fbf1ee
import
json
import
logging
import
sqlite3
import
tempfile
...
...
@@ -50,13 +51,19 @@ def save_sqlite(rows, table, cursor):
"""
Write a chunk of rows into an SQLite table
"""
def
_serialize
(
value
):
# Serialize UUID as string
if
isinstance
(
value
,
uuid
.
UUID
):
return
str
(
value
)
# Serialize list and dicts as json
if
isinstance
(
value
,
(
list
,
dict
)):
return
json
.
dumps
(
value
)
return
value
# Serialize UUID and lists as strings
rows
=
[
[
str
(
value
)
if
isinstance
(
value
,
(
uuid
.
UUID
,
list
))
else
value
for
value
in
row
]
list
(
map
(
_serialize
,
row
))
for
row
in
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