From 8617670b4665cff0f0f8f0947900466c9893aaac Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Sun, 13 Jun 2021 21:45:32 +0200
Subject: [PATCH] handle lists

---
 djaosdb/base.py            |  2 +-
 djaosdb/caosdb_client.py   | 10 +++-------
 djaosdb/sql2mongo/query.py |  2 +-
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/djaosdb/base.py b/djaosdb/base.py
index ebdcfeb..3cd97f1 100644
--- a/djaosdb/base.py
+++ b/djaosdb/base.py
@@ -62,7 +62,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
         'GenericObjectIdField': 'objectId',
         'ObjectIdField': 'objectId',
         'EmbeddedField': 'object',
-        'ArrayField': caosdb.LIST,
+        'ArrayField': None,
     }
 
     data_types_suffix = {
diff --git a/djaosdb/caosdb_client.py b/djaosdb/caosdb_client.py
index 789ce21..7360aaf 100644
--- a/djaosdb/caosdb_client.py
+++ b/djaosdb/caosdb_client.py
@@ -1,5 +1,6 @@
 import abc
 import time
+import json
 from logging import getLogger
 from collections import defaultdict
 import caosdb
@@ -213,9 +214,7 @@ class DefaultCaosDBClientDelegate:
                 for p in e.get_properties():
                     row[p.name] = p.value
                     if isinstance(p.value, list):
-                        if len(p.value):
-                            row[p.name] = p.value[0]
-                        else:
+                        if len(p.value) == 0:
                             row[p.name] = None
                 rows.append(row)
             return rows
@@ -225,10 +224,7 @@ class DefaultCaosDBClientDelegate:
             for i in range(len(row)):
                 val = row[i]
                 if isinstance(val, list):
-                    if len(val):
-                        row[i] = val[0]
-                    else:
-                        row[i] = None
+                    row[i] = json.dumps(val)
         return rows
 
     def find(self, record_type, limit=None, sort=None, skip=None, *args, **kwargs):
diff --git a/djaosdb/sql2mongo/query.py b/djaosdb/sql2mongo/query.py
index 5c3d040..44eab4c 100644
--- a/djaosdb/sql2mongo/query.py
+++ b/djaosdb/sql2mongo/query.py
@@ -905,7 +905,7 @@ class Query:
             exe = SQLDecodeError(
                 f'FAILED SQL: {self._sql}\n' 
                 f'Params: {self._params}\n'
-                f'Pymongo error: {e.details}\n'
+                f'CaosDBError: {e.msg}\n'
                 f'Version: {djaosdb.__version__}'
             )
             raise exe from e
-- 
GitLab