Skip to content

Commit

Permalink
fix(postgres): allow rust_decimal::Decimal in PgRange
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Nov 1, 2021
1 parent d25ab07 commit c30b3f2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions sqlx-core/src/postgres/types/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c30b3f2

Please sign in to comment.