Commit graph

300 commits

Author SHA1 Message Date
Nick Alexander
e1b1abe2de Pre: clarify comments. 2016-10-11 20:32:35 -07:00
Richard Newman
c36be57018 Expose a 'tempid' function on transaction results, because JS object lookup doesn't work for TempIds. 2016-10-07 20:12:17 -07:00
Richard Newman
5b6000003d Support order-by query option from JS. 2016-10-07 20:12:17 -07:00
Richard Newman
e89544beba Implement all four find specs. Fixes #38. r=nalexander 2016-10-07 11:02:35 -07:00
Richard Newman
021f2be620 Review comment: add comment about cljify. 2016-10-05 14:07:07 -07:00
Richard Newman
61757e271c Review comment: use datomish.api where possible. 2016-10-05 14:06:36 -07:00
Richard Newman
c7d0a8596b Part 2: extend 'cljify' implementation to round-trip records like TempId. 2016-10-05 12:54:26 -07:00
Richard Newman
0b6ac81ed5 Part 1: extend 'db' JS object with more useful methods. 2016-10-05 12:53:57 -07:00
Richard Newman
b777445ebf Sort variable sets to make tests consistent across platforms. 2016-10-04 11:38:14 -07:00
Nick Alexander
3cd64fb4d8 Review comments. 2016-09-30 17:00:27 -07:00
Nick Alexander
611d44fcce Process lookup-refs in batches. Fixes #25.
This uses a common table expression and multiple SQL calls rather than a
temporary table, since transactions with huge numbers of distinct
lookup-refs are likely to be very rare.

We mark lookup-refs with `lookup-ref`, which is a little awkward because
binding `(let [[a v] lookup-ref] ...)` doesn't directly work, but avoids
some ambiguity present in Datomic and DataScript around interpreting
lookup-refs as multiple value lists.  (Which bit the tests in an earlier
version of this patch!)
2016-09-30 16:47:04 -07:00
Nick Alexander
20531c1789 Pre: Don't insert nil tx where it should not be. 2016-09-30 16:47:04 -07:00
Nick Alexander
c46f0eb8ae Part 2: Get rid of {0, 1} -> {2, 3} mapping for added/added0. Fixes #28.
Now that we copying from tx_lookup_before -> tx_lookup_after, we don't
need to avoid duplicating rows.
2016-09-30 16:47:04 -07:00
Nick Alexander
da1250d210 Part 1: Separate tx_lookup into tx_lookup_before and tx_lookup_after. 2016-09-30 16:47:04 -07:00
Richard Newman
a7d6a37cfc Update comment in cc.cljc. 2016-09-29 15:49:30 -07:00
Richard Newman
6ab93208cb Part 2: implement complex 'or' translation. Fixes #57. r=nalexander
We implement sql-projection-for-simple-variable-list to allow us to add
a projection to subqueries.
2016-09-29 15:46:15 -07:00
Richard Newman
b9b9c37dfa Part 1: pass in :select when creating a partial subquery from a CC. 2016-09-29 15:44:16 -07:00
Richard Newman
1296b8090f Allow sets of attributes in fulltext expressions. Fixes #54. r=nalexander 2016-09-26 16:34:37 -07:00
Richard Newman
9587311412 Include deps.cljs giving externs for Node.js consumers; normalize build output.
cljsbuild using leiningen projects that depend on Datomish will
automatically include the externs.
2016-09-22 16:24:37 -07:00
Richard Newman
d0a04a5e56 Review comment: extracted shared go-promise. 2016-09-22 16:24:37 -07:00
Richard Newman
17d7eaec7b Add a babelified test file, Webpack the add-on, and make the JS API work.
We concatenate a simple setTimeout monkeypatch onto the add-on itself.
2016-09-22 15:59:15 -07:00
Richard Newman
360f7622e8 Add handling of simple schemas. Fixes #53. 2016-09-22 15:59:15 -07:00
Richard Newman
4f37a86039 Use cljify in promise-sqlite. 2016-09-22 15:59:15 -07:00
Richard Newman
ea027e8cea Implement cljify. 2016-09-22 15:59:15 -07:00
Richard Newman
1d53d547b8 Externs. 2016-09-22 12:43:36 -07:00
Richard Newman
330433a45c Add externs file for Node's use of promise_sqlite. 2016-09-22 12:43:35 -07:00
Nick Alexander
1a30306314 Move datomish.api into exported namespace. 2016-09-19 12:03:09 -07:00
Richard Newman
b5aec2e890 Move src-node and src-browser into subdirectories of src. 2016-09-09 12:07:03 -07:00
Richard Newman
418bb34d57 Add is-node?. 2016-09-08 19:11:44 -07:00
Richard Newman
5ccc725b56 Flesh out JS API. 2016-09-08 19:11:44 -07:00
Richard Newman
9e4e95ce51 Default SQLite's user_version to zero.
I saw nil here with Sqlite.jsm.
2016-09-08 19:11:44 -07:00
Richard Newman
cc25ce33e2 Move platform-specific code into src-node. 2016-09-08 19:11:44 -07:00
Richard Newman
9dbda3d9d8 Pre: remove exec_repl.cljc. 2016-09-08 19:04:15 -07:00
Richard Newman
53322d8389 Pre: @arg -> @param to quiet cljsbuild warnings. 2016-09-08 19:04:15 -07:00
Nick Alexander
659c26339c Serialize and de-serialize non-keyword schema values correctly. Fixes #52. 2016-09-07 17:31:30 -07:00
Nick Alexander
362bdb2028 Add :db.fn/retractAttribute and :db.fn/retractEntity. Fixes #46.
There's no distinction made for fulltext attributes, since the values
found by the retractAttributes SELECT are already rowids into the
fulltext_values table and therefore need no additional mapping.
2016-09-06 13:13:20 -07:00
Nick Alexander
94bac9704b Pre: Use SQLite temp files in deftest-db.
These temp files will almost certainly live in memory only, speeding our
test suite evaluation significantly.  Before this patch, in a warmed
REPL environment I get:

