Browse Source

fix: <q console errors

fixes LOG-3059
Tienson Qin 2 years ago
parent
commit
1a07d170c9
1 changed files with 13 additions and 11 deletions
  1. 13 11
      src/main/frontend/db/async/util.cljs

+ 13 - 11
src/main/frontend/db/async/util.cljs

@@ -13,18 +13,20 @@
     (p/let [result (.q sqlite graph (pr-str inputs))]
     (p/let [result (.q sqlite graph (pr-str inputs))]
       (when result
       (when result
         (let [result' (edn/read-string result)]
         (let [result' (edn/read-string result)]
-          (when (seq result')
+          (when (and (seq result') (coll? result'))
             (when-let [conn (db-conn/get-db graph false)]
             (when-let [conn (db-conn/get-db graph false)]
-              (let [tx-data (if (and (coll? result')
-                                     (coll? (first result'))
-                                     (not (map? (first result'))))
-                              (apply concat result')
-                              result')]
-                (try
-                  (d/transact! conn tx-data)
-                  (catch :default e
-                    (js/console.error "<q failed with:" e)
-                    nil)))))
+              (let [tx-data (->>
+                             (if (and (coll? (first result'))
+                                      (not (map? (first result'))))
+                               (apply concat result')
+                               result')
+                             (remove nil?))]
+                (when (every? map? tx-data)
+                  (try
+                    (d/transact! conn tx-data)
+                    (catch :default e
+                      (js/console.error "<q failed with:" e)
+                      nil))))))
           result')))))
           result')))))
 
 
 (defn <pull
 (defn <pull