This is necessary because we process patterns sequentially; a later
pattern might tell us the type of a variable (e.g., by having a
constant attribute), at which point we can do less work.
* Add a failing test for EDN parsing '…'.
* Expose a SQLValueType trait to get value_type_tag values out of a ValueType.
* Add accessors to FindSpec.
* Implement querying.
* Implement rudimentary projection.
* Export mentat_db::new_connection.
* Export symbols from mentat.
* Add rudimentary end-to-end query tests.
* Add top-level `Conn`. Fixes#296.
This is a little different than the API rnewman and I originally
discussed in https://public.etherpad-mozilla.org/p/db-conn-thoughts.
A few notes:
- I was led to make a `Schema` instance the thing that is shared,
rather than a `db::DB`. It's possible that queries will want to
know the current transaction at some point (to prevent races, or to
query historical data), but that can be a future consideration.
- The generation number just allows for a cheap comparison. I don't
care to handle races to transact just yet; the long term plan might
be to make embedding applications responsible for avoiding races, or
we might handle queuing transactions and yielding report futures in
Mentat itself.
- The sharing of the partition maps is a little more subtle than
expected. Partition maps are volatile: a successful Mentat
transaction always advances the :db.part/tx partition, so it's not
worth passing references around. This means that consumers must
clone in order to maintain just a single clone per transaction.
Clean some cruft.
* Review comments.
* Pre: Drop unneeded tx0 from search results.
* Pre: Don't require a schema in some of the DB code.
The idea is to separate the transaction applying code, which is
schema-aware, from the concrete storage code, which is just concerned
with getting bits onto disk.
* Pre: Only reference Schema, not DB, in debug module.
This is part of a larger separation of the volatile PartitionMap,
which is modified every transaction, from the stable Schema, which is
infrequently modified.
* Pre: Fix indentation.
* Extract part of DB to new SchemaTypeChecking trait.
* Extract part of DB to new PartitionMapping trait.
* Pre: Don't expect :db.part/tx partition to advance when tx fails.
This fails right now, because we allocate tx IDs even when we shouldn't.
* Sketch a db interface without DB.
* Add ValueParseError; use error-chain in tx-parser.
This can be simplified when
https://github.com/Marwes/combine/issues/86 makes it to a published
release, but this unblocks us for now. This converts the `combine`
error type `ParseError<&'a [edn::Value]>` to a type with owned
`Vec<edn::Value>` collections, re-using `edn::Value::Vector` for
making them `Display`.
* Pre: Accept Borrow<Schema> instead of just &Schema in debug module.
This makes it easy to use Rc<Schema> or Arc<Schema> without inserting
&* sigils throughout the code.
* Use error-chain in query-parser.
There are a few things to point out here:
- the fine grained error types have been flattened into one crate-wide
error type; it's pretty easy to regain the granularity as needed.
- edn::ParseError is automatically lifted to
mentat_query_parser::errors::Error;
- we use mentat_parser_utils::ValueParser to maintain parsing error
information from `combine`.
* Patch up top-level.
* Review comment: Only `borrow()` once.
These expand into a collection of named variables that should be
passed via bind parameters when the query is executed.
Bind parameters are now only named.
* Implement pretty printing
Signed-off-by: Victor Porof <victor.porof@gmail.com>
* Rewrite pretty printing.
This does a few things. First, it use pretty.rs directly, without the
layer of macro obfuscation. The code is significantly simpler as a
result.
Second, it tightens the layout, using pretty.rs to group nested
layouts that fit on a single line. This is Clojure's EDN style, more
or less.
Third, it drops "special format" support for queries. This wasn't
completely implemented; if we want it, we can newtype
Query(edn::Value) and figure out how to really implement this idea.
* Rename to reflect functionality.
* Make write interface more Rust-like.
There isn't a clear standard in the stdlib, but a function that takes
ownership of a writer and then returns it back is definitely not
Rust-like. That's what a (mutable) reference is for.
* Review comment: Use as_ref to avoid cloning strings.
* Post: Fix tests to use `without_spans()`.
Printing out failure to meet rustc version helps users during
setup with a helpful message if using an older rustc.
Rust version checking from http://stackoverflow.com/a/36607492.