mirror of
https://github.com/Phundrak/georm.git
synced 2026-07-29 04:19:18 +02:00
feat: add SQLite support behind a sqlite Cargo feature
Adds a SqliteDialect alongside PostgresDialect, gated by mutually exclusive postgres (default) / sqlite Cargo features, plus a feature-selected ActiveDatabase type alias used throughout the public Georm/Defaultable traits. Basic CRUD and Defaultable are fully covered by a new SQLite test suite (tests/sqlite/*) running against a real SQLite database, alongside split migrations/sqlite/*. Two real dialect differences surfaced beyond placeholder syntax: - SQLite's INTEGER columns type-infer as i64 in sqlx's compile-time query macros (unlike Postgres SERIAL -> i32), so the SQLite test models use i64 for integer PK/FK fields. - sqlx's SQLite query macros need bind arguments bound to a place rather than passed as an inline expression (fixed once, centrally, in SqlDialect::generate_relation_lookup). Composite-key entities with chrono::DateTime columns (tests/composite_key.rs) are not yet ported to SQLite: SQLite has no TIMESTAMPTZ equivalent, so sqlx infers TEXT date/time columns as String rather than DateTime<Utc> unless the query explicitly overrides the column type. That needs per-field type overrides threaded through the generated queries, left as follow-up. CI now matrixes over both backends; formatting/audit only run once since they don't vary by backend. examples/postgres/* stays out of --no-default-features builds by scoping sqlite lint/test just recipes to `-p georm` (it depends on georm's default postgres feature via Cargo feature unification, so building it under --features sqlite at the workspace level double-activates both dialects).
This commit is contained in:
@@ -3,18 +3,36 @@ default: lint
|
||||
clean:
|
||||
cargo clean
|
||||
|
||||
test:
|
||||
# Runs the whole workspace (examples included) against the default
|
||||
# "postgres" feature.
|
||||
test: test-postgres
|
||||
|
||||
test-postgres:
|
||||
cargo test --all-targets --all
|
||||
|
||||
# Scoped to -p georm: examples/postgres/* depends on georm's default
|
||||
# ("postgres") feature via Cargo feature unification, so it must stay out of
|
||||
# a --no-default-features build rather than be dragged into it.
|
||||
test-sqlite:
|
||||
cargo test -p georm --no-default-features --features sqlite --all-targets
|
||||
|
||||
lint:
|
||||
cargo clippy --all-targets
|
||||
|
||||
lint-sqlite:
|
||||
cargo clippy -p georm -p georm-macros --no-default-features --features sqlite --all-targets
|
||||
|
||||
audit:
|
||||
cargo deny check all
|
||||
|
||||
migrate:
|
||||
migrate: migrate-postgres
|
||||
|
||||
migrate-postgres:
|
||||
cargo sqlx migrate run
|
||||
|
||||
migrate-sqlite:
|
||||
cargo sqlx migrate run --source migrations/sqlite
|
||||
|
||||
build:
|
||||
cargo build
|
||||
|
||||
@@ -27,7 +45,7 @@ format:
|
||||
format-check:
|
||||
cargo fmt --check --all
|
||||
|
||||
check-all: format-check lint audit test
|
||||
check-all: format-check lint audit test test-sqlite
|
||||
|
||||
## Local Variables:
|
||||
## mode: makefile
|
||||
|
||||
Reference in New Issue
Block a user