Follow-up: don't accept schema when creating DB.
This schema was already ignored.
This commit is contained in:
parent
52af06ce28
commit
73b155cfdc
2 changed files with 69 additions and 72 deletions
|
@ -446,10 +446,7 @@
|
||||||
(declare <with-internal)
|
(declare <with-internal)
|
||||||
|
|
||||||
(defn <db-with-sqlite-connection
|
(defn <db-with-sqlite-connection
|
||||||
([sqlite-connection]
|
[sqlite-connection]
|
||||||
(<db-with-sqlite-connection sqlite-connection {}))
|
|
||||||
|
|
||||||
([sqlite-connection schema]
|
|
||||||
(go-pair
|
(go-pair
|
||||||
(when-not (= sqlite-schema/current-version (<? (sqlite-schema/<ensure-current-version sqlite-connection)))
|
(when-not (= sqlite-schema/current-version (<? (sqlite-schema/<ensure-current-version sqlite-connection)))
|
||||||
(raise "Could not ensure current SQLite schema version."))
|
(raise "Could not ensure current SQLite schema version."))
|
||||||
|
@ -502,7 +499,7 @@
|
||||||
:idents idents
|
:idents idents
|
||||||
:symbolic-schema symbolic-schema
|
:symbolic-schema symbolic-schema
|
||||||
:schema (ds/schema (into {} (map (fn [[k v]] [(k idents) v]) symbolic-schema))) ;; TODO: fail if ident missing.
|
:schema (ds/schema (into {} (map (fn [[k v]] [(k idents) v]) symbolic-schema))) ;; TODO: fail if ident missing.
|
||||||
:current-tx (inc current-tx)}))))))
|
:current-tx (inc current-tx)})))))
|
||||||
|
|
||||||
(defn connection-with-db [db]
|
(defn connection-with-db [db]
|
||||||
(map->Connection {:current-db (atom db)}))
|
(map->Connection {:current-db (atom db)}))
|
||||||
|
|
|
@ -123,7 +123,7 @@
|
||||||
(deftest-async test-add-one
|
(deftest-async test-add-one
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)]
|
conn (dm/connection-with-db db)]
|
||||||
(try
|
(try
|
||||||
(let [{tx0 :tx} (<? (dm/<transact! conn test-schema))]
|
(let [{tx0 :tx} (<? (dm/<transact! conn test-schema))]
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
(deftest-async test-add-two
|
(deftest-async test-add-two
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)]
|
conn (dm/connection-with-db db)]
|
||||||
(try
|
(try
|
||||||
(let [{tx0 :tx} (<? (dm/<transact! conn test-schema))
|
(let [{tx0 :tx} (<? (dm/<transact! conn test-schema))
|
||||||
|
@ -169,7 +169,7 @@
|
||||||
(deftest-async test-retract
|
(deftest-async test-retract
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)]
|
conn (dm/connection-with-db db)]
|
||||||
(try
|
(try
|
||||||
(let [{tx0 :tx} (<? (dm/<transact! conn test-schema))
|
(let [{tx0 :tx} (<? (dm/<transact! conn test-schema))
|
||||||
|
@ -188,7 +188,7 @@
|
||||||
(deftest-async test-id-literal-1
|
(deftest-async test-id-literal-1
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)]
|
conn (dm/connection-with-db db)]
|
||||||
(try
|
(try
|
||||||
(let [tx0 (:tx (<? (dm/<transact! conn test-schema)))
|
(let [tx0 (:tx (<? (dm/<transact! conn test-schema)))
|
||||||
|
@ -214,7 +214,7 @@
|
||||||
(deftest-async test-unique
|
(deftest-async test-unique
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)]
|
conn (dm/connection-with-db db)]
|
||||||
(try
|
(try
|
||||||
(let [tx0 (:tx (<? (dm/<transact! conn test-schema)))]
|
(let [tx0 (:tx (<? (dm/<transact! conn test-schema)))]
|
||||||
|
@ -236,7 +236,7 @@
|
||||||
(deftest-async test-valueType-keyword
|
(deftest-async test-valueType-keyword
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)]
|
conn (dm/connection-with-db db)]
|
||||||
(try
|
(try
|
||||||
(let [tx0 (:tx (<? (dm/<transact! conn [{:db/id (dm/id-literal :db.part/user -1)
|
(let [tx0 (:tx (<? (dm/<transact! conn [{:db/id (dm/id-literal :db.part/user -1)
|
||||||
|
@ -271,7 +271,7 @@
|
||||||
(deftest-async test-vector-upsert
|
(deftest-async test-vector-upsert
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)
|
conn (dm/connection-with-db db)
|
||||||
tempids (fn [tx] (into {} (map (juxt (comp :idx first) second) (:tempids tx))))]
|
tempids (fn [tx] (into {} (map (juxt (comp :idx first) second) (:tempids tx))))]
|
||||||
(try
|
(try
|
||||||
|
@ -309,7 +309,7 @@
|
||||||
(deftest-async test-map-upsert
|
(deftest-async test-map-upsert
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)
|
conn (dm/connection-with-db db)
|
||||||
tempids (fn [tx] (into {} (map (juxt (comp :idx first) second) (:tempids tx))))]
|
tempids (fn [tx] (into {} (map (juxt (comp :idx first) second) (:tempids tx))))]
|
||||||
(try
|
(try
|
||||||
|
@ -363,7 +363,7 @@
|
||||||
(deftest-async test-map-upsert-conflicts
|
(deftest-async test-map-upsert-conflicts
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)
|
conn (dm/connection-with-db db)
|
||||||
tempids (fn [tx] (into {} (map (juxt (comp :idx first) second) (:tempids tx))))]
|
tempids (fn [tx] (into {} (map (juxt (comp :idx first) second) (:tempids tx))))]
|
||||||
(try
|
(try
|
||||||
|
@ -401,7 +401,7 @@
|
||||||
(deftest-async test-add-ident
|
(deftest-async test-add-ident
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)]
|
conn (dm/connection-with-db db)]
|
||||||
(try
|
(try
|
||||||
(let [report (<? (dm/<transact! conn [[:db/add (dm/id-literal :db.part/db -1) :db/ident :test/ident]]))
|
(let [report (<? (dm/<transact! conn [[:db/add (dm/id-literal :db.part/db -1) :db/ident :test/ident]]))
|
||||||
|
@ -429,7 +429,7 @@
|
||||||
(deftest-async test-add-schema
|
(deftest-async test-add-schema
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)]
|
conn (dm/connection-with-db db)]
|
||||||
(try
|
(try
|
||||||
(let [es [[:db/add :db.part/db :db.install/attribute (dm/id-literal :db.part/db -1)]
|
(let [es [[:db/add :db.part/db :db.install/attribute (dm/id-literal :db.part/db -1)]
|
||||||
|
@ -461,7 +461,7 @@
|
||||||
(deftest-async test-fulltext
|
(deftest-async test-fulltext
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)
|
conn (dm/connection-with-db db)
|
||||||
schema [{:db/id (dm/id-literal :db.part/db -1)
|
schema [{:db/id (dm/id-literal :db.part/db -1)
|
||||||
:db/ident :test/fulltext
|
:db/ident :test/fulltext
|
||||||
|
@ -535,7 +535,7 @@
|
||||||
(deftest-async test-txInstant
|
(deftest-async test-txInstant
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)
|
conn (dm/connection-with-db db)
|
||||||
{tx0 :tx} (<? (dm/<transact! conn test-schema))]
|
{tx0 :tx} (<? (dm/<transact! conn test-schema))]
|
||||||
(try
|
(try
|
||||||
|
@ -571,7 +571,7 @@
|
||||||
(deftest-async test-no-tx
|
(deftest-async test-no-tx
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)
|
conn (dm/connection-with-db db)
|
||||||
{tx0 :tx} (<? (dm/<transact! conn test-schema))]
|
{tx0 :tx} (<? (dm/<transact! conn test-schema))]
|
||||||
(try
|
(try
|
||||||
|
@ -586,7 +586,7 @@
|
||||||
(deftest-async test-explode-sequences
|
(deftest-async test-explode-sequences
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)
|
conn (dm/connection-with-db db)
|
||||||
{tx0 :tx} (<? (dm/<transact! conn test-schema))]
|
{tx0 :tx} (<? (dm/<transact! conn test-schema))]
|
||||||
(try
|
(try
|
||||||
|
@ -615,7 +615,7 @@
|
||||||
(deftest-async test-explode-maps
|
(deftest-async test-explode-maps
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)
|
conn (dm/connection-with-db db)
|
||||||
{tx0 :tx} (<? (dm/<transact! conn test-schema))]
|
{tx0 :tx} (<? (dm/<transact! conn test-schema))]
|
||||||
(try
|
(try
|
||||||
|
@ -650,7 +650,7 @@
|
||||||
(deftest-async test-explode-reverse-refs
|
(deftest-async test-explode-reverse-refs
|
||||||
(with-tempfile [t (tempfile)]
|
(with-tempfile [t (tempfile)]
|
||||||
(let [c (<? (s/<sqlite-connection t))
|
(let [c (<? (s/<sqlite-connection t))
|
||||||
db (<? (dm/<db-with-sqlite-connection c test-schema))
|
db (<? (dm/<db-with-sqlite-connection c))
|
||||||
conn (dm/connection-with-db db)
|
conn (dm/connection-with-db db)
|
||||||
{tx0 :tx} (<? (dm/<transact! conn test-schema))]
|
{tx0 :tx} (<? (dm/<transact! conn test-schema))]
|
||||||
(try
|
(try
|
||||||
|
|
Loading…
Reference in a new issue