Review comment: clarity.
This commit is contained in:
parent
495e5a737e
commit
6fbd63fed2
3 changed files with 17 additions and 9 deletions
|
@ -260,12 +260,20 @@
|
||||||
chunk))])
|
chunk))])
|
||||||
(partition-all (quot max-sql-vars 11) ops))))
|
(partition-all (quot max-sql-vars 11) ops))))
|
||||||
|
|
||||||
|
(def initial-many-searchid 2000) ; Just to make it more obvious in the DB.
|
||||||
|
(def initial-one-searchid 5000)
|
||||||
|
|
||||||
;;; An FTS insertion happens in two parts.
|
;;; An FTS insertion happens in two parts.
|
||||||
|
;;;
|
||||||
;;; Firstly, we ensure that the fulltext value is present in the store.
|
;;; Firstly, we ensure that the fulltext value is present in the store.
|
||||||
;;; This is effectively an INSERT OR IGNORE… but FTS tables don't support
|
;;; This is effectively an INSERT OR IGNORE… but FTS tables don't support
|
||||||
;;; uniqueness constraints. So we do it through a trigger on a view.
|
;;; uniqueness constraints. So we do it through a trigger on a view.
|
||||||
|
;;;
|
||||||
;;; When we insert the value, we pass with it a searchid. We'll use this
|
;;; When we insert the value, we pass with it a searchid. We'll use this
|
||||||
;;; later when inserting the datom.
|
;;; later when inserting the datom, then we'll throw it away. The FTS table
|
||||||
|
;;; only contains searchids for the duration of the transaction that uses
|
||||||
|
;;; them.
|
||||||
|
;;;
|
||||||
;;; Secondly, we insert a row just like for non-FTS. The only difference
|
;;; Secondly, we insert a row just like for non-FTS. The only difference
|
||||||
;;; is that the value is the rowid into the fulltext_values table.
|
;;; is that the value is the rowid into the fulltext_values table.
|
||||||
(defn- fts-many->queries [ops tx ->SQLite indexing? ref? unique?]
|
(defn- fts-many->queries [ops tx ->SQLite indexing? ref? unique?]
|
||||||
|
@ -293,7 +301,7 @@
|
||||||
(unique? a) ; unique_value
|
(unique? a) ; unique_value
|
||||||
tag]]))
|
tag]]))
|
||||||
ops
|
ops
|
||||||
(range 2000 999999999))
|
(range initial-many-searchid 999999999))
|
||||||
["UPDATE fulltext_values SET searchid = NULL WHERE searchid IS NOT NULL"]))
|
["UPDATE fulltext_values SET searchid = NULL WHERE searchid IS NOT NULL"]))
|
||||||
|
|
||||||
(defn fts-one->queries [ops tx ->SQLite indexing? ref? unique?]
|
(defn fts-one->queries [ops tx ->SQLite indexing? ref? unique?]
|
||||||
|
@ -322,7 +330,7 @@
|
||||||
"(?, ?, (SELECT rowid FROM fulltext_values WHERE searchid = ?), ?, 0, ?)")
|
"(?, ?, (SELECT rowid FROM fulltext_values WHERE searchid = ?), ?, 0, ?)")
|
||||||
e a searchid tx tag]]))
|
e a searchid tx tag]]))
|
||||||
ops
|
ops
|
||||||
(range 3000 999999999))
|
(range initial-one-searchid 999999999))
|
||||||
["UPDATE fulltext_values SET searchid = NULL WHERE searchid IS NOT NULL"]))
|
["UPDATE fulltext_values SET searchid = NULL WHERE searchid IS NOT NULL"]))
|
||||||
|
|
||||||
(defn- -run-queries [conn queries exception-message]
|
(defn- -run-queries [conn queries exception-message]
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
;;
|
;;
|
||||||
;; `from` is a list of [source alias] pairs, suitable for passing to honeysql.
|
;; `from` is a list of [source alias] pairs, suitable for passing to honeysql.
|
||||||
;; `bindings` is a map from var to qualified columns.
|
;; `bindings` is a map from var to qualified columns.
|
||||||
;; `known-types` is a map from var to type keyword.
|
;; `known-types` is a map from var to type keyword (e.g., :db.type/ref)
|
||||||
;; `extracted-types` is a mapping, similar to `bindings`, but used to pull
|
;; `extracted-types` is a mapping, similar to `bindings`, but used to pull
|
||||||
;; type tags out of the store at runtime.
|
;; type tags out of the store at runtime.
|
||||||
;; `wheres` is a list of fragments that can be joined by `:and`.
|
;; `wheres` is a list of fragments that can be joined by `:and`.
|
||||||
|
|
|
@ -181,12 +181,12 @@
|
||||||
{:select [1],
|
{:select [1],
|
||||||
:from [[:all_datoms 'all_datoms1]],
|
:from [[:all_datoms 'all_datoms1]],
|
||||||
:where (list :and
|
:where (list :and
|
||||||
[:= :all_datoms1.e 15]
|
[:= :all_datoms1.e 999]
|
||||||
[:= :datoms0.v :all_datoms1.v])}]])}
|
[:= :datoms0.v :all_datoms1.v])}]])}
|
||||||
(expand
|
(expand
|
||||||
'[:find ?e ?v :in $ :where
|
'[:find ?e ?v :in $ :where
|
||||||
[?e :foo/int ?v]
|
[?e :foo/int ?v]
|
||||||
(not [15 ?a ?v])]
|
(not [999 ?a ?v])]
|
||||||
conn))))
|
conn))))
|
||||||
|
|
||||||
(testing "Type collisions inside :not."
|
(testing "Type collisions inside :not."
|
||||||
|
@ -195,7 +195,7 @@
|
||||||
(expand
|
(expand
|
||||||
'[:find ?e ?v :in $ :where
|
'[:find ?e ?v :in $ :where
|
||||||
[?e :foo/int ?v]
|
[?e :foo/int ?v]
|
||||||
(not [15 :foo/str ?v])]
|
(not [999 :foo/str ?v])]
|
||||||
conn))))
|
conn))))
|
||||||
|
|
||||||
(testing "Type collisions inside :or"
|
(testing "Type collisions inside :or"
|
||||||
|
@ -205,8 +205,8 @@
|
||||||
'[:find ?e ?v :in $ :where
|
'[:find ?e ?v :in $ :where
|
||||||
[?e :foo/int ?v]
|
[?e :foo/int ?v]
|
||||||
(or
|
(or
|
||||||
[15 :foo/str ?v]
|
[999 :foo/str ?v]
|
||||||
[10 :foo/int ?v])]
|
[666 :foo/int ?v])]
|
||||||
conn))))))
|
conn))))))
|
||||||
|
|
||||||
(deftest-db test-type-collision conn
|
(deftest-db test-type-collision conn
|
||||||
|
|
Loading…
Reference in a new issue