diff --git a/Cargo.toml b/Cargo.toml index c604ad9e14..4f76aa7b90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,6 +51,7 @@ inventory = { version = "0.3", optional = true } ipnetwork = { version = "0.20", default-features = false, optional = true } itertools = "0.14.0" log = { version = "0.4", default-features = false } +mac_address = { version = "1.1", default-features = false, optional = true } ouroboros = { version = "0.18", default-features = false } pgvector = { version = "~0.4", default-features = false, optional = true } rust_decimal = { version = "1", default-features = false, features = [ @@ -134,7 +135,7 @@ postgres-vector = [ "sea-query/postgres-vector", "sea-query-sqlx?/postgres-vector", ] -proxy = ["serde_json", "serde/derive"] +proxy = ["serde/derive"] rbac = ["sea-query/audit", "macros"] runtime-async-std = ["sqlx?/runtime-async-std"] runtime-async-std-native-tls = [ @@ -211,9 +212,15 @@ with-json = [ "bigdecimal?/serde", "uuid?/serde", "time?/serde", + "mac_address?/serde", "pgvector?/serde", "sea-query-sqlx?/with-json", ] +with-mac_address = [ + "mac_address", + "sea-query/with-mac_address", + "sea-query-sqlx?/with-mac_address", +] with-rust_decimal = [ "rust_decimal", "sea-query/with-rust_decimal", diff --git a/src/driver/sqlx_postgres.rs b/src/driver/sqlx_postgres.rs index 9c602a630e..1c9f51cf4f 100644 --- a/src/driver/sqlx_postgres.rs +++ b/src/driver/sqlx_postgres.rs @@ -626,12 +626,16 @@ pub(crate) fn from_sqlx_postgres_row_to_proxy_row(row: &sqlx::postgres::PgRow) - }), ), + #[cfg(feature = "with-json")] "JSON" | "JSONB" => Value::Json( row.try_get::, _>(c.ordinal()) .expect("Failed to get json") .map(Box::new), ), - #[cfg(any(feature = "json-array", feature = "postgres-array"))] + #[cfg(all( + feature = "with-json", + any(feature = "json-array", feature = "postgres-array") + ))] "JSON[]" | "JSONB[]" => Value::Array( sea_query::ArrayType::Json, row.try_get::>, _>(c.ordinal()) diff --git a/src/dynamic/model.rs b/src/dynamic/model.rs index 576e3a9203..fe3fe30518 100644 --- a/src/dynamic/model.rs +++ b/src/dynamic/model.rs @@ -135,6 +135,9 @@ fn try_get(res: &QueryResult, pre: &str, col: &str, ty: &ArrayType) -> Result Value::IpNetwork(res.try_get(pre, col)?), + + #[cfg(feature = "with-mac_address")] + ArrayType::MacAddress => Value::MacAddress(res.try_get(pre, col)?), }) } diff --git a/src/executor/query.rs b/src/executor/query.rs index 55bf1b6a1f..16667d9ab6 100644 --- a/src/executor/query.rs +++ b/src/executor/query.rs @@ -877,6 +877,9 @@ try_getable_uuid!(uuid::fmt::Urn, uuid::Uuid::urn); #[cfg(feature = "with-ipnetwork")] try_getable_postgres!(ipnetwork::IpNetwork); +#[cfg(feature = "with-mac_address")] +try_getable_postgres!(mac_address::MacAddress); + impl TryGetable for u32 { #[allow(unused_variables)] fn try_get_by(res: &QueryResult, idx: I) -> Result { @@ -1097,6 +1100,9 @@ mod postgres_array { #[cfg(feature = "with-ipnetwork")] try_getable_postgres_array!(ipnetwork::IpNetwork); + #[cfg(feature = "with-mac_address")] + try_getable_postgres_array!(mac_address::MacAddress); + #[allow(unused_macros)] macro_rules! try_getable_postgres_array_uuid { ( $type: ty, $conversion_fn: expr ) => { @@ -1648,6 +1654,9 @@ try_from_u64_err!(uuid::Uuid); #[cfg(feature = "with-ipnetwork")] try_from_u64_err!(ipnetwork::IpNetwork); +#[cfg(feature = "with-mac_address")] +try_from_u64_err!(mac_address::MacAddress); + #[cfg(test)] mod tests { use super::*;