From b59c71cb0076727b1a62e9838148ee6bf9ceb5ee Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Mon, 8 Aug 2016 09:40:34 -0700 Subject: [PATCH] Extract datomish.db.debug from test code, in order to use it during development. --- src/datomish/db/debug.cljc | 59 ++++++++++++++++++++++++++++++++++++++ test/datomish/db_test.cljc | 39 +------------------------ 2 files changed, 60 insertions(+), 38 deletions(-) create mode 100644 src/datomish/db/debug.cljc diff --git a/src/datomish/db/debug.cljc b/src/datomish/db/debug.cljc new file mode 100644 index 00000000..09145048 --- /dev/null +++ b/src/datomish/db/debug.cljc @@ -0,0 +1,59 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. + +(ns datomish.db.debug + #?(:cljs + (:require-macros + [datomish.pair-chan :refer [go-pair !]]]) + #?@(:cljs [[datomish.pair-chan] + [cljs.core.async :as a :refer [chan !]]])) + #?(:clj + (:import + [datomish.datom Datom]))) + +(defn > + (s/all-rows (:sqlite-connection db) ["SELECT e, a, v, tx FROM datoms WHERE tx > ?" tx]) + (> + (s/all-rows (:sqlite-connection db) ["SELECT a, v FROM datoms WHERE e = ?" eid]) + (> + (s/all-rows (:sqlite-connection db) ["SELECT e, a, v, tx, added FROM transactions WHERE tx > ? ORDER BY tx ASC, e, a, v, added" tx]) + (> + (s/all-rows (:sqlite-connection db) ["SELECT rowid, text FROM fulltext_values"]) + (> - (s/all-rows (:sqlite-connection db) ["SELECT e, a, v, tx FROM datoms WHERE tx > ?" tx]) - (> - (s/all-rows (:sqlite-connection db) ["SELECT a, v FROM datoms WHERE e = ?" eid]) - (> - (s/all-rows (:sqlite-connection db) ["SELECT e, a, v, tx, added FROM transactions WHERE tx > ? ORDER BY tx ASC, e, a, v, added" tx]) - (> - (s/all-rows (:sqlite-connection db) ["SELECT rowid, text FROM fulltext_values"]) - (