Commit graph

265 commits

Author SHA1 Message Date
Nick Alexander 38545f6efc Add :tx and :txInstant to TxReport; accept :db/tx in transactor; allow to set :db/txInstant.
The implementation of :db/tx is special and may need to change over
time.  We add it as a special ident, with value the current transaction
entity ID, specified per-transaction.  This works well right now but
introduces some (internal) ordering requirements that may need to be
loosened.
2016-08-04 14:26:20 -07:00
Nick Alexander 417ae1ed92 Allow false; fail if too many components in vector given. 2016-08-04 14:26:20 -07:00
Nick Alexander f25838a1eb Support :db/fulltext true.
Internally, we use SQLite's FTS4 to maintain a fulltext_values table of
unique "text" values.  Fulltext indexed datoms have value v that is the
rowid into fulltext_values.  We manually maintain the map between rowid
and value in the transactor.

For convenience, we expose two views interpolating the real text values
into the datoms structure.
2016-08-04 14:26:20 -07:00
Nick Alexander 13f33a4915 Unify test pattern around "(... -after tx0)". 2016-08-04 14:26:20 -07:00
Nick Alexander 296c9cb436 Bootstrap DB schema; persist and restore schema from materialized views. 2016-08-04 14:26:20 -07:00
Nick Alexander 5d271454ac Don't replace keyword idents if the underlying field is itself :db.type/keyword.
This is necessary to assert new :db/ident datoms.
2016-08-04 14:26:20 -07:00
Nick Alexander a1e3158eac Add some structure and value checking. 2016-08-04 14:26:20 -07:00
Nick Alexander 6a8739bd2f Accept new schema fragments via :db.part/db :db.install/attribute. 2016-08-04 14:26:20 -07:00
Nick Alexander 9497d69b44 Respect :db/unique constraints; test upserts.
This version includes SQLite-level unique indexes; these should never be
needed.  I've included them as a fail-safe while testing; they'll help
us catch errors in the transaction layer above.
2016-08-04 14:26:20 -07:00
Nick Alexander 80742242e2 Fix cljs 2016-08-04 14:26:20 -07:00
Nick Alexander 7a90c43a5a Map valueTypes to SQLite encodings.
In the future, we might add a layer of indirection, hashing values to
avoid duplicating storage, or sorting URLs, or handling fulltext indexed
values differently, or ...
2016-08-04 14:26:20 -07:00
Nick Alexander 43423b7d0a Validate value types. 2016-08-04 14:26:20 -07:00
Nick Alexander bceee3b5fb Re-throw errors in Clojure, for easier debugging. 2016-08-04 14:26:20 -07:00
Nick Alexander 661e7ed123 Allow to add new :db/ident mappings. 2016-08-04 14:26:20 -07:00
Nick Alexander fbd5863921 Resolve lookup-refs. 2016-08-04 14:26:20 -07:00
Nick Alexander baec3815b0 Implement transactions. 2016-08-04 14:26:20 -07:00
Nick Alexander 0c51cb6236 Pre: Catch Throwable, not Exception. 2016-08-04 14:26:20 -07:00
Richard Newman 2c1745fa3b Add notes about necessary SQLite options. 2016-08-04 13:45:38 -07:00
Richard Newman 8a77dcd8f0 Implement simple 'or' clauses. r=nalexander 2016-07-27 17:04:32 -07:00
Richard Newman 1ad67a03eb Add tests and comments for clause ordering. 2016-07-26 11:19:51 -07:00
Richard Newman feaca75a74 Add tests for joins and not-clauses. 2016-07-26 10:51:13 -07:00
Richard Newman 72f7c8e1a3 Fix test-raise. 2016-07-26 10:50:55 -07:00
Richard Newman a5556637e8 Add a table alias function to Source, allowing us to mock alias generation. 2016-07-26 10:50:40 -07:00
Richard Newman 5e1648b05f Remove a duplicate definition of context->sql-string. 2016-07-26 10:50:10 -07:00
Richard Newman 8633efc6be Fix exec-repl to build in cljs. 2016-07-26 10:49:43 -07:00
Richard Newman d9cff5fa3c Hacking on exec-repl. 2016-07-25 17:08:53 -07:00
Richard Newman 42361c1e5e Implement negation, predicates, external scalar bindings, <?q. r=nalexander 2016-07-25 17:08:00 -07:00
Nick Alexander 9ae9a0572b Pass a Context into query. 2016-07-19 10:35:39 -07:00
Nick Alexander f4b9b867a4 Indenting. 2016-07-19 10:35:39 -07:00
Nick Alexander 4262b10f55 Handle empty :where SQL clauses in query. 2016-07-19 10:35:39 -07:00
Nick Alexander 13dc1cc9b6 Take more general raise from DataScript. 2016-07-19 10:35:35 -07:00
Richard Newman 2a31a0c4d4 Fix error in pair-channel->lazy-seq.
Signed-off-by: Richard Newman <rnewman@twinql.com>
2016-07-15 12:37:01 -07:00
Richard Newman e76895ac00 Generalize test code for <?run to work in either environment.
Signed-off-by: Richard Newman <rnewman@twinql.com>
2016-07-15 12:36:46 -07:00
Richard Newman d695554123 Initial work on executing queries. r=nalexander
Signed-off-by: Richard Newman <rnewman@twinql.com>
2016-07-15 09:01:44 -07:00
Richard Newman 437a80a978 Store elements on the context. 2016-07-15 09:01:44 -07:00
Richard Newman 64460f7eef eavt -> datoms.
Signed-off-by: Richard Newman <rnewman@twinql.com>
2016-07-15 09:01:44 -07:00
Richard Newman 6c367616e6 Add while-let.
Signed-off-by: Richard Newman <rnewman@twinql.com>
2016-07-15 08:58:12 -07:00
Nick Alexander bf080ced3c Part 2: Add ISQLiteConnectionFactory and CLJC test that uses it. 2016-07-13 18:19:22 -07:00
Nick Alexander cca5010671 Part 1: Fix testing errors.
Some of these were just typos, but `with-open` was fatally flawed on
CLJS (we couldn't call `.close` at all), and `deftest-async` was hiding
all failures (due to a typo).
2016-07-13 18:19:22 -07:00
Richard Newman ef0454dd43 Depend on promise-sqlite for Node.
Signed-off-by: Richard Newman <rnewman@twinql.com>
2016-07-13 18:16:59 -07:00
Nick Alexander 900e77862e Implement database on top of SQLite connection. r=rnewman
We would prefer to talk about a knowledge base on top of a database, but
all the Datomic and DataScript code (and symbols, like :db/add, etc)
refer to the "database of datoms", so let's roll with that nomenclature
and try to be specific that the persistent storage-layer is SQLite.
This will become more clear when we actually use SQLite's unique
capabilities for text indexing.
2016-07-13 12:37:23 -07:00
Nick Alexander 636b7a7957 Pre: Delete trailing whitespace. 2016-07-13 12:04:29 -07:00
Richard Newman db68a714f6 First pass at translating Datalog queries into SQL. r=nalexander
Signed-off-by: Richard Newman <rnewman@twinql.com>
2016-07-13 09:51:42 -07:00
Richard Newman 75810b924e Use cljsbuild 1.1.3.
Signed-off-by: Richard Newman <rnewman@twinql.com>
2016-07-12 19:06:37 -07:00
Richard Newman 3aac28aa13 Take a dependency on honeysql for building queries.
Signed-off-by: Richard Newman <rnewman@twinql.com>
2016-07-12 19:05:39 -07:00
Richard Newman b3b9982740 Take a dependency on DataScript.
Signed-off-by: Richard Newman <rnewman@twinql.com>
2016-07-12 19:05:18 -07:00
Richard Newman 798e05bd9a Use correct project name in defproject.
Signed-off-by: Richard Newman <rnewman@twinql.com>
2016-07-12 19:04:53 -07:00
Richard Newman 655d361a4c Ignore /out/. 2016-07-12 19:04:53 -07:00
Nick Alexander 724c37466d Add an SQLite connection abstraction. 2016-07-12 13:56:26 -07:00
Nick Alexander d42e2f02a6 Expose with-open to CLJS. 2016-07-12 13:56:26 -07:00