id_effect_sql 0.9.0

Driver-agnostic SQL client traits for id_effect — @effect/sql-style boundaries
Documentation
[package]
name = "id_effect_sql"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
description = "Driver-agnostic SQL client traits for id_effect — @effect/sql-style boundaries"
repository.workspace = true
readme = "README.md"
keywords = ["effect", "async", "sql", "database", "postgres"]
categories = ["asynchronous", "database"]

[lints.rust]
unsafe_code = "forbid"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage)'] }

[features]
# PostgreSQL driver (sqlx pool + PgSqlClient). `time` is the drivers' date-time type; the public
# API speaks jiff (`value::time_conv` converts). TLS: rustls with aws-lc-rs and the Mozilla roots
# (webpki-roots), as for MySQL; no OpenSSL.
pg = [
  "dep:sqlx",
  "dep:tokio",
  "dep:time",
  "sqlx/postgres",
  "sqlx/tls-rustls-aws-lc-rs",
]
# `testing::arb_sql_value`: proptest strategies over the portable `SqlValue` domain.
proptest = ["dep:proptest", "id_effect/proptest"]
# `migrate`: versioned migrations (tracking table, advisory lock, one transaction each). sqlx
# supplies the source model (file naming, checksums, `sqlx::migrate!` embedding).
migrate = ["dep:sqlx", "sqlx/migrate"]
# `query`: build statements with sea-query and run them through `SqlClient` (values bridged to
# `SqlValue`; no sea-query-binder, so sqlx stays independent). `time` converts sea-query's time
# values.
query = ["dep:sea-query", "dep:time"]
# SQLite driver (sqlx sqlite, bundled libsqlite3) and `SqliteSqlClient`: in-memory and file
# databases. Date-times, uuids, decimals and JSON are stored as text (`sqlite` module docs).
sqlite = ["dep:sqlx", "dep:tokio", "sqlx/sqlite"]
# `audit`: hash-chained audit log appended in the caller's transaction (PostgreSQL SQL; the
# schema ships in `migrations/audit/`).
audit = ["dep:sha2"]
# `repository`: `#[derive(Entity)]` and `Repository<T>` (CRUD, optimistic locking, soft-delete /
# tenant / custom global filters) over `query`'s sea-query statements. A feature of its own so
# `query` stays the plain statement builder.
repository = ["query"]
# MySQL driver (sqlx mysql) and `MySqlSqlClient`, tested against MySQL 8. sqlx-mysql brings `rsa`
# (RUSTSEC-2023-0071, ignored with its reason in deny.toml).
mysql = [
  "dep:sqlx",
  "dep:tokio",
  "dep:time",
  "sqlx/mysql",
  "sqlx/tls-rustls-aws-lc-rs",
]

[dependencies]
id_effect = { path = "../id_effect", version = "0.9.0" }
# `#[derive(FromRow)]`, re-exported as `id_effect_sql::FromRow`.
id_effect_proc_macro = { path = "../id_effect_proc_macro", version = "0.9.0" }
# Value crates are unconditional: `SqlValue` has the same variants under every feature set.
# jiff: same floor as crates/id_effect.
jiff = "0.2.23"
uuid = { version = "1", default-features = false, features = ["std"] }
rust_decimal = { version = "1", default-features = false, features = ["std"] }
serde = "1"
serde_json = "1"
time = { version = "0.3", optional = true, default-features = false, features = [
  "std",
] }
proptest = { version = "1", optional = true, default-features = false, features = [
  "std",
] }
# 0.8.6: `Pool::begin_with` (transactions with a custom BEGIN statement).
sqlx = { version = "0.8.6", optional = true, default-features = false, features = [
  "runtime-tokio",
  "uuid",
  "time",
  "rust_decimal",
  "json",
] }
tokio = { version = "1.50.0", optional = true, features = ["rt", "sync"] }
# Feature `query`. The three backends render SQL only (no driver); derive/audit/itoa are off.
# 1.0.2: rust-version 1.88.
sea-query = { version = "1.0.2", optional = true, default-features = false, features = [
  "backend-postgres",
  "backend-mysql",
  "backend-sqlite",
  "with-json",
  "with-uuid",
  "with-rust_decimal",
  "with-jiff",
  "with-time",
] }
# Feature `audit`: the record hash chain. 0.10: the version sqlx's PostgreSQL driver uses.
sha2 = { version = "0.10", optional = true, default-features = false }

[dev-dependencies]
id_effect_tokio = { path = "../id_effect_tokio" }
proptest = "1"
serde = { version = "1", features = ["derive"] }
tokio = { version = "1.50.0", features = ["macros", "rt-multi-thread", "net"] }
# tests/from_row.rs: compile-fail cases of `#[derive(FromRow)]`.
trybuild = "1"
# MySQL 8 container for tests/conformance/mysql.rs (feature `mysql`), and the TLS servers of
# tests/tls.rs.
testcontainers = { version = "0.28", default-features = false }
# tests/tls.rs: a throwaway CA and server certificate (aws-lc-rs, as rustls uses).
rcgen = { version = "0.13", default-features = false, features = [
  "aws_lc_rs",
  "pem",
] }

[[test]]
name = "pg"
required-features = ["pg"]

[[test]]
name = "migrate"
required-features = ["migrate", "pg"]

[[test]]
name = "query"
required-features = ["query"]

[[test]]
name = "sqlite"
required-features = ["sqlite"]

[[test]]
name = "audit"
required-features = ["audit", "pg"]

[[test]]
name = "repository"
required-features = ["repository"]

# Typed values and rows (`params!`, `SqlRow::get`, `FromRow`) over `TestSqlClient`: no database,
# no feature.
[[example]]
name = "020_typed_rows"

[[example]]
name = "030_migrate"
required-features = ["migrate", "pg"]

[[example]]
name = "040_repository"
required-features = ["repository", "sqlite"]

[[example]]
name = "050_tenancy_audit"
required-features = ["repository", "sqlite", "audit", "migrate", "pg"]

[package.metadata.docs.rs]
all-features = true

[package.metadata.id_effect]
# ADR 0010 crate tier — checked by scripts/tier-conformance.sh
tier = "integration"