Testing datomish.db-test

Ran 19 tests containing 97 assertions.
0 failures, 0 errors.
"Elapsed time: 1408.720681 msecs"
"Elapsed time: 1343.986464 msecs"
"Elapsed time: 1338.660762 msecs"

After this patch, in a warmed REPL environment I get:

Testing datomish.db-test

Ran 19 tests containing 97 assertions.
0 failures, 0 errors.
"Elapsed time: 587.605168 msecs"
"Elapsed time: 569.522333 msecs"
"Elapsed time: 589.080282 msecs"
2016-09-06 13:13:20 -07:00
Nick Alexander
cfdce12c1a Pre: Use deftest-db in tests. 2016-09-06 13:13:20 -07:00
Richard Newman
5424e61be4 Review comment: args -> inputs. 2016-09-02 16:23:30 -07:00
Richard Newman
1197764949 Implement :limit and :order-by-vars. Fixes #37.
We'd like this to be part of the query syntax itself, but doing so
requires extending DataScript's parser.

Instead we generalize our `args` to `options`, and take `:limit`
and `:order-by-vars`. The former must be an integer or nil, and the
latter is an array of `[var direction]` pairs.

This commit includes descriptive error messages and tests for success
and failure.
2016-09-02 08:32:45 -07:00
Nick Alexander
d92016166a Cache partition map and update materialized partition view once. Fixes #47.
This caches a partition map per DB, which is helpful because it exposes
what the point in time DB partition state is, but is unhelpful because
the partition state can advance underneath the DB cache.  This is
generally true of the approach -- this can happen to the ident/entid
maps, and the datoms themselves -- so we'll roll with it for now.

This reduces the number of SQL UPDATE operations from linear in the
number of id-literals used to constant in the number of known
partitions.
2016-09-01 14:46:04 -07:00
Nick Alexander
d419554361 Revert "Add Datomic, for testing."
This reverts commit 1b1cc6f18e.

