[package]
name         = "spg-sqlx"
version      = { workspace = true }
edition      = { workspace = true }
authors      = { workspace = true }
license      = { workspace = true }
repository   = { workspace = true }
description  = "sqlx 0.8 Database driver for spg-embedded — let in-process callers use sqlx::query / query_as / pool.begin against an in-process SPG without a TCP listener. Backs mailrs's drop-in PgPool → SpgPool swap (gap-eval E1)."

[lib]
name = "spg_sqlx"

[dependencies]
# Workspace SPG deps. spg-embedded carries the in-process Database;
# spg-embedded-tokio adds the async wrapper. spg-engine is pulled
# transitively through spg-embedded.
spg-embedded       = { workspace = true }
spg-embedded-tokio = { workspace = true }
# v7.17.0 Phase 3.P0-68 — the sqlx Vector / TsVector Decode
# helpers need `spg_storage::quantize::dequantize` and
# `HalfVector::to_f32_vec`. spg-storage is already in the
# transitive set via spg-embedded, but we declare it explicitly
# so the use sites can name it without a glob re-export.
spg-storage        = { workspace = true }
# sqlx-core ONLY — we implement Database against sqlx-core's traits;
# we don't ship our own runtime or macro layer. Users add sqlx
# itself for the query!() macro + runtime selection.
sqlx-core = { version = "0.8", default-features = false }
# Type bridges. chrono + serde_json + uuid match the type set mailrs
# uses against sqlx::Postgres today; surfacing them behind feature
# flags so consumers pay only for what they reach.
chrono     = { version = "0.4", default-features = false, features = ["clock", "std"], optional = true }
serde_json = { version = "1",   optional = true }
# v7.17.0 Phase 3.P0-67 — sqlx Encode/Decode for `NUMERIC` /
# `DECIMAL`. Gated behind the `bigdecimal` feature so consumers
# who only deal in INT / TEXT don't pay the dep cost.
bigdecimal = { version = "0.4", default-features = false, optional = true }
num-bigint = { version = "0.4", default-features = false, optional = true }
num-traits = { version = "0.2", default-features = false, optional = true }
# v7.17.0 Phase 3.P0-69 — Encode/Decode for `uuid::Uuid` against
# SPG's `UUID` column. P0-25 already ships `gen_random_uuid()` /
# `uuid_generate_v4()` and the storage / pgwire layers carry the
# canonical hyphenated form; the sqlx bridge here closes the
# typed end-to-end loop.
uuid       = { version = "1", default-features = false, optional = true }
# Standard async machinery.
futures-core = "0.3"
futures-util = { version = "0.3", default-features = false, features = ["std"] }
either      = "1"
log         = "0.4"
tokio       = { version = "1", features = ["sync"] }

[dev-dependencies]
tokio        = { version = "1", features = ["rt-multi-thread", "macros"] }
sqlx         = { version = "0.8", default-features = false, features = ["runtime-tokio"] }
chrono       = { version = "0.4", features = ["clock", "std"] }
serde_json   = "1"
bigdecimal   = "0.4"
uuid         = { version = "1", features = ["v4"] }

[features]
default = ["chrono", "json", "bigdecimal", "uuid"]
# `chrono` — Encode/Decode for chrono::DateTime<Utc> against
# SPG's TIMESTAMPTZ (post-v7.15.0 offset literal round-trip).
chrono  = ["dep:chrono"]
# `json` — Encode/Decode for serde_json::Value against
# SPG's JSON / JSONB columns.
json    = ["dep:serde_json"]
# v7.17.0 Phase 3.P0-67 — Encode/Decode for `bigdecimal::BigDecimal`
# against SPG's `NUMERIC(p, s)`. Opt-in: only consumers using
# arbitrary-precision math pay the dep cost.
bigdecimal = ["dep:bigdecimal", "dep:num-bigint", "dep:num-traits"]
# v7.17.0 Phase 3.P0-69 — Encode/Decode for `uuid::Uuid` against
# SPG's `UUID` column.
uuid       = ["dep:uuid"]
