Skip to content

Releases: alumna/sqlite

v1.2.0 - Nested JSON Indexes, Query Safety & Memory Tuning

Choose a tag to compare

@paulocoghi paulocoghi released this 11 Jul 21:24

This release synchronizes the SQLite adapter with Alumna Backend v0.5.7, bringing nested JSON indexing and query safety improvements.

Native Nested JSON Indexes

You can now mark deeply nested fields with unique: true or indexed: true in your Alumna Schema. The SQLite adapter automatically understands this and compiles the necessary CREATE INDEX statements using SQLite's native json_extract functions. Duplicate records on nested fields are gracefully intercepted and returned as 422 Unprocessable Entity.

Strict Query Safety

Previously, if a client passed an unknown field into a $filter, $select, or $sort query parameter, the adapter silently dropped it. This could lead to clients accidentally receiving unfiltered datasets. The query engine is now strictly sealed: any reference to an undeclared schema field immediately halts the request with a 400 Bad Request.

Zero-Allocation Tuning & Resilience

  • Perfectly Sized Hashes: Internal create and patch operations now perfectly calculate their initial_capacity, eliminating mid-flight buffer resizing.
  • O(1) Patch Validation: Column validation during PATCH operations now uses a flat array inclusion check, completely bypassing structural dot-notation scanning.
  • Panic-Proof Dates: If your SQLite database contains legacy or corrupt strings in a Time column, the adapter now safely maps them to nil rather than raising an unhandled parsing exception.

v1.1.0 - Unique and Indexes, Nullability, and Zero-Allocation SQL

Choose a tag to compare

@paulocoghi paulocoghi released this 10 Jul 21:10

This release brings the SQLite adapter to full feature parity with Alumna Backend v0.5.5, adding index generation, uniqueness constraints, and explicit nullability, as well as performance optimizations.

Highlights

  • Unique Constraints: The adapter now intercepts unique: true and compound .index(..., unique: true) traits, returning a semantic 422 Unprocessable Entity on duplicate entries. This cleanly prevents fatal SQLite constraint exceptions and 500 Server Errors.
  • Auto-Indexing Helper: Added SqliteAdapter#create_indexes!. Calling this upon initialization automatically reads your schema and generates the exact CREATE INDEX and CREATE UNIQUE INDEX statements in SQLite. It also works natively with nested JSON dot-notation fields.
  • Explicit Nullability: Complete, type-safe support for the nullable: true schema trait, flawlessly mapping Crystal Nil to SQLite NULL.
  • Zero-Allocation SQL Engine: The SQL query builder for find, create, update, and patch has been deeply refactored. Queries are now streamed directly to memory buffers, bypassing intermediate string, array, and hash allocations entirely.
  • Hardened Type Safety: The cast_from_db layer has been hardened to never trigger runtime panics (like TypeCastError) even if the underlying SQLite file contains corrupt or mismatched primitive types.

Code Coverage

This release maintains a strict 100% test coverage.