mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-23 10:38:57 +00:00
fix(postgres): allow rust_decimal::Decimal in PgRange (#1523)
* fix(postgres): allow rust_decimal::Decimal in PgRange * test(postgres): add tests for BigDecimal and Decimal in ranges
This commit is contained in:
@@ -142,6 +142,17 @@ impl Type<Postgres> for PgRange<bigdecimal::BigDecimal> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "decimal")]
|
||||
impl Type<Postgres> for PgRange<rust_decimal::Decimal> {
|
||||
fn type_info() -> PgTypeInfo {
|
||||
PgTypeInfo::NUM_RANGE
|
||||
}
|
||||
|
||||
fn compatible(ty: &PgTypeInfo) -> bool {
|
||||
range_compatible::<rust_decimal::Decimal>(ty)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "chrono")]
|
||||
impl Type<Postgres> for PgRange<chrono::NaiveDate> {
|
||||
fn type_info() -> PgTypeInfo {
|
||||
@@ -227,6 +238,13 @@ impl Type<Postgres> for [PgRange<bigdecimal::BigDecimal>] {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "decimal")]
|
||||
impl Type<Postgres> for [PgRange<rust_decimal::Decimal>] {
|
||||
fn type_info() -> PgTypeInfo {
|
||||
PgTypeInfo::NUM_RANGE_ARRAY
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "chrono")]
|
||||
impl Type<Postgres> for [PgRange<chrono::NaiveDate>] {
|
||||
fn type_info() -> PgTypeInfo {
|
||||
@@ -288,6 +306,13 @@ impl Type<Postgres> for Vec<PgRange<bigdecimal::BigDecimal>> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "decimal")]
|
||||
impl Type<Postgres> for Vec<PgRange<rust_decimal::Decimal>> {
|
||||
fn type_info() -> PgTypeInfo {
|
||||
PgTypeInfo::NUM_RANGE_ARRAY
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "chrono")]
|
||||
impl Type<Postgres> for Vec<PgRange<chrono::NaiveDate>> {
|
||||
fn type_info() -> PgTypeInfo {
|
||||
|
||||
Reference in New Issue
Block a user