This should never have escaped the lab; Datomic is not a dependency of
Datomish.
2016-08-31 16:17:08 -07:00
Richard Newman
7486c2a8ba Hacking on exec-repl. 2016-08-30 18:22:23 -07:00
Richard Newman
ae65ba14fb Review comment: move assoc-if to utils. 2016-08-30 18:22:22 -07:00
Richard Newman
6fbd63fed2 Review comment: clarity. 2016-08-30 18:22:22 -07:00
Richard Newman
495e5a737e Review comment: check that Datalog vars don't have a namespace.
And fix the only test that uses syntax-quote, which namespace-qualifies bare symbols.
2016-08-30 18:22:22 -07:00
Richard Newman
0f399eafb0 Review comment: better UUID support. 2016-08-30 18:22:22 -07:00
Richard Newman
7d684216f0 Extension: allow non-constant attributes in fulltext expressions. Fixes #42.
This change breaks compatibility with Datomic, but is useful when we simply want
to find entities linked somehow to matching content.
2016-08-30 18:22:22 -07:00
Richard Newman
31e354ae61 Correctly distinguish between fulltext-values and fulltext-datoms. 2016-08-30 18:22:22 -07:00
Richard Newman
a9b26f154a Add (currently unused) ability to generate CTEs. 2016-08-30 18:22:22 -07:00
Richard Newman
f225dbe734 Implement get-else. 2016-08-30 18:22:22 -07:00
Richard Newman
38cd30a895 Implement aggregation. Fixes #39. 2016-08-30 18:22:22 -07:00
Richard Newman
1e04425287 Dates in and out. 2016-08-30 18:22:21 -07:00
Richard Newman
0cd6da1039 Add :db/doc as a default attribute. 2016-08-30 18:22:21 -07:00
Richard Newman
893f944596 Error out when an attribute could not be interned when transacting. 2016-08-30 18:22:11 -07:00
Richard Newman
bdac50e03c Define deftest-db to do async testing with an open DB. 2016-08-30 18:22:11 -07:00
Richard Newman
479a7fd583 Project real values. Fixes #30. 2016-08-30 18:22:11 -07:00
Richard Newman
1c6244db5b Implement type-aware querying. Fixes #14.
* Alter how clauses are concatenated. They now preserve order more accurately.
* Track mappings between vars and extracted type columns.
* Generate type code constraints.
* Push known types down into :not.
* Push known types down into :or.
* Tests and test fixes.
2016-08-30 18:22:11 -07:00
Richard Newman
2529378725 Rewrite <resolve-lookup-refs to work for lookup refs.
Note that `go` (and `go-pair`) don't descend into `for` comprehensions
and other situations in which a fn is created. This commit rewrites to
use nested `loop`s, and also improves use of `<av`.
2016-08-30 18:22:11 -07:00
Richard Newman
86b5a8ea8a Rework <apply-entities to be 40% faster and not blow the stack in CLJS.
* Batch up datoms into a smaller number of queries, improving transact speed by about 50%.
* Restore transacting FTS attributes.
* Implement retraction of freetext datoms.
2016-08-30 18:22:11 -07:00
Richard Newman
587959d1ff Simplify id-literal?, avoid some consing. 2016-08-30 18:22:11 -07:00
Richard Newman
b4112bbe52 Symbolicating is not expensive. 2016-08-30 18:22:10 -07:00
Richard Newman
43a96efd32 Memoize and simplify parts of insertion. 2016-08-30 18:22:10 -07:00
Richard Newman
6b480a700d Minor perf improvement: use UNION ALL to populate tx_lookup in a single INSERT. 2016-08-30 18:22:10 -07:00
Richard Newman
f53869ba6f Minor perf improvement: create idx_tx_lookup_added after populating tx_lookup. 2016-08-30 18:22:10 -07:00
Richard Newman
2a55b138f6 Limit number of imported places, not number of imported rows. Default to 1000. 2016-08-30 18:22:10 -07:00
Richard Newman
5836b1867e Don't attempt to add a places visit list of (nil). 2016-08-30 18:22:10 -07:00
Richard Newman
db8d043b27 Places import: add a title import function to exercise lookup refs. 2016-08-30 18:22:10 -07:00
Richard Newman
5ec79f6be3 Places import: LEFT JOIN correctly to pick up unvisited pages. 2016-08-30 18:22:10 -07:00
Richard Newman
f85968de88 Places import: title is the same for each returned row. Don't filter. 2016-08-30 18:22:10 -07:00
Richard Newman
d7018aedaa Remove dependency on test code from places importer. 2016-08-30 18:22:10 -07:00
Nick Alexander
3775c7c773 Start importing places. This is just about profiling for now. 2016-08-30 18:22:10 -07:00
Nick Alexander
71446a3af5 Completely rewrite main transaction logic to be faster.
This is almost complete; it passes the test suite save for retracting
fulltext datoms correctly.

