Skip to content

Commit

Permalink
updates from other projects
Browse files Browse the repository at this point in the history
  • Loading branch information
klahnakoski committed Mar 18, 2024
1 parent 88ccdee commit 0bb7929
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions mo_sqlite/transacfion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#
from dataclasses import is_dataclass, fields

from mo_dots import unwraplist, Data, is_missing, dict_to_data
from mo_dots import unwraplist, Data, is_missing, dict_to_data, from_data, leaves_to_data
from mo_future import allocate_lock as _allocate_lock
from mo_json import to_jx_type, union_type
from mo_logs import Except, logger
from mo_logs.exceptions import get_stacktrace
from mo_sql import sql_iso
from mo_sql.utils import untype_field, sql_type_key_to_json_type
from mo_sql.utils import untype_field, sql_type_key_to_json_type, GUID, UID
from mo_sqlite.utils import CommandItem, FORMAT_COMMAND, ROLLBACK, COMMIT, quote_column
from mo_threads import Lock

Expand Down Expand Up @@ -105,16 +105,23 @@ def query(
return result
# REMOVE TYPING
clean_header, jx_type = zip(*(
(name, name+to_jx_type(json_type))
(name, name+to_jx_type(json_type) if name not in (GUID, UID) else None)
for h in result.header
for name, json_type in [untype_field(h)]
))
jx_type = union_type(*jx_type)
jx_type = union_type(*(t for t in jx_type if t))
if format == "list":
clean_data = []
for row in result.data:
clean_row = Data()
for h, c in zip(clean_header, row):
if h not in (GUID, UID):
clean_row |= leaves_to_data({h:c})
clean_data.append(from_data(clean_row))
return dict_to_data({
"meta": {"format": "list"},
"type": jx_type,
"data": [{h: c for h, c in zip(clean_header, row)} for row in result.data]
"data": clean_data
})
else:
# RETURN TABLE
Expand Down

0 comments on commit 0bb7929

Please sign in to comment.