Repository navigation
Releases: vbasky/somnia
Release list
somnia v0.8.1
Patch release: native UUID record ids round-trip correctly. Bump to
somnia = "0.8.1" (or keep somnia = "0.8" if you already use a caret range).
Fixed
- UUID record ids no longer deserialize as
Key::String("u'…'")
(#1). SurrealDB serializes native
UUID record-id keys astable:u'…'over JSON;Key/Thingnow recognize
that wire form (and backtick-quoted keys) and parse them asKey::Uuid.
Key::render_idalso emits the nativeu'…'form for UUID keys instead of
backticks, so create/filter/RELATE keep a real uuid key rather than a string
that only looks like one. Covered by unit tests and a livemem://
create→select regression.
somnia v0.8.0
Completes the P3 roadmap tier: typed authentication, live queries, full-text /
vector search helpers, and SurrealDB 3.x type-system surface (closures,
REFERENCEs, union / literal types). Two small breaking changes: a new
SomniaError::Auth variant (breaks exhaustive matches on SomniaError), and
DefineIndex::search() / #[index(search = …)] now emit FULLTEXT ANALYZER …
instead of the pre-3.x SEARCH ANALYZER … (changed output, same API). Bump your
dependency to somnia = "0.8".
Added
-
Authentication (P3). The client grows a typed auth surface beyond
root-only signin. ACredentialsenum (Root/Namespace/Database/
Token, each with an ergonomic constructor) drives the new
SomniaClient::connect_with(endpoint, ns, db, creds), and
connect_anonymous(endpoint, ns, db)connects without signing in (for
embedded engines or deferred auth). On an existing connection:
signin(&creds), record/scope auth viasignin_record/signup_record
(params are anySerializevalue, flattened into the access method's
$params),authenticate(token)to attach a pre-issued JWT, and
invalidate()to clear the session. Signin/signup/record calls return the
issued access token. Auth failures surface as a newSomniaError::Auth
variant. Verified end-to-end against the live in-memory engine (record
signup → signin → invalidate, wrong-password rejection). -
Live queries (P3).
SomniaClient::live_select::<T>()starts aLIVE SELECTonT's table and returns aLiveQueryStream<T>— afutures
StreamofNotification<T>carrying the changeAction
(Create/Update/Delete), the originatingquery_id, and the deserialized
record. Dropping the stream issuesKILLserver-side (no explicit teardown).
Works on the embedded (mem://) engine and overws://. Verified live
(create → update → delete notifications with the decoded record). -
Vector / full-text query helpers (P3).
Table::search(field, query) → Search<T>builds full-textWHERE field @@ 'query'selects with optional
search::scoreprojection / relevance ordering;Table::nearest(field, vec) → VectorSearch<T>builds vector KNN selects (<|k,ef|>HNSW or<|k,METRIC|>
brute force) withvector::distance::knn()projection / nearest-first
ordering. New composable expression nodesMatchesExpr(@@) andKnnExpr
(<|…|>), plusColumn::matches. Both renderto_surrealql[_with_params]and
are verified live (ranked full-text search, HNSW nearest-neighbour ordering). -
SurrealDB 3.x type-system (P3). A typed
Closureexpression node renders
anonymous functions (|$x: int| -> int $x * 2) for higher-order calls /
computed values. The derive gains#[field(reference)]/
#[field(reference = "cascade")]to emit recordREFERENCE [ON DELETE …].
Union (#[field(ty = "int | string")]) and literal
(#[field(ty = "'a' | 'b'")]) field types are confirmed end-to-end.future<T>
is intentionally omitted — the keyword no longer exists in SurrealDB 3.x.
Changed
-
(Fix)
DefineIndex::search()/#[index(search = …)]now emitFULLTEXT ANALYZER …instead of the pre-3.xSEARCH ANALYZER …, which SurrealDB 3.x
rejects as a parse error. The method/attribute names are unchanged; only the
emitted keyword. Needed for the new full-text query helpers to run against a
real index. -
README — expanded the terse "More query power" block into descriptive,
per-feature sections (Parameters &LET, Transactions, Subqueries &IN,
SELECTmodifiers, Control flow, advanced schema DDL, graph edges), each with a
worked sample and the rendered SurrealQL shown inline.
somnia v0.7.0
Pre-1.0 API stabilization plus release-pipeline hardening. Breaking in two
small ways — update count("") → count(), and deref any &String args to
builder string methods. Bump your dependency to somnia = "0.7".
Changed (0.7.0)
- (Breaking)
Table::count()drops its ignored argument — was
count(field: &str)(the field was never used); nowcount(). Update
table().count("")→table().count(). - (Breaking) builder string args widened to
impl Into<String>for
consistency with the newer builders:Select::fetch/omit/split,
Create/Update::set_lit/set_expr/set_raw(thecolname), and
DefineIndex::search/hnsw/mtree.&strliterals andStringstill work;
callers passing&Stringmust deref (s.as_str()ors.clone()). - Release pipeline —
scripts/release.shnow runscargo doc -D warnings
before tagging (catches broken doc links pre-release), and the publish workflow
retries eachcargo publishup to 5× with a 30s backoff to ride out crates.io
index-propagation lag (which had leftsomnia-cliunpublished in 0.6.0 until a
manual re-run).
Fixed (0.7.0)
- Docs — removed a broken intra-doc link in the
SurrealEdgederive doc
(the proc-macro crate can't resolve::somnia_core::…paths), which failed
cargo doc -D warningsin CI.
somnia v0.6.0
Completes the P2 ("completeness") roadmap tier — transactions, parameter
binding, SELECT extras, more schema DDL, control flow, and the edge derive.
Every change is API-additive, but the breadth of new functionality earns a minor
bump (update your dependency to somnia = "0.6").
Added (0.6.0)
- Edge derive (P2) —
#[derive(SurrealEdge)]generates theSurrealEdge
impl (edge name from#[table(...)]), replacing the hand-written
impl SurrealEdge. The derive also rendersFLEXIBLEon#[field(flexible)]
fields (DEFINE FIELD … FLEXIBLE TYPE …). - Control flow (P2) —
IfExpr(IF … THEN … ELSE IF … ELSE … END) as a
DynExprusable in any expression position, and aForbuilder
(FOR $item IN <array> { <body> }). Both validated against the live engine. - More schema DDL (P2) — standalone builders
DefineEvent,DefineFunction
(fn::-prefixed, typed args, return type, body),DefineAnalyzer(tokenizers +
filters), andDefineParam($-prefixed, raw or typed value), each with a
::remove(...)inverse. New derived field attributes#[field(assert = "…")],
#[field(readonly)], and#[field(permissions = "…")]render into the
generatedDEFINE FIELD. Validated against the live engine. SELECTextras (P2) —VALUEmode,OMIT,SPLIT,WITH INDEX/WITH NOINDEXhints,TIMEOUT, andEXPLAIN[FULL] modifiers onSelect;
subqueries (Select<T>now implementsDynExpr, rendering parenthesized — use
it in aWHERE, as a scalar operand, or asFROM (<subquery>)via
from_subquery);in_expr()/not_in_expr()(IN/NOT IN) on columns and
idents; andRETURN <projection>onINSERT(now renders the actual field list
plus areturning()enum setter) andRelateEdge(return_field/returning).
Subquery parameters merge into the parent's$parammap.PARALLELis omitted —
SurrealDB 3.1 rejects it onSELECT.- Transactions (P2) — a
Transactionbuilder wraps pushed statements in
BEGIN TRANSACTION; … ; COMMIT TRANSACTION;(orCANCEL TRANSACTIONvia
.cancel()), giving atomic, roll-back-on-error semantics that the
;-concatenatedBatchdoesn't. Verified atomic against a live engine. - Parameters /
LET(P2) — an opt-in$param-binding mode alongside the
default inline rendering.to_surrealql_with_params()onSelect/Create/
Update/Delete(andthen_select_params()on the mutations) returns
(String, BTreeMap<String, serde_json::Value>), auto-binding each literal as
$p0,$p1, ….Param::new("name", value)declares an explicit named
placeholder for reuse across a query. ALetVarbuilder emits
LET $var = <expr>, andSomniaClient::query_with_params()binds and runs the
pair. The inlineto_surrealql()path is unchanged.
Changed (0.6.0)
- README — documented the P1 features (graph traversal,
#[index(...)]/
DefineIndex, richer field types) and added a "More query power" section
covering the P2 surface (transactions,$parambinding, subqueries,SELECT
modifiers,DEFINE EVENT/FUNCTION,IfExpr/For,#[derive(SurrealEdge)]).
Docs only.
somnia v0.5.2
Completes the P1 roadmap tier. Every change is API-additive (new builders,
methods, a defaulted trait method, and new SurrealQL impls), so this stays a
patch release; the only behavioral shift is that collection fields now emit a
more precise array<…> type in generated DDL.
Added (0.5.2)
- Recursive graph paths — the
Pathnode gainedrecurse_all()(@.{..}),
recurse_up_to(n)(@.{..n}),recurse_range(min, max)(@.{min..max}), and
recurse_exact(n)(@.{n}), rendering SurrealDB's recursive traversal syntax
(relative@.{…}or, withfrom_record, record-anchored). Validated against a
live in-memory engine. DEFINE INDEX— a runtimeDefineIndexbuilder (plain, composite,
unique(),search(analyzer),hnsw/mtreevector,comment,
concurrently,overwrite, andDefineIndex::remove) plus a repeatable derive
attribute#[index(name = "…", fields = "a, b", unique)]. Derived indexes flow
into the newSurrealSchema::define_indexes()and are emitted byup()after
the field definitions. A live test confirms aUNIQUEindex rejects duplicates.- Richer field types — the derive maps Rust types via real recursive
syn::Typeanalysis instead of substring matching: typed arrays
(Vec<T>/VecDeque/HashSet/slices →array<…>), arrays of records, nested
Option,duration, anddecimal. AddsSurrealQLliteral impls for
Vec<T>(renders[…]) andstd::time::Duration(renders e.g.1s500000000ns).
Changed (0.5.2)
SurrealSchemagained a defaulteddefine_indexes()method; existing manual
implementations are unaffected.- The derive emits a precise
array<…>element type for collection fields
(previously a barearray). Generated DDL only; no Rust API change.
somnia v0.5.1
Changed (0.5.1)
- README — bumped the install snippet and status line from
0.4to0.5.
The0.5.0crates.io README still showedsomnia = "0.4"(a constraint that
won't resolve to0.5.0); this corrects it. Docs only; no code changes.
somnia v0.5.0
Added (0.5.0)
- Graph traversal in
SELECT— a typedPathexpression node for querying
across edges created withRELATE(previously a drop toRaw). Build hops with
Path::out::<E>()/inn/both(raw variantsout_edge/in_edge/
both_edge), constrain the destination with.to::<T>()/.to_table(...),
chain multi-hop paths with.then_out::<E>()/.then_in::<E>(), filter a hop's
edge with.where_(expr)(->(edge WHERE …)->table), append a.field("…")or
.all()(.*) accessor, and anchor to a record with.from_record(thing)/
.from_expr(...). APathis aDynExpr, so it works as aSELECTprojection
(Table::project_path(path, alias),Select::with_path(path, alias)for
SELECT *, <path> AS …) or inside aWHEREfilter (with.contains(...),
.eq_expr(...),.and(...)/.or(...)). Recursive{..}paths and.{…}
destructuring are not yet covered.
somnia v0.4.1
Changed
- README — bumped version strings and badge references from
0.3to0.4;
addedthen_selectusage example. (crates.io README was stale in 0.4.0.)
somnia v0.4.0
Added
then_selectonCREATE/UPDATE/DELETE— replaces the manual
Batch::new().push(mut).push(select).to_surrealql()pattern with a single
method chain:create.then_select(select). Joins any mutation statement with
a follow-upSELECTas a;-separated batch. Available onCreate<T>,
Update<T>, andDelete<T>.
somnia v0.3.1
Changed (0.3.1)
- crates.io README — the
somniacrate's ownREADME.md(what crates.io
renders) now mirrors the repo README: banner, currentsomnia = "0.3"usage,
and absolute URLs for the banner/links so they resolve on crates.io. Docs only;
no code changes.