There's a lot to say about this approach, but I don't have time to give
too many details.  The broad outline is as follows.  We collect datoms
to add and retract in a tx_lookup table.  Depending on flags ("search
value" sv and "search value type tag" svalue_type_tag) we "complete" the
tx_lookup table by joining matching datoms.  This allows us to find
datoms that are present (and should not be added as part of the
transaction, or should be retracted as part of the transaction, or
should be replaced as part of the transaction.  We complete the
tx_lookup (in place!) in two separate INSERTs to avoid a quadratic
two-table walk (explain the queries to observe that both INSERTs walk
the lookup table once and then use the datoms indexes to complete the
matching values).

We could simplify the code by using multiple lookup tables, both for the
two cases of search parameters (eav vs. ea) and for the incomplete and
completed rows.  Right now we differentiate the former with NULL checks,
and the latter by incrementing the added0 column.  It performs well
enough, so I haven't tried to understand the performance of separating
these things.

After the tx_lookup table is completed, we build the transaction from
it; and update the datoms materialized view table as well.  Observe the
careful handling of the "search value" sv parameters to handle replacing
:db.cardinality/one datoms.

Finally, we read the processed transaction back to produce to the API.
This is strictly to match the Datomic API; we might make allow to skip
this, since many consumers will not want to stream this over the wire.

Rough timings show the transactor processing a single >50k datom
transaction in about 3.5s, of which less than 0.5s is spent in the
expensive joins.  Further, repeating the processing of the same
transaction is only about 3.5s again!  That's the worst possible for the
joins, since every single inserted datom will already be present in the
database, making the most expensive join match every row.
2016-08-30 18:22:10 -07:00
Nick Alexander
b59c71cb00 Extract datomish.db.debug from test code, in order to use it during development. 2016-08-30 18:22:10 -07:00
Nick Alexander
a1cc372d43 Fix :db.unique/value, which should be per (a, v) pair, not per v-value. 2016-08-30 18:22:10 -07:00
Nick Alexander
1b1cc6f18e Add Datomic, for testing. 2016-08-30 18:22:09 -07:00
Nick Alexander
b29e5caec0 Implement parts: Make the DB allocate and persist entity IDs.
This implementation is inefficient because each allocated temporary ID
touches the database, but it's enough to allow to re-open DBs.
2016-08-30 18:22:09 -07:00
Richard Newman
22fc2ce201 Define <-tagged-SQLite and tagged-SQLite-to-JS to do tag-aware value transforms. 2016-08-30 18:22:09 -07:00
Nick Alexander
ff9a75ae09 Tag values with value type tags in SQLite. 2016-08-30 18:22:09 -07:00
Nick Alexander
4d34c820b8 Add d/q; make query minimally schema aware. 2016-08-30 18:22:09 -07:00
Nick Alexander
0f7c1cad79 Extract IEncodeSQLite protocol and type-aware (but not schema-aware) <-SQLite factory. 2016-08-30 18:22:09 -07:00
Richard Newman
655a6a1461 Raise a specific error when trying to transact invalid sequences.
This specifically checks for things like :db/add foo bar (nil),
which will otherwise fail elsewhere after being exploded.
2016-08-30 18:22:09 -07:00
Nick Alexander
e7e84e0a90 Add d/{ident,entid} for mapping between keyword idents and integer entids. 2016-08-30 18:22:09 -07:00
Richard Newman
dc87d7d557 Correctly handle SQL errors in <?all-rows. Fixes #40. 2016-08-30 18:22:09 -07:00
Richard Newman
14a6a9bebb Configure our JDBC interface to not downcase column names in result sets. 2016-08-30 18:22:09 -07:00
Richard Newman
cf96bf1888 Always use our sql-quoting-style. 2016-08-30 18:22:09 -07:00
Richard Newman
cff49b6df5 Initialize the sqlite connection with WAL and foreign keys.
This somewhat improves performance, which is nice.
2016-08-30 18:22:09 -07:00
Richard Newman
1a54cec1ba Use correct view for fulltext+non-fulltext. 2016-08-05 16:29:21 -07:00
Richard Newman
b1e6ffc91c Example query hacking. 2016-08-05 13:04:09 -07:00
Richard Newman
fc845a9950 Implement basic fulltext binding. r=nalexander 2016-08-05 13:04:06 -07:00
Richard Newman
57d8796d07 Split out datomish.query.cc so we can implement clause resolution in more than one namespace. r=nalexander 2016-08-05 13:04:01 -07:00
Richard Newman
fc65f268fa Process Function instances in clause handling. r=nalexander 2016-08-05 13:03:52 -07:00
Richard Newman
4c2230929e Turn Source into a protocol. Allow source->from to switch on attribute. r=nalexander 2016-08-05 13:03:48 -07:00
Nick Alexander
c948902c52 Follow-up: Extract datomish.transact.explode.
This required pushing the ID literal out of transact.  I elected to put
them in DB, since literal allocation will end up in IDB eventually.
2016-08-04 17:54:50 -07:00
Nick Alexander
d8c976c3ad Follow-up: split the monolith!
This was a little more tricky than might be expected because the
initialization process uses the transactor to bootstrap the database.
Since Clojure doesn't accept mutually recursive modules, this
necessitated a third module, namely "db-factory", which uses both "db"
and "transact".  While I was here, I started an "api" module, to paper
over the potentially complicated internal module structure for external
consumers.  In time, this "api" module may also grow CLJS-specific JS
transformations.
2016-08-04 17:54:32 -07:00
Nick Alexander
1853d57cba Follow-up: extract datomish.transact.bootstrap. 2016-08-04 16:37:14 -07:00
Nick Alexander
73b155cfdc Follow-up: don't accept schema when creating DB.
This schema was already ignored.
2016-08-04 16:34:48 -07:00
Nick Alexander
52af06ce28 Follow-up: lift in-transaction! to DB; make transactions exclusive. 2016-08-04 16:27:36 -07:00
Nick Alexander
f408cfd314 Follow-up: lift helpers to IDB. 2016-08-04 16:20:48 -07:00
Nick Alexander
65d71a2598 Review comment: use :quoting :ansi parameter to honeysql/format. 2016-08-04 15:42:25 -07:00
Nick Alexander
9c2d81b9c4 Review comments: update SQLite schema definitions. 2016-08-04 15:42:25 -07:00
Nick Alexander
6a01885dff Review comment: simplify equality. 2016-08-04 14:51:17 -07:00
Nick Alexander
c344de665e Review comments: lift (schema db) in a few places. 2016-08-04 14:50:05 -07:00
Nick Alexander
5ece60e3e9 Review comment: be more strict in lookup-ref?. 2016-08-04 14:45:41 -07:00
Nick Alexander
44db8116bf Handle nested maps, sequences in maps, and reverse references. 2016-08-04 14:26:20 -07:00
Nick Alexander
d9a8cb0d6a Don't accept user-provided tx values.
This agrees with Datomic.  DataScript allows tx values, possibly to
allow reconstructing DBs from Datom streams, but appears to handle
user-provided tx values in the transactor inconsistently.
2016-08-04 14:26:20 -07:00
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
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
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
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
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
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
Nick Alexander
d5cfbeaa45 Add tempfile and with-tempfile to CLJS.
We already have a nice library like this for CLJ (tempfile); this builds
the same thing for CLJS, using Node.js's tmp.
2016-07-12 13:56:26 -07:00
Nick Alexander
0a312b4f40 Add an async and async testing framework.
This is a well-worn idea: use a `promise-channel` of `[result nil]` or
`[nil error]` pairs.  The `go-pair` and `<?` macros handle catching
exceptions (important, given that synchronous CLJ code expects to throw
rather than return an error promise or similar), allowing code like:
```
(go-pair
  (let [result (<? (pair-chan-fn))]
    (when (not result)
      (throw (Exception. "No result!")))
    (transform result)))
```
to be expressed naturally.  These are the equivalents of `async` and
`await` in JS.

The implementation is complicated by significant incompatibilities
between CLJ and CLJS.  The solution presented here takes care to
separate the macro definitions into CLJ.  Sadly, this requires
namespacing the per-environment symbols explicitly; but we hope to
minimize such code in files like this.

The most significant restriction to this approach is that consumers must
require the transitive dependencies of the macro-defining modules.  See
the included tests (both CLJ and CLJS) for the appropriate
incantations (for pair-chan, core.async, and test).
2016-07-12 13:56:26 -07:00
Nick Alexander
f2365646d2 Add lein-cljsbuild and adapt datascript's release-js vehicle. 2016-07-06 16:42:37 -07:00
Richard Newman
9e3df19798 Stub code, build, and REPL.
Signed-off-by: Richard Newman <rnewman@twinql.com>
2016-07-05 12:36:55 -07:00