diff --git a/src/datomish/db.cljc b/src/datomish/db.cljc index 0e5e49c9..634ec603 100644 --- a/src/datomish/db.cljc +++ b/src/datomish/db.cljc @@ -82,16 +82,15 @@ [db eid] "Returns the keyword associated with an id, or the key itself if passed.") - (current-tx - [db] - "TODO: document this interface.") - (in-transaction! [db chan-fn] "Evaluate the given pair-chan `chan-fn` in an exclusive transaction. If it returns non-nil, commit the transaction; otherwise, rollback the transaction. Returns a pair-chan resolving to the pair-chan returned by `chan-fn`.") + (Context (datoms-source db) nil nil)) @@ -188,14 +190,20 @@ (get (.-ident-map db) eid eid) eid)) - (current-tx - [db] - (inc (:current-tx db))) - (in-transaction! [db chan-fn] (s/in-transaction! (:sqlite-connection db) chan-fn)) + ( + (:sqlite-connection db) + (s/all-rows ["SELECT EXISTS(SELECT 1 FROM transactions LIMIT 1) AS bootstrapped"]) + ( (integer entid), like {:db/ident 0}." @@ -37,14 +34,6 @@ (s/all-rows sqlite-connection)))] (into {} (map (fn [row] [(sqlite-schema/<-SQLite :db.type/keyword (:ident row)) (:entid row)])) rows)))) -(defn (map (keyword attribute -> keyword value)), like @@ -83,10 +72,9 @@ (when-not (= sqlite-schema/current-version (= current-tx 0) - current-tx (max current-tx tx0)] - (when-not bootstrapped + (let [db (db/db sqlite-connection bootstrap/idents bootstrap/symbolic-schema) + bootstrapped? ( (db/db sqlite-connection bootstrap/idents bootstrap/symbolic-schema current-tx) - ;; We use db + ;; We use numeric entid. @@ -293,22 +294,22 @@ allocated-eid (get-in report [:tempids e])] (if (and upserted-eid allocated-eid (not= upserted-eid allocated-eid)) ( report (assoc-in [:db-after] db-after))))) diff --git a/src/datomish/transact/bootstrap.cljc b/src/datomish/transact/bootstrap.cljc index f5e72305..83dd4c8a 100644 --- a/src/datomish/transact/bootstrap.cljc +++ b/src/datomish/transact/bootstrap.cljc @@ -52,8 +52,8 @@ :db/noHistory 13 :db/add 14 :db/retract 15 - :db.part/tx 16 - :db.part/user 17 + :db.part/user 16 + :db.part/tx 17 :db/excise 18 :db.excise/attrs 19 :db.excise/beforeT 20 diff --git a/test/datomish/db_test.cljc b/test/datomish/db_test.cljc index 6be310ff..29b8243a 100644 --- a/test/datomish/db_test.cljc +++ b/test/datomish/db_test.cljc @@ -73,47 +73,46 @@ (