diff --git a/sqlx-macros-core/src/database/postgres.rs b/sqlx-macros-core/src/database/postgres.rs index 2c2d461f..0bd6b4c8 100644 --- a/sqlx-macros-core/src/database/postgres.rs +++ b/sqlx-macros-core/src/database/postgres.rs @@ -59,7 +59,7 @@ impl_database_ext! { #[cfg(feature = "bigdecimal")] sqlx::types::BigDecimal, - #[cfg(feature = "decimal")] + #[cfg(feature = "rust_decimal")] sqlx::types::Decimal, #[cfg(feature = "ipnetwork")] @@ -118,7 +118,7 @@ impl_database_ext! { #[cfg(feature = "bigdecimal")] Vec | &[sqlx::types::BigDecimal], - #[cfg(feature = "decimal")] + #[cfg(feature = "rust_decimal")] Vec | &[sqlx::types::Decimal], #[cfg(feature = "ipnetwork")] @@ -138,7 +138,7 @@ impl_database_ext! { #[cfg(feature = "bigdecimal")] sqlx::postgres::types::PgRange, - #[cfg(feature = "decimal")] + #[cfg(feature = "rust_decimal")] sqlx::postgres::types::PgRange, #[cfg(feature = "chrono")] diff --git a/sqlx-postgres/Cargo.toml b/sqlx-postgres/Cargo.toml index 1094f09f..0fd05720 100644 --- a/sqlx-postgres/Cargo.toml +++ b/sqlx-postgres/Cargo.toml @@ -16,7 +16,7 @@ migrate = ["sqlx-core/migrate"] offline = ["sqlx-core/offline"] # Type integration features which require additional dependencies -rust_decimal = ["dep:rust_decimal"] +rust_decimal = ["dep:rust_decimal", "dep:num-bigint"] bigdecimal = ["dep:bigdecimal", "dep:num-bigint"] [dependencies] diff --git a/sqlx-postgres/src/types/mod.rs b/sqlx-postgres/src/types/mod.rs index 8749fe28..c0dd5c91 100644 --- a/sqlx-postgres/src/types/mod.rs +++ b/sqlx-postgres/src/types/mod.rs @@ -196,7 +196,7 @@ mod time_tz; #[cfg(feature = "bigdecimal")] mod bigdecimal; -#[cfg(any(feature = "bigdecimal", feature = "decimal"))] +#[cfg(any(feature = "bigdecimal", feature = "rust_decimal"))] mod numeric; #[cfg(feature = "rust_decimal")] diff --git a/sqlx-postgres/src/types/money.rs b/sqlx-postgres/src/types/money.rs index 4d00f4b5..963186be 100644 --- a/sqlx-postgres/src/types/money.rs +++ b/sqlx-postgres/src/types/money.rs @@ -81,7 +81,7 @@ impl PgMoney { /// See the type-level docs for an explanation of `locale_frac_digits`. /// /// [`Decimal`]: crate::types::Decimal - #[cfg(feature = "decimal")] + #[cfg(feature = "rust_decimal")] pub fn to_decimal(self, locale_frac_digits: u32) -> rust_decimal::Decimal { rust_decimal::Decimal::new(self.0, locale_frac_digits) } @@ -94,7 +94,7 @@ impl PgMoney { /// If the value is larger than 63 bits it will be truncated. /// /// [`Decimal`]: crate::types::Decimal - #[cfg(feature = "decimal")] + #[cfg(feature = "rust_decimal")] pub fn from_decimal(mut decimal: rust_decimal::Decimal, locale_frac_digits: u32) -> Self { // this is all we need to convert to our expected locale's `frac_digits` decimal.rescale(locale_frac_digits); @@ -316,7 +316,7 @@ mod tests { } #[test] - #[cfg(feature = "decimal")] + #[cfg(feature = "rust_decimal")] fn conversion_to_decimal_works() { assert_eq!( rust_decimal::Decimal::new(12345, 2), @@ -325,7 +325,7 @@ mod tests { } #[test] - #[cfg(feature = "decimal")] + #[cfg(feature = "rust_decimal")] fn conversion_from_decimal_works() { assert_eq!( PgMoney(12345), diff --git a/sqlx-postgres/src/types/range.rs b/sqlx-postgres/src/types/range.rs index ba4b7d36..2152808d 100644 --- a/sqlx-postgres/src/types/range.rs +++ b/sqlx-postgres/src/types/range.rs @@ -143,7 +143,7 @@ impl Type for PgRange { } } -#[cfg(feature = "decimal")] +#[cfg(feature = "rust_decimal")] impl Type for PgRange { fn type_info() -> PgTypeInfo { PgTypeInfo::NUM_RANGE