From 79fab4ab459c96bdbfb23d7be5d223030b298e54 Mon Sep 17 00:00:00 2001 From: Ivan Krivosheev Date: Sun, 9 Oct 2022 17:52:21 +0300 Subject: [PATCH] issues-336 Rebase from master --- sea-query-binder/src/sqlx_any.rs | 34 +-- sea-query-binder/src/sqlx_mysql.rs | 34 +-- sea-query-binder/src/sqlx_postgres.rs | 56 ++-- sea-query-binder/src/sqlx_sqlite.rs | 34 +-- sea-query-postgres/Cargo.toml | 3 +- sea-query-postgres/src/lib.rs | 50 ++-- src/backend/postgres/table.rs | 4 +- src/backend/query_builder.rs | 90 +++--- src/value.rs | 401 +++++++++++++++++--------- 9 files changed, 419 insertions(+), 287 deletions(-) diff --git a/sea-query-binder/src/sqlx_any.rs b/sea-query-binder/src/sqlx_any.rs index 7f6a67075..a44b4093d 100644 --- a/sea-query-binder/src/sqlx_any.rs +++ b/sea-query-binder/src/sqlx_any.rs @@ -49,7 +49,7 @@ impl<'q> sqlx::IntoArguments<'q, sqlx::any::Any> for SqlxValues { Value::Bytes(b) => { args.add(b.map(|b| *b)); } - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BoolArray(_) | Value::TinyIntArray(_) | Value::SmallIntArray(_) @@ -67,31 +67,31 @@ impl<'q> sqlx::IntoArguments<'q, sqlx::any::Any> for SqlxValues { Value::ChronoDate(d) => { args.add(d.map(|d| *d)); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateArray(_) => panic!("Array support not implemented for Any"), #[cfg(feature = "with-chrono")] Value::ChronoTime(t) => { args.add(t.map(|t| *t)); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoTimeArray(_) => panic!("Array support not implemented for Any"), #[cfg(feature = "with-chrono")] Value::ChronoDateTime(t) => { args.add(t.map(|t| *t)); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeArray(_) => panic!("Array support not implemented for Any"), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeUtc(t) => { args.add(t.map(|t| *t)); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeUtcArray(_) => panic!("Array support not implemented for Any"), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeLocal(t) => { args.add(t.map(|t| *t)); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeLocalArray(_) => { panic!("Array support not implemented for Any") } @@ -99,7 +99,7 @@ impl<'q> sqlx::IntoArguments<'q, sqlx::any::Any> for SqlxValues { Value::ChronoDateTimeWithTimeZone(t) => { args.add(Value::ChronoDateTimeWithTimeZone(t).chrono_as_naive_utc_in_string()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeWithTimeZoneArray(_) => { panic!("Array support not implemented for Any") } @@ -107,25 +107,25 @@ impl<'q> sqlx::IntoArguments<'q, sqlx::any::Any> for SqlxValues { Value::TimeDate(t) => { args.add(Value::TimeDate(t).time_as_naive_utc_in_string()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::TimeDateArray(_) => panic!("Array support not implemented for Any"), #[cfg(feature = "with-time")] Value::TimeTime(t) => { args.add(Value::TimeTime(t).time_as_naive_utc_in_string()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::TimeTimeArray(_) => panic!("Array support not implemented for Any"), #[cfg(feature = "with-time")] Value::TimeDateTime(t) => { args.add(Value::TimeDateTime(t).time_as_naive_utc_in_string()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::TimeDateTimeArray(_) => panic!("Array support not implemented for Any"), #[cfg(feature = "with-time")] Value::TimeDateTimeWithTimeZone(t) => { args.add(Value::TimeDateTimeWithTimeZone(t).time_as_naive_utc_in_string()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::TimeDateTimeWithTimeZoneArray(_) => { panic!("Array support not implemented for Any") } @@ -133,37 +133,37 @@ impl<'q> sqlx::IntoArguments<'q, sqlx::any::Any> for SqlxValues { Value::Uuid(_) => { panic!("UUID support not implemented for Any"); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::UuidArray(_) => panic!("Array support not implemented for Any"), #[cfg(feature = "with-rust_decimal")] Value::Decimal(_) => { panic!("Sqlite doesn't support decimal arguments"); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::DecimalArray(_) => panic!("Array support not implemented for Any"), #[cfg(feature = "with-bigdecimal")] Value::BigDecimal(_) => { panic!("Sqlite doesn't support bigdecimal arguments"); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::BigDecimalArray(_) => panic!("Array support not implemented for Any"), #[cfg(feature = "with-json")] Value::Json(_) => { panic!("Json support not implemented for Any"); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::JsonArray(_) => panic!("Array support not implemented for Any"), #[cfg(feature = "with-ipnetwork")] Value::IpNetwork(_) => { panic!("SeaQuery doesn't support IpNetwork arguments for Any"); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::IpNetworkArray(_) => panic!("Array support not implemented for Any"), #[cfg(feature = "with-mac_address")] Value::MacAddress(_) => { panic!("SeaQuery doesn't support MacAddress arguments for Any"); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::MacAddressArray(_) => panic!("Array support not implemented for Any"), } } diff --git a/sea-query-binder/src/sqlx_mysql.rs b/sea-query-binder/src/sqlx_mysql.rs index 57334129d..0bb4c9dbd 100644 --- a/sea-query-binder/src/sqlx_mysql.rs +++ b/sea-query-binder/src/sqlx_mysql.rs @@ -49,7 +49,7 @@ impl<'q> sqlx::IntoArguments<'q, sqlx::mysql::MySql> for SqlxValues { Value::Bytes(b) => { args.add(b.as_deref()); } - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BoolArray(_) | Value::TinyIntArray(_) | Value::SmallIntArray(_) @@ -67,97 +67,97 @@ impl<'q> sqlx::IntoArguments<'q, sqlx::mysql::MySql> for SqlxValues { Value::ChronoDate(d) => { args.add(d.as_deref()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-chrono")] Value::ChronoTime(t) => { args.add(t.as_deref()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoTimeArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-chrono")] Value::ChronoDateTime(t) => { args.add(t.as_deref()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeUtc(t) => { args.add(t.as_deref()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeUtcArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeLocal(t) => { args.add(t.as_deref()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeLocalArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeWithTimeZone(t) => { args.add(Value::ChronoDateTimeWithTimeZone(t).chrono_as_naive_utc_in_string()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeWithTimeZoneArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-time")] Value::TimeDate(t) => { args.add(t.as_deref()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::TimeDateArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-time")] Value::TimeTime(t) => { args.add(t.as_deref()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::TimeTimeArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-time")] Value::TimeDateTime(t) => { args.add(t.as_deref()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::TimeDateTimeArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-time")] Value::TimeDateTimeWithTimeZone(t) => { args.add(t.as_deref()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::TimeDateTimeWithTimeZoneArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-uuid")] Value::Uuid(uuid) => { args.add(uuid.as_deref()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::UuidArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-rust_decimal")] Value::Decimal(d) => { args.add(d.as_deref()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::DecimalArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-bigdecimal")] Value::BigDecimal(d) => { args.add(d.as_deref()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::BigDecimalArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-json")] Value::Json(j) => { args.add(j.as_deref()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::JsonArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-ipnetwork")] Value::IpNetwork(_) => { panic!("Mysql doesn't support IpNetwork arguments"); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::IpNetworkArray(_) => panic!("Mysql doesn't support array"), #[cfg(feature = "with-mac_address")] Value::MacAddress(_) => { panic!("Mysql doesn't support MacAddress arguments"); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::MacAddressArray(_) => panic!("Mysql doesn't support array"), } } diff --git a/sea-query-binder/src/sqlx_postgres.rs b/sea-query-binder/src/sqlx_postgres.rs index 406eb068d..68e692a77 100644 --- a/sea-query-binder/src/sqlx_postgres.rs +++ b/sea-query-binder/src/sqlx_postgres.rs @@ -49,115 +49,115 @@ impl<'q> sqlx::IntoArguments<'q, sqlx::postgres::Postgres> for SqlxValues { Value::Bytes(b) => { args.add(b.as_deref()); } - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BoolArray(v) => args.add(v.as_deref()), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::TinyIntArray(v) => args.add(v.as_deref()), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::SmallIntArray(v) => args.add(v.as_deref()), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::IntArray(v) => args.add(v.as_deref()), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BigIntArray(v) => args.add(v.as_deref()), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::SmallUnsignedArray(v) => { args.add(v.map(|v| v.iter().map(|&i| i as i32).collect::>())) } - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::UnsignedArray(v) => { args.add(v.map(|v| v.iter().map(|&i| i as i64).collect::>())) } - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BigUnsignedArray(v) => args.add(v.map(|v| { v.iter() .map(|&i| >::try_from(i).unwrap()) .collect::>() })), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::FloatArray(v) => args.add(v.as_deref()), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::DoubleArray(v) => args.add(v.as_deref()), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::StringArray(v) => args.add(v.as_deref()), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::CharArray(v) => { args.add(v.map(|v| v.iter().map(|c| c.to_string()).collect::>())) } #[cfg(feature = "with-chrono")] Value::ChronoDate(d) => args.add(d.as_deref()), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateArray(d) => args.add(d.as_deref()), #[cfg(feature = "with-chrono")] Value::ChronoTime(d) => args.add(d.as_deref()), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoTimeArray(d) => args.add(d.as_deref()), #[cfg(feature = "with-chrono")] Value::ChronoDateTime(d) => args.add(d.as_deref()), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeArray(d) => args.add(d.as_deref()), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeUtc(d) => args.add(d.as_deref()), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeUtcArray(d) => args.add(d.as_deref()), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeLocal(d) => args.add(d.as_deref()), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeLocalArray(d) => args.add(d.as_deref()), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeWithTimeZone(d) => args.add(d.as_deref()), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeWithTimeZoneArray(d) => args.add(d.as_deref()), #[cfg(feature = "with-time")] Value::TimeDate(t) => args.add(t.as_deref()), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateArray(t) => args.add(t.as_deref()), #[cfg(feature = "with-time")] Value::TimeTime(t) => args.add(t.as_deref()), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeTimeArray(t) => args.add(t.as_deref()), #[cfg(feature = "with-time")] Value::TimeDateTime(t) => args.add(t.as_deref()), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateTimeArray(t) => args.add(t.as_deref()), #[cfg(feature = "with-time")] Value::TimeDateTimeWithTimeZone(t) => args.add(t.as_deref()), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateTimeWithTimeZoneArray(t) => args.add(t.as_deref()), #[cfg(feature = "with-uuid")] Value::Uuid(uuid) => { args.add(uuid.as_deref()); } - #[cfg(all(feature = "with-uuid", feature = "with-array"))] + #[cfg(all(feature = "with-uuid", feature = "postgres-array"))] Value::UuidArray(uuid) => args.add(uuid.as_deref()), #[cfg(feature = "with-rust_decimal")] Value::Decimal(d) => { args.add(d.as_deref()); } - #[cfg(all(feature = "with-rust_decimal", feature = "with-array"))] + #[cfg(all(feature = "with-rust_decimal", feature = "postgres-array"))] Value::DecimalArray(d) => args.add(d.as_deref()), #[cfg(feature = "with-bigdecimal")] Value::BigDecimal(d) => { args.add(d.as_deref()); } - #[cfg(all(feature = "with-bigdecimal", feature = "with-array"))] + #[cfg(all(feature = "with-bigdecimal", feature = "postgres-array"))] Value::BigDecimalArray(d) => args.add(d.as_deref()), #[cfg(feature = "with-json")] Value::Json(j) => { args.add(j.as_deref()); } - #[cfg(all(feature = "with-json", feature = "with-array"))] + #[cfg(all(feature = "with-json", feature = "postgres-array"))] Value::JsonArray(d) => args.add(d.as_deref()), #[cfg(feature = "with-ipnetwork")] Value::IpNetwork(ip) => { args.add(ip.as_deref()); } - #[cfg(all(feature = "with-ipnetwork", feature = "with-array"))] + #[cfg(all(feature = "with-ipnetwork", feature = "postgres-array"))] Value::IpNetworkArray(d) => args.add(d.as_deref()), #[cfg(feature = "with-mac_address")] Value::MacAddress(mac) => { args.add(mac.as_deref()); } - #[cfg(all(feature = "with-mac_address", feature = "with-array"))] + #[cfg(all(feature = "with-mac_address", feature = "postgres-array"))] Value::MacAddressArray(d) => args.add(d.as_deref()), } } diff --git a/sea-query-binder/src/sqlx_sqlite.rs b/sea-query-binder/src/sqlx_sqlite.rs index 2e82691c4..411170877 100644 --- a/sea-query-binder/src/sqlx_sqlite.rs +++ b/sea-query-binder/src/sqlx_sqlite.rs @@ -49,7 +49,7 @@ impl<'q> sqlx::IntoArguments<'q, sqlx::sqlite::Sqlite> for SqlxValues { Value::Bytes(b) => { args.add(b.map(|b| *b)); } - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BoolArray(_) | Value::TinyIntArray(_) | Value::SmallIntArray(_) @@ -67,97 +67,97 @@ impl<'q> sqlx::IntoArguments<'q, sqlx::sqlite::Sqlite> for SqlxValues { Value::ChronoDate(d) => { args.add(d.map(|d| *d)); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-chrono")] Value::ChronoTime(t) => { args.add(t.map(|t| *t)); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoTimeArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-chrono")] Value::ChronoDateTime(t) => { args.add(t.map(|t| *t)); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeUtc(t) => { args.add(t.map(|t| *t)); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeUtcArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeLocal(t) => { args.add(t.map(|t| *t)); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeLocalArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeWithTimeZone(t) => { args.add(t.map(|t| *t)); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeWithTimeZoneArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-time")] Value::TimeDate(t) => { args.add(Value::TimeDate(t).time_as_naive_utc_in_string()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::TimeDateArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-time")] Value::TimeTime(t) => { args.add(Value::TimeTime(t).time_as_naive_utc_in_string()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::TimeTimeArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-time")] Value::TimeDateTime(t) => { args.add(Value::TimeDateTime(t).time_as_naive_utc_in_string()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::TimeDateTimeArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-time")] Value::TimeDateTimeWithTimeZone(t) => { args.add(Value::TimeDateTimeWithTimeZone(t).time_as_naive_utc_in_string()); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::TimeDateTimeWithTimeZoneArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-uuid")] Value::Uuid(uuid) => { args.add(uuid.map(|uuid| *uuid)); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::UuidArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-rust_decimal")] Value::Decimal(_) => { panic!("Sqlite doesn't support decimal arguments"); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::DecimalArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-bigdecimal")] Value::BigDecimal(_) => { panic!("Sqlite doesn't support bigdecimal arguments"); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::BigDecimalArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-json")] Value::Json(j) => { args.add(j.map(|j| *j)); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::JsonArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-ipnetwork")] Value::IpNetwork(_) => { panic!("Sqlite doesn't support IpNetwork arguments"); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::IpNetworkArray(_) => panic!("Sqlite doesn't support array"), #[cfg(feature = "with-mac_address")] Value::MacAddress(_) => { panic!("Sqlite doesn't support MacAddress arguments"); } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::MacAddressArray(_) => panic!("Sqlite doesn't support array"), } } diff --git a/sea-query-postgres/Cargo.toml b/sea-query-postgres/Cargo.toml index 4afd7aa49..467b05fed 100644 --- a/sea-query-postgres/Cargo.toml +++ b/sea-query-postgres/Cargo.toml @@ -29,6 +29,7 @@ with-rust_decimal = ["sea-query/with-rust_decimal", "rust_decimal/db-postgres"] with-bigdecimal = ["sea-query/with-bigdecimal"] with-uuid = ["postgres-types/with-uuid-1", "sea-query/with-uuid"] with-time = ["postgres-types/with-time-0_3", "sea-query/with-time"] -postgres-array = ["postgres-types/array-impls", "sea-query/postgres-array"] with-ipnetwork = ["sea-query/with-ipnetwork"] with-mac_address = ["sea-query/with-mac_address"] +postgres-array = ["postgres-types/array-impls", "sea-query/postgres-array"] + diff --git a/sea-query-postgres/src/lib.rs b/sea-query-postgres/src/lib.rs index 50b80dca2..d4e726020 100644 --- a/sea-query-postgres/src/lib.rs +++ b/sea-query-postgres/src/lib.rs @@ -73,27 +73,27 @@ impl ToSql for PostgresValue { Value::Double(v) => to_sql!(v, f64), Value::String(v) => v.as_deref().to_sql(ty, out), Value::Char(v) => v.map(|v| v.to_string()).to_sql(ty, out), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BoolArray(v) => v.as_deref().to_sql(ty, out), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::TinyIntArray(v) => v.as_deref().to_sql(ty, out), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::SmallIntArray(v) => v.as_deref().to_sql(ty, out), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::IntArray(v) => v.as_deref().to_sql(ty, out), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BigIntArray(v) => v.as_deref().to_sql(ty, out), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::SmallUnsignedArray(v) => v .as_deref() .map(|v| v.iter().map(|&i| i as u32).collect::>()) .to_sql(ty, out), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::UnsignedArray(v) => v .as_deref() .map(|v| v.iter().map(|&i| i as i64).collect::>()) .to_sql(ty, out), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BigUnsignedArray(v) => v .as_ref() .map(|v| { @@ -102,13 +102,13 @@ impl ToSql for PostgresValue { .collect::>() }) .to_sql(ty, out), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::FloatArray(v) => v.as_deref().to_sql(ty, out), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::DoubleArray(v) => v.as_deref().to_sql(ty, out), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::StringArray(v) => v.as_deref().to_sql(ty, out), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::CharArray(v) => v .as_ref() .map(|v| v.iter().map(|c| c.to_string()).collect::>()) @@ -116,55 +116,55 @@ impl ToSql for PostgresValue { Value::Bytes(v) => v.as_deref().to_sql(ty, out), #[cfg(feature = "with-json")] Value::Json(v) => v.as_deref().to_sql(ty, out), - #[cfg(all(feature = "with-json", feature = "with-array"))] + #[cfg(all(feature = "with-json", feature = "postgres-array"))] Value::JsonArray(v) => v.as_deref().to_sql(ty, out), #[cfg(feature = "with-chrono")] Value::ChronoDate(v) => v.as_deref().to_sql(ty, out), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateArray(v) => v.as_deref().to_sql(ty, out), #[cfg(feature = "with-chrono")] Value::ChronoTime(v) => v.as_deref().to_sql(ty, out), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoTimeArray(v) => v.as_deref().to_sql(ty, out), #[cfg(feature = "with-chrono")] Value::ChronoDateTime(v) => v.as_deref().to_sql(ty, out), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeArray(v) => v.as_deref().to_sql(ty, out), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeUtc(v) => v.as_deref().to_sql(ty, out), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeUtcArray(v) => v.as_deref().to_sql(ty, out), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeLocal(v) => v.as_deref().to_sql(ty, out), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeLocalArray(v) => v.as_deref().to_sql(ty, out), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeWithTimeZone(v) => v.as_deref().to_sql(ty, out), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeWithTimeZoneArray(v) => v.as_deref().to_sql(ty, out), #[cfg(feature = "with-time")] Value::TimeDate(v) => v.as_deref().to_sql(ty, out), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateArray(v) => v.as_deref().to_sql(ty, out), #[cfg(feature = "with-time")] Value::TimeTime(v) => v.as_deref().to_sql(ty, out), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeTimeArray(v) => v.as_deref().to_sql(ty, out), #[cfg(feature = "with-time")] Value::TimeDateTime(v) => v.as_deref().to_sql(ty, out), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateTimeArray(v) => v.as_deref().to_sql(ty, out), #[cfg(feature = "with-time")] Value::TimeDateTimeWithTimeZone(v) => v.as_deref().to_sql(ty, out), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateTimeWithTimeZoneArray(v) => v.as_deref().to_sql(ty, out), #[cfg(feature = "with-rust_decimal")] Value::Decimal(v) => v.as_deref().to_sql(ty, out), - #[cfg(all(feature = "postgres-rust_decimal", feature = "with-array"))] + #[cfg(all(feature = "postgres-rust_decimal", feature = "postgres-array"))] Value::DecimalArray(v) => v.as_deref().to_sql(ty, out), #[cfg(feature = "with-uuid")] Value::Uuid(v) => v.as_deref().to_sql(ty, out), - #[cfg(all(feature = "with-uuid", feature = "with-array"))] + #[cfg(all(feature = "with-uuid", feature = "postgres-array"))] Value::UuidArray(v) => v.as_deref().to_sql(ty, out), #[allow(unreachable_patterns)] _ => unimplemented!(), diff --git a/src/backend/postgres/table.rs b/src/backend/postgres/table.rs index 8640010c5..54016a115 100644 --- a/src/backend/postgres/table.rs +++ b/src/backend/postgres/table.rs @@ -97,9 +97,9 @@ impl TableBuilder for PostgresQueryBuilder { ColumnType::JsonBinary => "jsonb".into(), ColumnType::Uuid => "uuid".into(), ColumnType::Array(elem_type) => { - let mut inner = SqlWriter::new(); + let mut inner = String::new(); self.prepare_column_type(elem_type, &mut inner); - format!("{}[]", inner.result()) + format!("{}[]", inner) } ColumnType::Custom(iden) => iden.to_string(), ColumnType::Enum { name, .. } => name.to_string(), diff --git a/src/backend/query_builder.rs b/src/backend/query_builder.rs index eeda188ff..b2c18ba14 100644 --- a/src/backend/query_builder.rs +++ b/src/backend/query_builder.rs @@ -933,7 +933,7 @@ pub trait QueryBuilder: QuotedBuilder + EscapeBuilder + TableRefBuilder { | Value::String(None) | Value::Char(None) | Value::Bytes(None) => write!(s, "NULL").unwrap(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BoolArray(None) | Value::TinyIntArray(None) | Value::SmallIntArray(None) @@ -948,67 +948,67 @@ pub trait QueryBuilder: QuotedBuilder + EscapeBuilder + TableRefBuilder { | Value::CharArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-json")] Value::Json(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-json", feature = "with-array"))] + #[cfg(all(feature = "with-json", feature = "postgres-array"))] Value::JsonArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-chrono")] Value::ChronoDate(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-chrono")] Value::ChronoTime(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoTimeArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-chrono")] Value::ChronoDateTime(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeUtc(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeUtcArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeLocal(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeLocalArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeWithTimeZone(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeWithTimeZoneArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-time")] Value::TimeDate(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-time")] Value::TimeTime(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeTimeArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-time")] Value::TimeDateTime(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateTimeArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-time")] Value::TimeDateTimeWithTimeZone(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateTimeWithTimeZoneArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-rust_decimal")] Value::Decimal(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-rust_decimal", feature = "with-array"))] + #[cfg(all(feature = "with-rust_decimal", feature = "postgres-array"))] Value::DecimalArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-bigdecimal")] Value::BigDecimal(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-bigdecimal", feature = "with-array"))] + #[cfg(all(feature = "with-bigdecimal", feature = "postgres-array"))] Value::BigDecimalArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-uuid")] Value::Uuid(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-uuid", feature = "with-array"))] + #[cfg(all(feature = "with-uuid", feature = "postgres-array"))] Value::UuidArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-ipnetwork")] Value::IpNetwork(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-ipnetwork", feature = "with-array"))] + #[cfg(all(feature = "with-ipnetwork", feature = "postgres-array"))] Value::IpNetworkArray(None) => write!(s, "NULL").unwrap(), #[cfg(feature = "with-mac_address")] Value::MacAddress(None) => write!(s, "NULL").unwrap(), - #[cfg(all(feature = "with-mac_address", feature = "with-array"))] + #[cfg(all(feature = "with-mac_address", feature = "postgres-array"))] Value::MacAddressArray(None) => write!(s, "NULL").unwrap(), Value::Bool(Some(b)) => write!(s, "{}", if *b { "TRUE" } else { "FALSE" }).unwrap(), @@ -1032,84 +1032,84 @@ pub trait QueryBuilder: QuotedBuilder + EscapeBuilder + TableRefBuilder { v.iter().map(|b| format!("{:02X}", b)).collect::() ) .unwrap(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BoolArray(Some(_)) => todo!(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::TinyIntArray(Some(_)) => todo!(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::SmallIntArray(Some(_)) => todo!(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::IntArray(Some(_)) => todo!(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BigIntArray(Some(_)) => todo!(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::SmallUnsignedArray(Some(_)) => todo!(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::UnsignedArray(Some(_)) => todo!(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BigUnsignedArray(Some(_)) => todo!(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::FloatArray(Some(_)) => todo!(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::DoubleArray(Some(_)) => todo!(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::StringArray(Some(_)) => todo!(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::CharArray(Some(_)) => todo!(), #[cfg(feature = "with-json")] Value::Json(Some(v)) => self.write_string_quoted(&v.to_string(), &mut s), - #[cfg(all(feature = "with-json", feature = "with-array"))] + #[cfg(all(feature = "with-json", feature = "postgres-array"))] Value::JsonArray(Some(_)) => todo!(), #[cfg(feature = "with-chrono")] Value::ChronoDate(Some(v)) => write!(s, "'{}'", v.format("%Y-%m-%d")).unwrap(), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateArray(_) => todo!(), #[cfg(feature = "with-chrono")] Value::ChronoTime(Some(v)) => write!(s, "'{}'", v.format("%H:%M:%S")).unwrap(), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoTimeArray(_) => todo!(), #[cfg(feature = "with-chrono")] Value::ChronoDateTime(Some(v)) => { write!(s, "'{}'", v.format("%Y-%m-%d %H:%M:%S")).unwrap() } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeArray(_) => todo!(), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeUtc(Some(v)) => { write!(s, "'{}'", v.format("%Y-%m-%d %H:%M:%S %:z")).unwrap() } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeUtcArray(_) => todo!(), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeLocal(Some(v)) => { write!(s, "'{}'", v.format("%Y-%m-%d %H:%M:%S %:z")).unwrap() } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeLocalArray(_) => todo!(), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeWithTimeZone(Some(v)) => { write!(s, "'{}'", v.format("%Y-%m-%d %H:%M:%S %:z")).unwrap() } - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeWithTimeZoneArray(_) => todo!(), #[cfg(feature = "with-time")] Value::TimeDate(Some(v)) => { write!(s, "'{}'", v.format(time_format::FORMAT_DATE).unwrap()).unwrap() } - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateArray(_) => todo!(), #[cfg(feature = "with-time")] Value::TimeTime(Some(v)) => { write!(s, "'{}'", v.format(time_format::FORMAT_TIME).unwrap()).unwrap() } - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeTimeArray(_) => todo!(), #[cfg(feature = "with-time")] Value::TimeDateTime(Some(v)) => { write!(s, "'{}'", v.format(time_format::FORMAT_DATETIME).unwrap()).unwrap() } - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateTimeArray(_) => todo!(), #[cfg(feature = "with-time")] Value::TimeDateTimeWithTimeZone(Some(v)) => write!( @@ -1118,27 +1118,27 @@ pub trait QueryBuilder: QuotedBuilder + EscapeBuilder + TableRefBuilder { v.format(time_format::FORMAT_DATETIME_TZ).unwrap() ) .unwrap(), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateTimeWithTimeZoneArray(_) => todo!(), #[cfg(feature = "with-rust_decimal")] Value::Decimal(Some(v)) => write!(s, "{}", v).unwrap(), - #[cfg(all(feature = "with-rust_decimal", feature = "with-array"))] + #[cfg(all(feature = "with-rust_decimal", feature = "postgres-array"))] Value::DecimalArray(Some(_)) => todo!(), #[cfg(feature = "with-bigdecimal")] Value::BigDecimal(Some(v)) => write!(s, "{}", v).unwrap(), - #[cfg(all(feature = "with-bigdecimal", feature = "with-array"))] + #[cfg(all(feature = "with-bigdecimal", feature = "postgres-array"))] Value::BigDecimalArray(Some(_)) => todo!(), #[cfg(feature = "with-uuid")] Value::Uuid(Some(v)) => write!(s, "'{}'", v).unwrap(), - #[cfg(all(feature = "with-uuid", feature = "with-array"))] + #[cfg(all(feature = "with-uuid", feature = "postgres-array"))] Value::UuidArray(Some(_)) => todo!(), #[cfg(feature = "with-ipnetwork")] Value::IpNetwork(Some(v)) => write!(s, "'{}'", v).unwrap(), - #[cfg(all(feature = "with-ipnetwork", feature = "with-array"))] + #[cfg(all(feature = "with-ipnetwork", feature = "postgres-array"))] Value::IpNetworkArray(Some(_)) => todo!(), #[cfg(feature = "with-mac_address")] Value::MacAddress(Some(v)) => write!(s, "'{}'", v).unwrap(), - #[cfg(all(feature = "with-mac_address", feature = "with-array"))] + #[cfg(all(feature = "with-mac_address", feature = "postgres-array"))] Value::MacAddressArray(Some(_)) => todo!(), }; s diff --git a/src/value.rs b/src/value.rs index 554968cf5..a7609e373 100644 --- a/src/value.rs +++ b/src/value.rs @@ -50,29 +50,29 @@ pub enum Value { String(Option>), Char(Option), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] BoolArray(Option>), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] TinyIntArray(Option>), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] SmallIntArray(Option>), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] IntArray(Option>), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] BigIntArray(Option>), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] SmallUnsignedArray(Option>), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] UnsignedArray(Option>), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] BigUnsignedArray(Option>), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] FloatArray(Option>), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] DoubleArray(Option>), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] StringArray(Option>), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] CharArray(Option>), #[allow(clippy::box_collection)] @@ -81,124 +81,160 @@ pub enum Value { #[cfg(feature = "with-json")] #[cfg_attr(docsrs, doc(cfg(feature = "with-json")))] Json(Option>), - #[cfg(all(feature = "with-json", feature = "with-array"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "with-json", feature = "with-array"))))] + #[cfg(all(feature = "with-json", feature = "postgres-array"))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "with-json", feature = "postgres-array"))) + )] JsonArray(Option>), #[cfg(feature = "with-chrono")] #[cfg_attr(docsrs, doc(cfg(feature = "with-chrono")))] ChronoDate(Option>), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "with-chrono", feature = "with-array"))))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "with-chrono", feature = "postgres-array"))) + )] ChronoDateArray(Option>), #[cfg(feature = "with-chrono")] #[cfg_attr(docsrs, doc(cfg(feature = "with-chrono")))] ChronoTime(Option>), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "with-chrono", feature = "with-array"))))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "with-chrono", feature = "postgres-array"))) + )] ChronoTimeArray(Option>), #[cfg(feature = "with-chrono")] #[cfg_attr(docsrs, doc(cfg(feature = "with-chrono")))] ChronoDateTime(Option>), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "with-chrono", feature = "with-array"))))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "with-chrono", feature = "postgres-array"))) + )] ChronoDateTimeArray(Option>), #[cfg(feature = "with-chrono")] #[cfg_attr(docsrs, doc(cfg(feature = "with-chrono")))] ChronoDateTimeUtc(Option>>), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "with-chrono", feature = "with-array"))))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "with-chrono", feature = "postgres-array"))) + )] ChronoDateTimeUtcArray(Option>>), #[cfg(feature = "with-chrono")] #[cfg_attr(docsrs, doc(cfg(feature = "with-chrono")))] ChronoDateTimeLocal(Option>>), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "with-chrono", feature = "with-array"))))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "with-chrono", feature = "postgres-array"))) + )] ChronoDateTimeLocalArray(Option>>), #[cfg(feature = "with-chrono")] #[cfg_attr(docsrs, doc(cfg(feature = "with-chrono")))] ChronoDateTimeWithTimeZone(Option>>), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "with-chrono", feature = "with-array"))))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "with-chrono", feature = "postgres-array"))) + )] ChronoDateTimeWithTimeZoneArray(Option>>), #[cfg(feature = "with-time")] #[cfg_attr(docsrs, doc(cfg(feature = "with-time")))] TimeDate(Option>), - #[cfg(all(feature = "with-time", feature = "with-array"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "with-time", feature = "with-array"))))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "with-time", feature = "postgres-array"))) + )] TimeDateArray(Option>), #[cfg(feature = "with-time")] #[cfg_attr(docsrs, doc(cfg(feature = "with-time")))] TimeTime(Option>), - #[cfg(all(feature = "with-time", feature = "with-array"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "with-time", feature = "with-array"))))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "with-time", feature = "postgres-array"))) + )] TimeTimeArray(Option>), #[cfg(feature = "with-time")] #[cfg_attr(docsrs, doc(cfg(feature = "with-time")))] TimeDateTime(Option>), - #[cfg(all(feature = "with-time", feature = "with-array"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "with-time", feature = "with-array"))))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "with-time", feature = "postgres-array"))) + )] TimeDateTimeArray(Option>), #[cfg(feature = "with-time")] #[cfg_attr(docsrs, doc(cfg(feature = "with-time")))] TimeDateTimeWithTimeZone(Option>), - #[cfg(all(feature = "with-time", feature = "with-array"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "with-time", feature = "with-array"))))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "with-time", feature = "postgres-array"))) + )] TimeDateTimeWithTimeZoneArray(Option>), #[cfg(feature = "with-uuid")] #[cfg_attr(docsrs, doc(cfg(feature = "with-uuid")))] Uuid(Option>), - #[cfg(all(feature = "with-uuid", feature = "with-array"))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "with-uuid", feature = "with-array"))))] + #[cfg(all(feature = "with-uuid", feature = "postgres-array"))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "with-uuid", feature = "postgres-array"))) + )] UuidArray(Option>), #[cfg(feature = "with-rust_decimal")] #[cfg_attr(docsrs, doc(cfg(feature = "with-rust_decimal")))] Decimal(Option>), - #[cfg(all(feature = "with-rust_decimal", feature = "with-array"))] + #[cfg(all(feature = "with-rust_decimal", feature = "postgres-array"))] #[cfg_attr( docsrs, - doc(cfg(all(feature = "with-rust_decimal", feature = "with-array"))) + doc(cfg(all(feature = "with-rust_decimal", feature = "postgres-array"))) )] DecimalArray(Option>), #[cfg(feature = "with-bigdecimal")] #[cfg_attr(docsrs, doc(cfg(feature = "with-bigdecimal")))] BigDecimal(Option>), - #[cfg(all(feature = "with-bigdecimal", feature = "with-array"))] + #[cfg(all(feature = "with-bigdecimal", feature = "postgres-array"))] #[cfg_attr( docsrs, - doc(cfg(all(feature = "with-bigdecimal", feature = "with-array"))) + doc(cfg(all(feature = "with-bigdecimal", feature = "postgres-array"))) )] BigDecimalArray(Option>), #[cfg(feature = "with-ipnetwork")] #[cfg_attr(docsrs, doc(cfg(feature = "with-ipnetwork")))] IpNetwork(Option>), - #[cfg(all(feature = "with-ipnetwork", feature = "with-array"))] + #[cfg(all(feature = "with-ipnetwork", feature = "postgres-array"))] #[cfg_attr( docsrs, - doc(cfg(all(feature = "with-ipnetwork", feature = "with-array"))) + doc(cfg(all(feature = "with-ipnetwork", feature = "postgres-array"))) )] IpNetworkArray(Option>), #[cfg(feature = "with-mac_address")] #[cfg_attr(docsrs, doc(cfg(feature = "with-mac_address")))] MacAddress(Option>), - #[cfg(all(feature = "with-mac_address", feature = "with-array"))] + #[cfg(all(feature = "with-mac_address", feature = "postgres-array"))] #[cfg_attr( docsrs, - doc(cfg(all(feature = "with-mac_address", feature = "with-array"))) + doc(cfg(all(feature = "with-mac_address", feature = "postgres-array"))) )] MacAddressArray(Option>), } @@ -404,8 +440,8 @@ where type_to_box_value!(Vec, Bytes, Binary(BlobSize::Blob(None))); type_to_box_value!(String, String, String(None)); -#[cfg(feature = "with-array")] -#[cfg_attr(docsrs, doc(cfg(feature = "with-array")))] +#[cfg(feature = "postgres-array")] +#[cfg_attr(docsrs, doc(cfg(feature = "postgres-array")))] mod with_array { use super::*; @@ -438,7 +474,7 @@ mod with_json { type_to_box_value!(Json, Json, Json); - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!(Vec, JsonArray, Array(Box::new(Json))); } @@ -540,29 +576,29 @@ mod with_chrono { } } - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!(Vec, ChronoDateArray, Array(Box::new(Date))); - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!(Vec, ChronoTimeArray, Array(Box::new(Time(None)))); - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!( Vec, ChronoDateTimeArray, Array(Box::new(DateTime(None))) ); - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!( Vec>, ChronoDateTimeLocalArray, Array(Box::new(TimestampWithTimeZone(None))) ); - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!( Vec>, ChronoDateTimeUtcArray, Array(Box::new(TimestampWithTimeZone(None))) ); - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!( Vec>, ChronoDateTimeWithTimeZoneArray, @@ -624,17 +660,17 @@ mod with_time { } } - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!(Vec, TimeDateArray, Array(Box::new(Date))); - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!(Vec, TimeTimeArray, Array(Box::new(Time(None)))); - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!( Vec, TimeDateTimeArray, Array(Box::new(DateTime(None))) ); - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!( Vec, TimeDateTimeWithTimeZoneArray, @@ -649,7 +685,7 @@ mod with_rust_decimal { type_to_box_value!(Decimal, Decimal, Decimal(None)); - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!(Vec, DecimalArray, Array(Box::new(Decimal(None)))); } @@ -660,7 +696,7 @@ mod with_bigdecimal { type_to_box_value!(BigDecimal, BigDecimal, Decimal(None)); - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!( Vec, BigDecimalArray, @@ -674,12 +710,8 @@ mod with_uuid { use super::*; type_to_box_value!(Uuid, Uuid, Uuid); - #[cfg(feature = "with-array")] - type_to_value!( - Vec, - UuidArray, - Array(Box::new(Uuid)) - ); + #[cfg(feature = "postgres-array")] + type_to_value!(Vec, UuidArray, Array(Box::new(Uuid))); } #[cfg(feature = "with-ipnetwork")] @@ -689,7 +721,7 @@ mod with_ipnetwork { type_to_box_value!(IpNetwork, IpNetwork, Inet); - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!(Vec, IpNetworkArray, Array(Box::new(Inet))); } @@ -700,7 +732,7 @@ mod with_mac_address { type_to_box_value!(MacAddress, MacAddress, MacAddr); - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] type_to_value!(Vec, MacAddressArray, Array(Box::new(MacAddr))); } @@ -722,21 +754,41 @@ macro_rules! impl_value_methods { #[cfg(feature = "with-json")] impl_value_methods!(Json, is_json, as_ref_json, Json); -#[cfg(all(feature = "with-json", feature = "with-array"))] +#[cfg(all(feature = "with-json", feature = "postgres-array"))] impl_value_methods!(JsonArray, is_json_array, as_ref_json_array, [Json]); #[cfg(feature = "with-time")] impl_value_methods!(ChronoDate, is_chrono_date, as_ref_chrono_date, NaiveDate); #[cfg(feature = "with-time")] -impl_value_methods!(ChronoDateTime, is_chrono_date_time, as_ref_chrono_date_time, NaiveDateTime); +impl_value_methods!( + ChronoDateTime, + is_chrono_date_time, + as_ref_chrono_date_time, + NaiveDateTime +); #[cfg(feature = "with-time")] impl_value_methods!(ChronoTime, is_chrono_time, as_ref_chrono_time, NaiveTime); #[cfg(feature = "with-time")] -impl_value_methods!(ChronoDateTimeUtc, is_chrono_date_time_utc, as_ref_chrono_date_time_utc, DateTime); +impl_value_methods!( + ChronoDateTimeUtc, + is_chrono_date_time_utc, + as_ref_chrono_date_time_utc, + DateTime +); #[cfg(feature = "with-time")] -impl_value_methods!(ChronoDateTimeLocal, is_chrono_date_time_local, as_ref_chrono_date_time_local, DateTime); +impl_value_methods!( + ChronoDateTimeLocal, + is_chrono_date_time_local, + as_ref_chrono_date_time_local, + DateTime +); #[cfg(feature = "with-time")] -impl_value_methods!(ChronoDateTimeWithTimeZone, is_chrono_date_time_with_time_zone, as_ref_chrono_date_time_with_time_zone, DateTime); +impl_value_methods!( + ChronoDateTimeWithTimeZone, + is_chrono_date_time_with_time_zone, + as_ref_chrono_date_time_with_time_zone, + DateTime +); #[cfg(feature = "with-chrono")] impl Value { pub fn chrono_as_naive_utc_in_string(&self) -> Option { @@ -751,27 +803,67 @@ impl Value { } } } -#[cfg(all(feature = "with-chrono", feature = "with-array"))] -impl_value_methods!(ChronoDateArray, is_chrono_date_array, as_ref_chrono_date_array, [NaiveDate]); -#[cfg(all(feature = "with-chrono", feature = "with-array"))] -impl_value_methods!(ChronoDateTimeArray, is_chrono_date_time_array, as_ref_chrono_date_time_array, [NaiveDateTime]); -#[cfg(all(feature = "with-chrono", feature = "with-array"))] -impl_value_methods!(ChronoTimeArray, is_chrono_time_array, as_ref_chrono_time_array, [NaiveTime]); -#[cfg(all(feature = "with-chrono", feature = "with-array"))] -impl_value_methods!(ChronoDateTimeUtcArray, is_chrono_date_time_utc_array, as_ref_chrono_date_time_utc_array, [DateTime]); -#[cfg(all(feature = "with-chrono", feature = "with-array"))] -impl_value_methods!(ChronoDateTimeLocalArray, is_chrono_date_time_local_array, as_ref_chrono_date_time_local_array, [DateTime]); -#[cfg(all(feature = "with-chrono", feature = "with-array"))] -impl_value_methods!(ChronoDateTimeWithTimeZoneArray, is_chrono_date_time_with_time_zone_array, as_ref_chrono_date_time_with_time_zone_array, [DateTime]); +#[cfg(all(feature = "with-chrono", feature = "postgres-array"))] +impl_value_methods!( + ChronoDateArray, + is_chrono_date_array, + as_ref_chrono_date_array, + [NaiveDate] +); +#[cfg(all(feature = "with-chrono", feature = "postgres-array"))] +impl_value_methods!( + ChronoDateTimeArray, + is_chrono_date_time_array, + as_ref_chrono_date_time_array, + [NaiveDateTime] +); +#[cfg(all(feature = "with-chrono", feature = "postgres-array"))] +impl_value_methods!( + ChronoTimeArray, + is_chrono_time_array, + as_ref_chrono_time_array, + [NaiveTime] +); +#[cfg(all(feature = "with-chrono", feature = "postgres-array"))] +impl_value_methods!( + ChronoDateTimeUtcArray, + is_chrono_date_time_utc_array, + as_ref_chrono_date_time_utc_array, + [DateTime] +); +#[cfg(all(feature = "with-chrono", feature = "postgres-array"))] +impl_value_methods!( + ChronoDateTimeLocalArray, + is_chrono_date_time_local_array, + as_ref_chrono_date_time_local_array, + [DateTime] +); +#[cfg(all(feature = "with-chrono", feature = "postgres-array"))] +impl_value_methods!( + ChronoDateTimeWithTimeZoneArray, + is_chrono_date_time_with_time_zone_array, + as_ref_chrono_date_time_with_time_zone_array, + [DateTime] +); #[cfg(feature = "with-time")] impl_value_methods!(TimeDate, is_time_date, as_ref_time_date, time::Date); #[cfg(feature = "with-time")] impl_value_methods!(TimeTime, is_time_time, as_ref_time_time, time::Time); #[cfg(feature = "with-time")] -impl_value_methods!(TimeDateTime, is_time_date_time, as_ref_time_date_time, PrimitiveDateTime); +impl_value_methods!( + TimeDateTime, + is_time_date_time, + as_ref_time_date_time, + PrimitiveDateTime +); #[cfg(feature = "with-time")] -impl_value_methods!(TimeDateTimeWithTimeZone, is_time_date_time_with_time_zone, as_ref_time_date_time_with_time_zone, OffsetDateTime); +impl_value_methods!( + TimeDateTimeWithTimeZone, + is_time_date_time_with_time_zone, + as_ref_time_date_time_with_time_zone, + OffsetDateTime +); #[cfg(feature = "with-time")] impl Value { pub fn time_as_naive_utc_in_string(&self) -> Option { @@ -794,14 +886,34 @@ impl Value { } } } -#[cfg(all(feature = "with-time", feature = "with-array"))] -impl_value_methods!(TimeDateArray, is_time_date_array, as_ref_time_date_array, [time::Date]); -#[cfg(all(feature = "with-time", feature = "with-array"))] -impl_value_methods!(TimeTimeArray, is_time_time_array, as_ref_time_time_array, [time::Time]); -#[cfg(all(feature = "with-time", feature = "with-array"))] -impl_value_methods!(TimeDateTimeArray, is_time_date_time_array, as_ref_time_date_time_array, [PrimitiveDateTime]); -#[cfg(all(feature = "with-time", feature = "with-array"))] -impl_value_methods!(TimeDateTimeWithTimeZoneArray, is_time_date_time_with_time_zone_array, as_ref_time_date_time_with_time_zone_array, [OffsetDateTime]); +#[cfg(all(feature = "with-time", feature = "postgres-array"))] +impl_value_methods!( + TimeDateArray, + is_time_date_array, + as_ref_time_date_array, + [time::Date] +); +#[cfg(all(feature = "with-time", feature = "postgres-array"))] +impl_value_methods!( + TimeTimeArray, + is_time_time_array, + as_ref_time_time_array, + [time::Time] +); +#[cfg(all(feature = "with-time", feature = "postgres-array"))] +impl_value_methods!( + TimeDateTimeArray, + is_time_date_time_array, + as_ref_time_date_time_array, + [PrimitiveDateTime] +); +#[cfg(all(feature = "with-time", feature = "postgres-array"))] +impl_value_methods!( + TimeDateTimeWithTimeZoneArray, + is_time_date_time_with_time_zone_array, + as_ref_time_date_time_with_time_zone_array, + [OffsetDateTime] +); #[cfg(feature = "with-rust_decimal")] impl_value_methods!(Decimal, is_decimal, as_ref_decimal, Decimal); @@ -813,8 +925,13 @@ impl Value { self.as_ref_decimal().and_then(|d| d.to_f64()) } } -#[cfg(all(feature = "with-rust_decimal", feature = "with-array"))] -impl_value_methods!(DecimalArray, is_decimal_array, as_ref_decimal_array, [Decimal]); +#[cfg(all(feature = "with-rust_decimal", feature = "postgres-array"))] +impl_value_methods!( + DecimalArray, + is_decimal_array, + as_ref_decimal_array, + [Decimal] +); #[cfg(feature = "with-bigdecimal")] impl_value_methods!(BigDecimal, is_big_decimal, as_ref_big_decimal, BigDecimal); @@ -825,12 +942,17 @@ impl Value { self.as_ref_big_decimal().map(|d| d.to_f64().unwrap()) } } -#[cfg(all(feature = "with-bigdecimal", feature = "with-array"))] -impl_value_methods!(BigDecimalArray, is_big_decimal_array, as_ref_big_decimal_array, [BigDecimal]); +#[cfg(all(feature = "with-bigdecimal", feature = "postgres-array"))] +impl_value_methods!( + BigDecimalArray, + is_big_decimal_array, + as_ref_big_decimal_array, + [BigDecimal] +); #[cfg(feature = "with-uuid")] impl_value_methods!(Uuid, is_uuid, as_ref_uuid, Uuid); -#[cfg(all(feature = "with-uuid", feature = "with-array"))] +#[cfg(all(feature = "with-uuid", feature = "postgres-array"))] impl_value_methods!(UuidArray, is_uuid_array, as_ref_uuid_array, [Uuid]); #[cfg(feature = "with-ipnetwork")] @@ -838,17 +960,26 @@ impl_value_methods!(IpNetwork, is_ipnetwork, as_ref_ipnetwork, IpNetwork); #[cfg(feature = "with-ipnetwork")] impl Value { pub fn as_ipaddr(&self) -> Option { - self.as_ref_ipnetwork().map(|v|v.network()) + self.as_ref_ipnetwork().map(|v| v.network()) } } -#[cfg(all(feature = "with-ipnetwork", feature = "with-array"))] -impl_value_methods!(IpNetworkArray, is_ipnetwork_array, as_ref_ipnetwork_array, [IpNetwork]); +#[cfg(all(feature = "with-ipnetwork", feature = "postgres-array"))] +impl_value_methods!( + IpNetworkArray, + is_ipnetwork_array, + as_ref_ipnetwork_array, + [IpNetwork] +); #[cfg(feature = "with-mac_address")] impl_value_methods!(MacAddress, is_mac_address, as_ref_mac_address, MacAddress); -#[cfg(all(feature = "with-mac_address", feature = "with-array"))] -impl_value_methods!(MacAddressArray, is_mac_address_array, as_ref_mac_address_array, [MacAddress]); - +#[cfg(all(feature = "with-mac_address", feature = "postgres-array"))] +impl_value_methods!( + MacAddressArray, + is_mac_address_array, + as_ref_mac_address_array, + [MacAddress] +); impl IntoIterator for ValueTuple { type Item = Value; @@ -1089,7 +1220,7 @@ pub fn sea_value_to_json_value(value: &Value) -> Json { | Value::Char(None) | Value::Bytes(None) | Value::Json(None) => Json::Null, - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BoolArray(None) | Value::TinyIntArray(None) | Value::SmallIntArray(None) @@ -1113,7 +1244,7 @@ pub fn sea_value_to_json_value(value: &Value) -> Json { Value::IpNetwork(None) => Json::Null, #[cfg(feature = "with-mac_address")] Value::MacAddress(None) => Json::Null, - #[cfg(all(feature = "with-uuid", feature = "with-array"))] + #[cfg(all(feature = "with-uuid", feature = "postgres-array"))] Value::UuidArray(None) => Json::Null, Value::Bool(Some(b)) => Json::Bool(*b), @@ -1131,31 +1262,31 @@ pub fn sea_value_to_json_value(value: &Value) -> Json { Value::Char(Some(v)) => Json::String(v.to_string()), Value::Bytes(Some(s)) => Json::String(from_utf8(s).unwrap().to_string()), Value::Json(Some(v)) => v.as_ref().clone(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::JsonArray(Some(v)) => v.as_slice().into(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BoolArray(Some(v)) => v.as_slice().into(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::TinyIntArray(Some(v)) => v.as_slice().into(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::SmallIntArray(Some(v)) => v.as_slice().into(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::IntArray(Some(v)) => v.as_slice().into(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BigIntArray(Some(v)) => v.as_slice().into(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::SmallUnsignedArray(Some(v)) => v.as_slice().into(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::UnsignedArray(Some(v)) => v.as_slice().into(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::BigUnsignedArray(Some(v)) => v.as_slice().into(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::FloatArray(Some(v)) => v.as_slice().into(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::DoubleArray(Some(v)) => v.as_slice().into(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::StringArray(Some(v)) => v.as_slice().into(), - #[cfg(feature = "with-array")] + #[cfg(feature = "postgres-array")] Value::CharArray(Some(v)) => v .iter() .map(|c| c.to_string()) @@ -1163,46 +1294,46 @@ pub fn sea_value_to_json_value(value: &Value) -> Json { .into(), #[cfg(feature = "with-chrono")] Value::ChronoDate(_) => CommonSqlQueryBuilder.value_to_string(value).into(), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateArray(_) => CommonSqlQueryBuilder.value_to_string(value).into(), #[cfg(feature = "with-chrono")] Value::ChronoTime(_) => CommonSqlQueryBuilder.value_to_string(value).into(), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoTimeArray(_) => CommonSqlQueryBuilder.value_to_string(value).into(), #[cfg(feature = "with-chrono")] Value::ChronoDateTime(_) => CommonSqlQueryBuilder.value_to_string(value).into(), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeArray(_) => CommonSqlQueryBuilder.value_to_string(value).into(), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeWithTimeZone(_) => CommonSqlQueryBuilder.value_to_string(value).into(), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeWithTimeZoneArray(_) => { CommonSqlQueryBuilder.value_to_string(value).into() } #[cfg(feature = "with-chrono")] Value::ChronoDateTimeUtc(_) => CommonSqlQueryBuilder.value_to_string(value).into(), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeUtcArray(_) => CommonSqlQueryBuilder.value_to_string(value).into(), #[cfg(feature = "with-chrono")] Value::ChronoDateTimeLocal(_) => CommonSqlQueryBuilder.value_to_string(value).into(), - #[cfg(all(feature = "with-chrono", feature = "with-array"))] + #[cfg(all(feature = "with-chrono", feature = "postgres-array"))] Value::ChronoDateTimeLocalArray(_) => CommonSqlQueryBuilder.value_to_string(value).into(), #[cfg(feature = "with-time")] Value::TimeDate(_) => CommonSqlQueryBuilder.value_to_string(value).into(), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateArray(_) => CommonSqlQueryBuilder.value_to_string(value).into(), #[cfg(feature = "with-time")] Value::TimeTime(_) => CommonSqlQueryBuilder.value_to_string(value).into(), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeTimeArray(_) => CommonSqlQueryBuilder.value_to_string(value).into(), #[cfg(feature = "with-time")] Value::TimeDateTime(_) => CommonSqlQueryBuilder.value_to_string(value).into(), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateTimeArray(_) => CommonSqlQueryBuilder.value_to_string(value).into(), #[cfg(feature = "with-time")] Value::TimeDateTimeWithTimeZone(_) => CommonSqlQueryBuilder.value_to_string(value).into(), - #[cfg(all(feature = "with-time", feature = "with-array"))] + #[cfg(all(feature = "with-time", feature = "postgres-array"))] Value::TimeDateTimeWithTimeZoneArray(_) => { CommonSqlQueryBuilder.value_to_string(value).into() } @@ -1212,18 +1343,18 @@ pub fn sea_value_to_json_value(value: &Value) -> Json { use rust_decimal::prelude::ToPrimitive; v.as_ref().to_f64().unwrap().into() } - #[cfg(all(feature = "with-rust_decimal", feature = "with-array"))] + #[cfg(all(feature = "with-rust_decimal", feature = "postgres-array"))] Value::DecimalArray(_) => CommonSqlQueryBuilder.value_to_string(value).into(), #[cfg(feature = "with-bigdecimal")] Value::BigDecimal(Some(v)) => { use bigdecimal::ToPrimitive; v.as_ref().to_f64().unwrap().into() } - #[cfg(all(feature = "with-bigdecimal", feature = "with-array"))] + #[cfg(all(feature = "with-bigdecimal", feature = "postgres-array"))] Value::BigDecimalArray(_) => CommonSqlQueryBuilder.value_to_string(value).into(), #[cfg(feature = "with-uuid")] Value::Uuid(Some(v)) => Json::String(v.to_string()), - #[cfg(all(feature = "with-uuid", feature = "with-array"))] + #[cfg(all(feature = "with-uuid", feature = "postgres-array"))] Value::UuidArray(Some(v)) => v .iter() .map(|v| v.to_string()) @@ -1231,11 +1362,11 @@ pub fn sea_value_to_json_value(value: &Value) -> Json { .into(), #[cfg(feature = "with-ipnetwork")] Value::IpNetwork(Some(_)) => CommonSqlQueryBuilder.value_to_string(value).into(), - #[cfg(all(feature = "with-ipnetwork", feature = "with-array"))] + #[cfg(all(feature = "with-ipnetwork", feature = "postgres-array"))] Value::IpNetworkArray(_) => CommonSqlQueryBuilder.value_to_string(value).into(), #[cfg(feature = "with-mac_address")] Value::MacAddress(_) => CommonSqlQueryBuilder.value_to_string(value).into(), - #[cfg(all(feature = "with-mac_address", feature = "with-array"))] + #[cfg(all(feature = "with-mac_address", feature = "postgres-array"))] Value::MacAddressArray(_) => CommonSqlQueryBuilder.value_to_string(value).into(), } }