Skip to content

feat: add SQLite backend support#105

Draft
bodymindarts wants to merge 4 commits intomainfrom
task/sqlite-backend-019cdf3d
Draft

feat: add SQLite backend support#105
bodymindarts wants to merge 4 commits intomainfrom
task/sqlite-backend-019cdf3d

Conversation

@bodymindarts
Copy link
Copy Markdown
Member

Summary

  • Add a new sqlite feature flag alongside the existing postgres feature for compile-time database backend selection
  • Create es-entity-macros-sqlite proc macro crate that generates SQLite-compatible SQL (positional ?N params, IS instead of IS NOT DISTINCT FROM, no ANY(), etc.)
  • Add src/db.rs module with cfg-gated type aliases as the single chokepoint for all database-specific types (Pool, Row, Db, Transaction, etc.)
  • Include SQLite migration for test infrastructure using in-memory databases
  • Adapt all existing integration tests to work with both backends via feature gates

Test plan

  • 82/82 macro unit tests passing (cargo test -p es-entity-macros-sqlite)
  • Full SQLite integration test suite passing (cargo test --no-default-features --features sqlite -p es-entity)
  • Zero clippy warnings on SQLite target
  • nix flake check passes (fmt, clippy-pg, clippy-sqlite, audit, deny)
  • Verify Postgres tests still pass with a live database (cargo test --features postgres)

🤖 Generated with Claude Code

@HonestMajority HonestMajority marked this pull request as ready for review March 12, 2026 09:48
@HonestMajority HonestMajority marked this pull request as draft March 12, 2026 09:48
bodymindarts and others added 2 commits March 12, 2026 11:23
Add a new `sqlite` feature flag alongside the existing `postgres` feature,
allowing compile-time selection of the database backend. This includes:

- New `es-entity-macros-sqlite` proc macro crate generating SQLite-compatible
  SQL (positional `?N` params, `IS` instead of `IS NOT DISTINCT FROM`, etc.)
- `src/db.rs` module with cfg-gated type aliases as the single chokepoint
  for database-specific types (Pool, Row, Db, etc.)
- SQLite migration for test infrastructure with in-memory databases
- All existing integration tests adapted to work with both backends
- 82 macro unit tests + full integration test suite passing on SQLite

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The function in error.rs referenced sqlx::postgres::PgDatabaseError
without a feature gate. Add #[cfg(feature = "postgres")] and a SQLite
no-op variant.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bodymindarts bodymindarts force-pushed the task/sqlite-backend-019cdf3d branch from 8370f31 to 7b2b5ae Compare March 12, 2026 10:27
bodymindarts and others added 2 commits March 12, 2026 11:57
Add nextest-sqlite-runner script that runs macro and integration tests
with SQLite features (in-memory databases, no infrastructure needed).
Add sqlite-tests job to test.yml workflow for CI visibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…and list_for

The generated SQL for find_by and list_for queries used bare `= ?`
equality, which fails when the bound parameter is NULL because
`column = NULL` evaluates to NULL (falsy) in SQL. This caused zero
rows to be returned when querying for NULL values on Option<T> columns.

Switch to SQLite's `IS` operator for Option<T> columns, which handles
NULL-safe equality (`NULL IS NULL` returns true). The list_for_filters
variant already handled this correctly via its COALESCE pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant