sqlx
sqlx copied to clipboard
SQLx fails to compile with BigDecimal 0.4.x
Bug Description
SQLX with BigDecimal 0.4.1 fails to compile as big decimal because sqlx::Decode<'_, _>
is not implemented for bigdecimal::BigDecimal
.
Works fine with BigDecimal 0.3.x
.
Minimal Reproduction
#...
sqlx = { version = "0.7.1", features = ["runtime-tokio", "tls-rustls", "uuid", "bigdecimal", "postgres", "chrono", "migrate"] }
bigdecimal = { version = "0.4.1", features = ["serde"] }
#...
use bigdecimal::BigDecimal;
use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
use uuid::Uuid;
#[derive(Debug, Serialize, Deserialize, FromRow)]
pub struct SubscriptionPlan {
pub id: Uuid,
pub name: String,
pub price: BigDecimal,
pub allowed_number_of_ads: i64,
}
pub async fn get_subscription_plan_by_id(ctx: &Ctx, plan_id: Uuid) -> AppResult<SubscriptionPlan> {
let plan = sqlx::query_as::<_, SubscriptionPlan>(SELECT_PLAN_BY_ID)
.bind(plan_id)
.fetch_one(&ctx.postgres)
.await?;
Ok(plan)
}
Info
- SQLx version: 0.7.1
- SQLx features enabled: ["runtime-tokio", "tls-rustls", "uuid", "bigdecimal", "postgres", "chrono", "migrate" ]
- Database server and version: Postgres 15.01
- Operating system: Pop!_OS 22.04 LTS
-
rustc --version
: rustc 1.71.0 (8ede3aae2 2023-07-12)
having this issue too on sqlx 0.7.3, would be great to get the fix merged :smile:
I'm finding that 0.3.x
still has this problem:
bigdecimal = { version = "0.3.0", features = ["serde"] }
Closed by #2720