We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
my wallet_balance default value(numeric) is 0 in my database, and the value is 0 too. here is my code
sqlx = { version = "0.3.4", features = [ "postgres", "bigdecimal" ] } use anyhow::Result; use sqlx::postgres::PgPool; use sqlx::{PgConnection, Pool}; use sqlx::prelude::*; use sqlx::types::BigDecimal; #[derive(Debug, sqlx::FromRow, sqlx::Type)] pub struct ClientMember { pub id: i32, pub wallet_balance: BigDecimal, } #[actix_rt::main] async fn main() -> Result<(), sqlx::Error> { let url = "postgres://postgres:postgres@localhost/my_db"; let pool = PgPool::builder() .max_size(5) .build(url).await?; let c = get_columns(pool).await?; println!("{:?}", c); Ok(()) } async fn get_columns(pool: Pool<PgConnection>) -> Result<ClientMember, sqlx::Error> { let rec = sqlx::query_as(r#"SELECT id,wallet_balance FROM my_table where id=$1"#) .bind(655929_i32) .fetch_one(&pool).await?; Ok(rec) }
it panic when i run the code, message:
thread 'main' panicked at 'assertion failed: !v.is_empty() && !radix.is_power_of_two()', /Users/xxx/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.2.6/src/biguint.rs:199:5 stack backtrace: 0: backtrace::backtrace::libunwind::trace at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86 1: backtrace::backtrace::trace_unsynchronized at /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66 2: std::sys_common::backtrace::_print_fmt at src/libstd/sys_common/backtrace.rs:78 3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt at src/libstd/sys_common/backtrace.rs:59 ...
But when i update my wallet_balance to 0.1, it works! Did i miss the derive or something else? i am new to rust. thanks.
derive
The text was updated successfully, but these errors were encountered:
This sounds like a bug to me, I'll look into it.
Sorry, something went wrong.
Yep, looks like Postgres sends an empty value array for 0 but we're not handling that properly.
fix and test handling of 0 for BigDecimal in Postgres/MySQL
6102a63
closes #283
c7db9cb
c285e28
Successfully merging a pull request may close this issue.
my wallet_balance default value(numeric) is 0 in my database, and the value is 0 too.
here is my code
it panic when i run the code,
message:
But when i update my wallet_balance to 0.1, it works! Did i miss the
derive
or something else?i am new to rust.
thanks.
The text was updated successfully, but these errors were encountered: