Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ chrono = { version = "0.4.30", default-features = false, optional = true }
time = { version = "0.3.36", default-features = false, optional = true }
futures-util = { version = "0.3", default-features = false, features = ["std"] }
log = { version = "0.4", default-features = false }
mac_address = { version = "1.1", default-features = false, optional = true }
tracing = { version = "0.1", default-features = false, features = ["attributes", "log"] }
rust_decimal = { version = "1", default-features = false, optional = true }
bigdecimal = { version = "0.4", default-features = false, optional = true }
Expand Down Expand Up @@ -77,14 +78,15 @@ default = [
]
macros = ["sea-orm-macros/derive"]
mock = []
proxy = ["serde_json", "serde/derive"]
with-json = ["serde_json", "sea-query/with-json", "chrono?/serde", "rust_decimal?/serde", "bigdecimal?/serde", "uuid?/serde", "time?/serde", "pgvector?/serde", "sea-query-binder?/with-json", "sqlx?/json"]
proxy = ["serde/derive"]
with-json = ["serde_json", "sea-query/with-json", "chrono?/serde", "rust_decimal?/serde", "bigdecimal?/serde", "uuid?/serde", "time?/serde", "pgvector?/serde", "sea-query-binder?/with-json", "sqlx?/json", "mac_address?/serde"]
with-chrono = ["chrono", "sea-query/with-chrono", "sea-query-binder?/with-chrono", "sqlx?/chrono"]
with-rust_decimal = ["rust_decimal", "sea-query/with-rust_decimal", "sea-query-binder?/with-rust_decimal", "sqlx?/rust_decimal"]
with-bigdecimal = ["bigdecimal", "sea-query/with-bigdecimal", "sea-query-binder?/with-bigdecimal", "sqlx?/bigdecimal"]
with-uuid = ["uuid", "sea-query/with-uuid", "sea-query-binder?/with-uuid", "sqlx?/uuid"]
with-time = ["time", "sea-query/with-time", "sea-query-binder?/with-time", "sqlx?/time"]
with-ipnetwork = ["ipnetwork", "sea-query/with-ipnetwork", "sea-query-binder?/with-ipnetwork", "sqlx?/ipnetwork"]
with-mac_address = ["mac_address", "sea-query/with-mac_address", "sea-query-binder?/with-mac_address"]
postgres-array = ["sea-query/postgres-array", "sea-query-binder?/postgres-array", "sea-orm-macros/postgres-array"]
postgres-vector = ["pgvector", "sea-query/postgres-vector", "sea-query-binder?/postgres-vector"]
json-array = ["postgres-array"] # this does not actually enable sqlx-postgres, but only a few traits to support array in sea-query
Expand Down
10 changes: 7 additions & 3 deletions src/driver/sqlx_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ pub(crate) fn from_sqlx_postgres_row_to_proxy_row(row: &sqlx::postgres::PgRow) -
not(feature = "with-bigdecimal")
))]
"NUMERIC" => Value::Decimal(
row.try_get(c.ordinal())
row.try_get::<Option<rust_decimal::Decimal>, _>(c.ordinal())
.expect("Failed to get numeric")
.map(Box::new),
),
Expand Down Expand Up @@ -611,12 +611,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::<Option<serde_json::Value>, _>(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::<Option<Vec<serde_json::Value>>, _>(c.ordinal())
Expand Down Expand Up @@ -856,7 +860,7 @@ pub(crate) fn from_sqlx_postgres_row_to_proxy_row(row: &sqlx::postgres::PgRow) -
),
#[cfg(all(feature = "with-time", not(feature = "with-chrono")))]
"TIMETZ" => Value::TimeTime(
row.try_get(c.ordinal())
row.try_get::<Option<time::Time>, _>(c.ordinal())
.expect("Failed to get timetz")
.map(Box::new),
),
Expand Down
9 changes: 9 additions & 0 deletions src/executor/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,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<I: ColIdx>(res: &QueryResult, idx: I) -> Result<Self, TryGetError> {
Expand Down Expand Up @@ -996,6 +999,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 ) => {
Expand Down Expand Up @@ -1537,6 +1543,9 @@ try_from_u64_err!(uuid::fmt::Braced);
#[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::*;
Expand Down
Loading