mirror of
https://github.com/Phundrak/georm.git
synced 2026-07-28 20:09:18 +02:00
4c314c2f0b
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).
81 lines
2.4 KiB
TOML
81 lines
2.4 KiB
TOML
[workspace]
|
|
members = [
|
|
".",
|
|
"georm-macros",
|
|
"examples/postgres/*"
|
|
]
|
|
|
|
[workspace.package]
|
|
version = "0.2.1"
|
|
edition = "2024"
|
|
authors = ["Lucien Cartier-Tilet <lucien@phundrak.com>"]
|
|
homepage = "https://github.com/Phundrak/georm"
|
|
repository = "https://github.com/Phundrak/georm"
|
|
license = "MIT OR GPL-3.0-or-later"
|
|
keywords = ["sqlx", "orm", "postgres", "postgresql", "database", "async"]
|
|
categories = ["database"]
|
|
|
|
[package]
|
|
name = "georm"
|
|
readme = "README.md"
|
|
description = "Georm, a simple, opiniated SQLx ORM for PostgreSQL and SQLite"
|
|
authors.workspace = true
|
|
edition.workspace = true
|
|
homepage.workspace = true
|
|
license.workspace = true
|
|
repository.workspace = true
|
|
version.workspace = true
|
|
|
|
[features]
|
|
default = ["postgres"]
|
|
postgres = ["georm-macros/postgres", "sqlx/postgres", "sqlx/bigdecimal"]
|
|
sqlite = ["georm-macros/sqlite", "sqlx/sqlite"]
|
|
|
|
[workspace.dependencies]
|
|
georm-macros = { version = "=0.2.1", path = "georm-macros" }
|
|
|
|
[workspace.dependencies.sqlx]
|
|
version = "0.8.6"
|
|
default-features = false
|
|
features = ["runtime-tokio", "macros", "migrate"]
|
|
|
|
[dependencies]
|
|
sqlx = { workspace = true }
|
|
georm-macros = { workspace = true }
|
|
|
|
[dev-dependencies]
|
|
chrono = { version = "0.4", features = ["serde"] }
|
|
rand = "0.9"
|
|
|
|
[dev-dependencies.sqlx]
|
|
# Unlike the crate's own [features] above, dev-dependencies are always built
|
|
# for `cargo test` regardless of --no-default-features/--features passed for
|
|
# the georm package itself. Tests bind directly to sqlx::PgPool/SqlitePool,
|
|
# so both drivers must be enabled here unconditionally.
|
|
version = "0.8.6"
|
|
default-features = false
|
|
features = ["postgres", "sqlite", "runtime-tokio", "macros", "migrate", "chrono", "bigdecimal"]
|
|
|
|
# Cargo's test auto-discovery only scans tests/*.rs (not subdirectories), so
|
|
# the tests/sqlite/*.rs files (kept in their own directory to avoid colliding
|
|
# with the postgres tests/models.rs module) need explicit [[test]] entries.
|
|
[[test]]
|
|
name = "sqlite_simple_struct"
|
|
path = "tests/sqlite/simple_struct.rs"
|
|
|
|
[[test]]
|
|
name = "sqlite_defaultable_struct"
|
|
path = "tests/sqlite/defaultable_struct.rs"
|
|
|
|
# sqlite_composite_key intentionally deferred: UserRole's chrono::DateTime<Utc>
|
|
# column needs per-field query_as! type overrides under SQLite (see the note
|
|
# in tests/sqlite/models.rs) that don't exist yet.
|
|
|
|
[workspace.lints.rust]
|
|
unsafe_code = "forbid"
|
|
|
|
[workspace.lints.clippy]
|
|
all = "deny"
|
|
pendantic = "deny"
|
|
nursery = "deny"
|