Skip to content

Releases: vbasky/somnia

somnia v0.8.1

Choose a tag to compare

@github-actions github-actions released this 11 Aug 00:42

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 as table:u'…' over JSON; Key / Thing now recognize
    that wire form (and backtick-quoted keys) and parse them as Key::Uuid.
    Key::render_id also emits the native u'…' 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 live mem://
    create→select regression.

somnia v0.8.0

Choose a tag to compare

@github-actions github-actions released this 23 Jun 10:56

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. A Credentials enum (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 via signin_record / signup_record
    (params are any Serialize value, 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 new SomniaError::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 a LIVE SELECT on T's table and returns a LiveQueryStream<T> — a futures
    Stream of Notification<T> carrying the change Action
    (Create/Update/Delete), the originating query_id, and the deserialized
    record. Dropping the stream issues KILL server-side (no explicit teardown).
    Works on the embedded (mem://) engine and over ws://. Verified live
    (create → update → delete notifications with the decoded record).

  • Vector / full-text query helpers (P3). Table::search(field, query) → Search<T> builds full-text WHERE field @@ 'query' selects with optional
    search::score projection / relevance ordering; Table::nearest(field, vec) → VectorSearch<T> builds vector KNN selects (<|k,ef|> HNSW or <|k,METRIC|>
    brute force) with vector::distance::knn() projection / nearest-first
    ordering. New composable expression nodes MatchesExpr (@@) and KnnExpr
    (<|…|>), plus Column::matches. Both render to_surrealql[_with_params] and
    are verified live (ranked full-text search, HNSW nearest-neighbour ordering).

  • SurrealDB 3.x type-system (P3). A typed Closure expression 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 record REFERENCE [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 emit FULLTEXT ANALYZER … instead of the pre-3.x SEARCH 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,
    SELECT modifiers, Control flow, advanced schema DDL, graph edges), each with a
    worked sample and the rendered SurrealQL shown inline.

somnia v0.7.0

Choose a tag to compare

@github-actions github-actions released this 21 Jun 15:28

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); now count(). 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 (the col name), and
    DefineIndex::search/hnsw/mtree. &str literals and String still work;
    callers passing &String must deref (s.as_str() or s.clone()).
  • Release pipeline — scripts/release.sh now runs cargo doc -D warnings
    before tagging (catches broken doc links pre-release), and the publish workflow
    retries each cargo publish up to 5× with a 30s backoff to ride out crates.io
    index-propagation lag (which had left somnia-cli unpublished in 0.6.0 until a
    manual re-run).

Fixed (0.7.0)

  • Docs — removed a broken intra-doc link in the SurrealEdge derive doc
    (the proc-macro crate can't resolve ::somnia_core::… paths), which failed
    cargo doc -D warnings in CI.

somnia v0.6.0

Choose a tag to compare

@github-actions github-actions released this 21 Jun 12:10

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 the SurrealEdge
    impl (edge name from #[table(...)]), replacing the hand-written
    impl SurrealEdge. The derive also renders FLEXIBLE on #[field(flexible)]
    fields (DEFINE FIELD … FLEXIBLE TYPE …).
  • Control flow (P2) — IfExpr (IF … THEN … ELSE IF … ELSE … END) as a
    DynExpr usable in any expression position, and a For builder
    (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), and DefineParam ($-prefixed, raw or typed value), each with a
    ::remove(...) inverse. New derived field attributes #[field(assert = "…")],
    #[field(readonly)], and #[field(permissions = "…")] render into the
    generated DEFINE FIELD. Validated against the live engine.
  • SELECT extras (P2) — VALUE mode, OMIT, SPLIT, WITH INDEX/WITH NOINDEX hints, TIMEOUT, and EXPLAIN[ FULL] modifiers on Select;
    subqueries (Select<T> now implements DynExpr, rendering parenthesized — use
    it in a WHERE, as a scalar operand, or as FROM (<subquery>) via
    from_subquery); in_expr() / not_in_expr() (IN / NOT IN) on columns and
    idents; and RETURN <projection> on INSERT (now renders the actual field list
    plus a returning() enum setter) and RelateEdge (return_field / returning).
    Subquery parameters merge into the parent's $param map. PARALLEL is omitted —
    SurrealDB 3.1 rejects it on SELECT.
  • Transactions (P2) — a Transaction builder wraps pushed statements in
    BEGIN TRANSACTION; … ; COMMIT TRANSACTION; (or CANCEL TRANSACTION via
    .cancel()), giving atomic, roll-back-on-error semantics that the
    ;-concatenated Batch doesn'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() on Select/Create/
    Update/Delete (and then_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. A LetVar builder emits
    LET $var = <expr>, and SomniaClient::query_with_params() binds and runs the
    pair. The inline to_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, $param binding, subqueries, SELECT
    modifiers, DEFINE EVENT/FUNCTION, IfExpr/For, #[derive(SurrealEdge)]).
    Docs only.

somnia v0.5.2

Choose a tag to compare

@github-actions github-actions released this 19 Jun 23:18

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 Path node gained recurse_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, with from_record, record-anchored). Validated against a
    live in-memory engine.
  • DEFINE INDEX — a runtime DefineIndex builder (plain, composite,
    unique(), search(analyzer), hnsw/mtree vector, comment,
    concurrently, overwrite, and DefineIndex::remove) plus a repeatable derive
    attribute #[index(name = "…", fields = "a, b", unique)]. Derived indexes flow
    into the new SurrealSchema::define_indexes() and are emitted by up() after
    the field definitions. A live test confirms a UNIQUE index rejects duplicates.
  • Richer field types — the derive maps Rust types via real recursive
    syn::Type analysis instead of substring matching: typed arrays
    (Vec<T>/VecDeque/HashSet/slices → array<…>), arrays of records, nested
    Option, duration, and decimal. Adds SurrealQL literal impls for
    Vec<T> (renders […]) and std::time::Duration (renders e.g. 1s500000000ns).

Changed (0.5.2)

  • SurrealSchema gained a defaulted define_indexes() method; existing manual
    implementations are unaffected.
  • The derive emits a precise array<…> element type for collection fields
    (previously a bare array). Generated DDL only; no Rust API change.

somnia v0.5.1

Choose a tag to compare

@github-actions github-actions released this 19 Jun 22:47

Changed (0.5.1)

  • README — bumped the install snippet and status line from 0.4 to 0.5.
    The 0.5.0 crates.io README still showed somnia = "0.4" (a constraint that
    won't resolve to 0.5.0); this corrects it. Docs only; no code changes.

somnia v0.5.0

Choose a tag to compare

@github-actions github-actions released this 19 Jun 22:36

Added (0.5.0)

  • Graph traversal in SELECT — a typed Path expression node for querying
    across edges created with RELATE (previously a drop to Raw). Build hops with
    Path::out::<E>() / inn / both (raw variants out_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(...). A Path is a DynExpr, so it works as a SELECT projection
    (Table::project_path(path, alias), Select::with_path(path, alias) for
    SELECT *, <path> AS …) or inside a WHERE filter (with .contains(...),
    .eq_expr(...), .and(...) / .or(...)). Recursive {..} paths and .{…}
    destructuring are not yet covered.

somnia v0.4.1

Choose a tag to compare

@github-actions github-actions released this 06 Jun 01:13

Changed

  • README — bumped version strings and badge references from 0.3 to 0.4;
    added then_select usage example. (crates.io README was stale in 0.4.0.)

somnia v0.4.0

Choose a tag to compare

@github-actions github-actions released this 06 Jun 00:31

Added

  • then_select on CREATE/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-up SELECT as a ;-separated batch. Available on Create<T>,
    Update<T>, and Delete<T>.

somnia v0.3.1

Choose a tag to compare

@github-actions github-actions released this 05 Jun 22:29

Changed (0.3.1)

  • crates.io README — the somnia crate's own README.md (what crates.io
    renders) now mirrors the repo README: banner, current somnia = "0.3" usage,
    and absolute URLs for the banner/links so they resolve on crates.io. Docs only;
    no code changes.