Vendor dependencies

This commit is contained in:
2026-08-01 16:11:49 +03:00
parent 7f139a0241
commit 6b5e7f0f8b
29706 changed files with 9575646 additions and 0 deletions
@@ -0,0 +1 @@
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"4c4951c26748e19fe83bc73ce52fcd291a069817a297cf491d6c5cc71215fca9","Cargo.lock":"c0fdaec959c97a69479197dbde9e75c1b3bd8208d92a21f0ab0828668461fcec","Cargo.toml":"d8cc5995ef729dc84b6abd4eb6bf6ba10c0afb54c60cc08bbce893c6e802437f","Cargo.toml.orig":"d9ad3fa796c80860293a853a5e6326d47ddd4bccd9f8590330a4ba3a41b92370","src/lib.rs":"1e37bed7ea1576fcfcf66561a7031733e41e6120e7bb0d585538617da8abaef6","src/sqlx.rs":"a623e8f6f6b15671e0350ad08a9b53835960b3ab2b8725b841fb6ac8608cf66a","src/sqlx_any.rs":"5ad482010dd9b3d304622e752cfda6d3887002bd3a957b6237aaec83738b6fcf","src/sqlx_mysql.rs":"78e707fafba75ac1aff3e8e196ae0ae757f93e0bb7de2f33e34a3c2fa72fddd6","src/sqlx_postgres.rs":"215b3b5346cf268067e0150f359f1e71013ea05495fb17c998ff2434982b8fc1","src/sqlx_sqlite.rs":"dd1caec9230fff56fd83628b1af17e66b1259c4481004ddb383b4d1a701e0778","src/values.rs":"8f605aaabdb587db94911254eacb9bce9af8c365264fecea769f2c4711972c88"},"package":"4eaa419cdb9157da1361186b1959983eb2ea0dcb9a3c69dc45c449ecb2af8fef"}
@@ -0,0 +1,6 @@
{
"git": {
"sha1": "24986a26992729e235e9078abd7e1b9407471837"
},
"path_in_vcs": "sea-query-sqlx"
}
+3045
View File
File diff suppressed because it is too large Load Diff
+182
View File
@@ -0,0 +1,182 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2024"
rust-version = "1.94.0"
name = "sea-query-sqlx"
version = "0.9.1"
authors = [
"Valentin Tolmer <valentin@tolmer.fr>",
"Ivan Krivosheev <py.krivosheev@gmail.com>",
]
build = false
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Driver library for using SeaQuery with SQLx"
documentation = "https://docs.rs/sea-query"
readme = false
keywords = [
"database",
"sql",
"mysql",
"postgres",
"sqlite",
]
categories = ["database"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/SeaQL/sea-query"
[package.metadata.docs.rs]
features = [
"sqlx-mysql",
"sqlx-postgres",
"sqlx-sqlite",
"sqlx-any",
"with-chrono",
"with-json",
"with-rust_decimal",
"with-bigdecimal",
"with-uuid",
"with-time",
"with-ipnetwork",
"with-mac_address",
"postgres-array",
"postgres-vector",
"runtime-tokio",
"tls-rustls",
]
[features]
postgres-array = ["sea-query/postgres-array"]
postgres-vector = [
"sea-query/postgres-vector",
"pgvector/sqlx",
]
runtime-actix = ["sqlx?/runtime-tokio"]
runtime-actix-native-tls = [
"runtime-actix",
"tls-native-tls",
]
runtime-actix-rustls = [
"runtime-actix",
"tls-rustls",
]
runtime-async-std = ["sqlx?/runtime-async-std"]
runtime-async-std-native-tls = [
"runtime-async-std",
"tls-native-tls",
]
runtime-async-std-rustls = [
"runtime-async-std",
"tls-rustls",
]
runtime-tokio = ["sqlx?/runtime-tokio"]
runtime-tokio-native-tls = [
"runtime-tokio",
"tls-native-tls",
]
runtime-tokio-rustls = [
"runtime-tokio",
"tls-rustls",
]
sqlx-any = ["sqlx/any"]
sqlx-mysql = ["sqlx/mysql"]
sqlx-postgres = [
"sqlx/postgres",
"sea-query/backend-postgres",
]
sqlx-sqlite = ["sqlx/sqlite"]
tls-native-tls = ["sqlx?/tls-native-tls"]
tls-none = ["sqlx?/tls-none"]
tls-rustls = ["sqlx?/tls-rustls"]
tls-rustls-aws-lc-rs = ["sqlx?/tls-rustls-aws-lc-rs"]
tls-rustls-ring = ["sqlx?/tls-rustls-ring"]
tls-rustls-ring-native-roots = ["sqlx?/tls-rustls-ring-native-roots"]
tls-rustls-ring-webpki = ["sqlx?/tls-rustls-ring-webpki"]
unimplemented-jiff-sqlx = []
unimplemented-jiff-sqlx-mysql = ["unimplemented-jiff-sqlx"]
with-bigdecimal = [
"sqlx?/bigdecimal",
"sea-query/with-bigdecimal",
]
with-chrono = [
"sqlx?/chrono",
"sea-query/with-chrono",
]
with-ipnetwork = [
"sqlx?/ipnetwork",
"sea-query/with-ipnetwork",
]
with-jiff = [
"sea-query/with-jiff",
"jiff",
]
with-json = [
"sqlx?/json",
"sea-query/with-json",
]
with-mac_address = [
"sqlx?/mac_address",
"sea-query/with-mac_address",
]
with-rust_decimal = [
"sqlx?/rust_decimal",
"sea-query/with-rust_decimal",
]
with-time = [
"sqlx?/time",
"sea-query/with-time",
]
with-uuid = [
"sqlx?/uuid",
"sea-query/with-uuid",
]
[lib]
name = "sea_query_sqlx"
path = "src/lib.rs"
[dependencies.ipnetwork]
version = "0.21.1"
optional = true
default-features = false
[dependencies.jiff]
version = "0.2.15"
features = [
"std",
"perf-inline",
]
optional = true
default-features = false
[dependencies.jiff-sqlx]
version = "0.1"
optional = true
[dependencies.pgvector]
version = "0.4.2"
optional = true
default-features = false
[dependencies.sea-query]
version = "1.0.0"
features = ["thread-safe"]
default-features = false
[dependencies.sqlx]
version = "0.9"
optional = true
default-features = false
+85
View File
@@ -0,0 +1,85 @@
[workspace]
# A separate workspace
[package]
name = "sea-query-sqlx"
version = "0.9.1"
authors = [ "Valentin Tolmer <valentin@tolmer.fr>", "Ivan Krivosheev <py.krivosheev@gmail.com>" ]
edition = "2024"
description = "Driver library for using SeaQuery with SQLx"
license = "MIT OR Apache-2.0"
documentation = "https://docs.rs/sea-query"
repository = "https://github.com/SeaQL/sea-query"
categories = [ "database" ]
keywords = [ "database", "sql", "mysql", "postgres", "sqlite" ]
rust-version = "1.94.0"
[lib]
[dependencies]
sea-query = { version = "1.0.0", path = "..", default-features = false, features = ["thread-safe"] }
sqlx = { version = "0.9", default-features = false, optional = true }
ipnetwork = { version = "0.21.1", default-features = false, optional = true } # pin dependency
pgvector = { version = "0.4.2", default-features = false, optional = true } # requires feature flag
jiff = { version = "0.2.15", default-features = false, optional = true, features = ["std", "perf-inline"] }
# TODO: Re-enable in `with-jiff` when jiff-sqlx releases sqlx 0.9 support.
# jiff-sqlx 0.1.1 still depends on sqlx 0.8.
jiff-sqlx = { version = "0.1", optional = true }
[features]
sqlx-mysql = ["sqlx/mysql"]
sqlx-postgres = ["sqlx/postgres", "sea-query/backend-postgres"]
sqlx-sqlite = ["sqlx/sqlite"]
sqlx-any = ["sqlx/any"]
with-chrono = ["sqlx?/chrono", "sea-query/with-chrono"]
with-json = ["sqlx?/json", "sea-query/with-json"]
with-rust_decimal = ["sqlx?/rust_decimal", "sea-query/with-rust_decimal"]
with-bigdecimal = ["sqlx?/bigdecimal", "sea-query/with-bigdecimal"]
with-uuid = ["sqlx?/uuid", "sea-query/with-uuid"]
with-time = ["sqlx?/time", "sea-query/with-time"]
with-ipnetwork = ["sqlx?/ipnetwork", "sea-query/with-ipnetwork"]
with-mac_address = ["sqlx?/mac_address", "sea-query/with-mac_address"]
with-jiff = ["sea-query/with-jiff", "jiff"]
unimplemented-jiff-sqlx = []
unimplemented-jiff-sqlx-mysql = ["unimplemented-jiff-sqlx"]
postgres-array = ["sea-query/postgres-array"]
postgres-vector = ["sea-query/postgres-vector", "pgvector/sqlx"]
runtime-async-std = ["sqlx?/runtime-async-std"]
runtime-actix = ["sqlx?/runtime-tokio"]
runtime-tokio = ["sqlx?/runtime-tokio"]
tls-none = ["sqlx?/tls-none"]
tls-native-tls = ["sqlx?/tls-native-tls"]
tls-rustls = ["sqlx?/tls-rustls"]
tls-rustls-aws-lc-rs = ["sqlx?/tls-rustls-aws-lc-rs"]
tls-rustls-ring = ["sqlx?/tls-rustls-ring"]
tls-rustls-ring-native-roots = ["sqlx?/tls-rustls-ring-native-roots"]
tls-rustls-ring-webpki = ["sqlx?/tls-rustls-ring-webpki"]
# TODO: Remove those features as a breaking change.
runtime-async-std-native-tls = ["runtime-async-std", "tls-native-tls"]
runtime-async-std-rustls = ["runtime-async-std", "tls-rustls"]
runtime-actix-native-tls = ["runtime-actix", "tls-native-tls"]
runtime-actix-rustls = ["runtime-actix", "tls-rustls"]
runtime-tokio-native-tls = ["runtime-tokio", "tls-native-tls"]
runtime-tokio-rustls = ["runtime-tokio", "tls-rustls"]
[package.metadata.docs.rs]
features = [
"sqlx-mysql",
"sqlx-postgres",
"sqlx-sqlite",
"sqlx-any",
"with-chrono",
"with-json",
"with-rust_decimal",
"with-bigdecimal",
"with-uuid",
"with-time",
"with-ipnetwork",
"with-mac_address",
"postgres-array",
"postgres-vector",
"runtime-tokio",
"tls-rustls",
]
+52
View File
@@ -0,0 +1,52 @@
#![forbid(unsafe_code)]
//! Driver library for using SeaQuery with SQLx
//!
//! This library introduces various traits that add methods to the query types from `sea-query`.
//! For instance, using the [`SqlxBinder`] trait adds a [`SqlxBinder::build_sqlx`] method that
//! returns the query and a [`SqlxValues`] object, which can be directly passed to `sqlx`'s
//! [`sqlx::query_with`][1] method.
//!
//! [1]: ../sqlx/fn.query_with.html
#[cfg(all(
any(
feature = "sqlx-mysql",
feature = "sqlx-postgres",
feature = "sqlx-any"
),
feature = "with-jiff",
not(feature = "unimplemented-jiff-sqlx")
))]
const _: () = panic!(
"sea-query-sqlx does not support with-jiff together with sqlx-mysql/sqlx-postgres/sqlx-any yet; \
enable the `unimplemented-jiff-sqlx` feature to acknowledge the limitation and keep the \
current runtime panic behavior"
);
#[cfg(feature = "sqlx-any")]
mod sqlx_any;
#[cfg(feature = "sqlx-mysql")]
mod sqlx_mysql;
#[cfg(feature = "sqlx-postgres")]
mod sqlx_postgres;
#[cfg(feature = "sqlx-sqlite")]
mod sqlx_sqlite;
mod values;
pub use crate::values::SqlxValues;
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-postgres",
feature = "sqlx-sqlite",
feature = "sqlx-any"
))]
mod sqlx;
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-postgres",
feature = "sqlx-sqlite",
feature = "sqlx-any"
))]
pub use crate::sqlx::SqlxBinder;
+28
View File
@@ -0,0 +1,28 @@
use crate::SqlxValues;
use sea_query::{QueryBuilder, query::*};
pub trait SqlxBinder {
fn build_sqlx<T>(&self, query_builder: T) -> (String, SqlxValues)
where
T: QueryBuilder;
}
macro_rules! impl_sqlx_binder {
($l:ident) => {
impl SqlxBinder for $l {
fn build_sqlx<T>(&self, query_builder: T) -> (String, SqlxValues)
where
T: QueryBuilder,
{
let (query, values) = self.build(query_builder);
(query, SqlxValues(values))
}
}
};
}
impl_sqlx_binder!(SelectStatement);
impl_sqlx_binder!(UpdateStatement);
impl_sqlx_binder!(InsertStatement);
impl_sqlx_binder!(DeleteStatement);
impl_sqlx_binder!(WithQuery);
+157
View File
@@ -0,0 +1,157 @@
use crate::SqlxValues;
use sea_query::{OptionEnum, Value};
impl sqlx::IntoArguments<sqlx::any::Any> for SqlxValues {
fn into_arguments(self) -> sqlx::any::AnyArguments {
let mut args = sqlx::any::AnyArguments::default();
for arg in self.0.into_iter() {
use sqlx::Arguments;
match arg {
Value::Bool(b) => {
let _ = args.add(b);
}
Value::TinyInt(i) => {
let _ = args.add(i.map(Into::<i32>::into));
}
Value::SmallInt(i) => {
let _ = args.add(i.map(Into::<i32>::into));
}
Value::Int(i) => {
let _ = args.add(i);
}
Value::BigInt(i) => {
let _ = args.add(i);
}
Value::TinyUnsigned(i) => {
let _ = args.add(i.map(Into::<i32>::into));
}
Value::SmallUnsigned(i) => {
let _ = args.add(i.map(Into::<i32>::into));
}
Value::Unsigned(i) => {
let _ = args.add(i.map(Into::<i64>::into));
}
Value::BigUnsigned(i) => {
let _ = args
.add(i.map(|i| <i64 as std::convert::TryFrom<u64>>::try_from(i).unwrap()));
}
Value::Float(f) => {
let _ = args.add(f);
}
Value::Double(d) => {
let _ = args.add(d);
}
Value::String(s) => {
let _ = args.add(s);
}
Value::Enum(e) => {
let value = match e {
OptionEnum::Some(v) => Some(v.value.into_owned()),
OptionEnum::None(_) => None,
};
let _ = args.add(value);
}
Value::Char(c) => {
let _ = args.add(c.map(|c| c.to_string()));
}
Value::Bytes(b) => {
let _ = args.add(b);
}
#[cfg(feature = "with-chrono")]
Value::ChronoDate(t) => {
let _ = args.add(Value::ChronoDate(t).chrono_as_naive_utc_in_string());
}
#[cfg(feature = "with-chrono")]
Value::ChronoTime(t) => {
let _ = args.add(Value::ChronoTime(t).chrono_as_naive_utc_in_string());
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTime(t) => {
let _ = args.add(Value::ChronoDateTime(t).chrono_as_naive_utc_in_string());
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTimeUtc(t) => {
let _ = args.add(Value::ChronoDateTimeUtc(t).chrono_as_naive_utc_in_string());
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTimeLocal(t) => {
let _ = args.add(Value::ChronoDateTimeLocal(t).chrono_as_naive_utc_in_string());
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTimeWithTimeZone(t) => {
let _ = args
.add(Value::ChronoDateTimeWithTimeZone(t).chrono_as_naive_utc_in_string());
}
#[cfg(feature = "with-time")]
Value::TimeDate(t) => {
let _ = args.add(Value::TimeDate(t).time_as_naive_utc_in_string());
}
#[cfg(feature = "with-time")]
Value::TimeTime(t) => {
let _ = args.add(Value::TimeTime(t).time_as_naive_utc_in_string());
}
#[cfg(feature = "with-time")]
Value::TimeDateTime(t) => {
let _ = args.add(Value::TimeDateTime(t).time_as_naive_utc_in_string());
}
#[cfg(feature = "with-time")]
Value::TimeDateTimeWithTimeZone(t) => {
let _ =
args.add(Value::TimeDateTimeWithTimeZone(t).time_as_naive_utc_in_string());
}
#[cfg(feature = "with-jiff")]
Value::JiffDate(j) => {
let _ = args.add(j.map(|j| j.to_string()));
}
#[cfg(feature = "with-jiff")]
Value::JiffTime(j) => {
let _ = args.add(j.map(|j| j.to_string()));
}
#[cfg(feature = "with-jiff")]
Value::JiffDateTime(j) => {
let _ = args.add(j.map(|j| j.to_string()));
}
#[cfg(feature = "with-jiff")]
Value::JiffTimestamp(j) => {
let _ = args.add(j.map(|j| j.to_string()));
}
#[cfg(feature = "with-uuid")]
Value::Uuid(_) => {
panic!("UUID support not implemented for Any");
}
#[cfg(feature = "with-rust_decimal")]
Value::Decimal(_) => {
panic!("Sqlite doesn't support decimal arguments");
}
#[cfg(feature = "with-bigdecimal")]
Value::BigDecimal(_) => {
panic!("Sqlite doesn't support bigdecimal arguments");
}
#[cfg(feature = "with-json")]
Value::Json(_) => {
panic!("Json support not implemented for Any");
}
#[cfg(feature = "with-ipnetwork")]
Value::IpNetwork(_) => {
panic!("SQLx doesn't support IpNetwork arguments for Any");
}
#[cfg(feature = "with-mac_address")]
Value::MacAddress(_) => {
panic!("SQLx doesn't support MacAddress arguments for Any");
}
#[cfg(feature = "postgres-array")]
Value::Array(_, _) => {
panic!("SQLx doesn't support array arguments for Any");
}
#[cfg(feature = "postgres-vector")]
Value::Vector(_) => {
panic!("SQLx doesn't support vector arguments for Any");
} /* #[cfg(feature = "postgres-range")]
Value::Range(_) => {
panic!("SQLx doesn't support PgRange arguments for Any");
} */
}
}
args
}
}
+155
View File
@@ -0,0 +1,155 @@
use crate::SqlxValues;
use sea_query::{OptionEnum, Value};
impl sqlx::IntoArguments<sqlx::mysql::MySql> for SqlxValues {
fn into_arguments(self) -> sqlx::mysql::MySqlArguments {
let mut args = sqlx::mysql::MySqlArguments::default();
for arg in self.0.into_iter() {
use sqlx::Arguments;
match arg {
Value::Bool(b) => {
let _ = args.add(b);
}
Value::TinyInt(i) => {
let _ = args.add(i);
}
Value::SmallInt(i) => {
let _ = args.add(i);
}
Value::Int(i) => {
let _ = args.add(i);
}
Value::BigInt(i) => {
let _ = args.add(i);
}
Value::TinyUnsigned(i) => {
let _ = args.add(i);
}
Value::SmallUnsigned(i) => {
let _ = args.add(i);
}
Value::Unsigned(i) => {
let _ = args.add(i);
}
Value::BigUnsigned(i) => {
let _ = args.add(i);
}
Value::Float(f) => {
let _ = args.add(f);
}
Value::Double(d) => {
let _ = args.add(d);
}
Value::String(s) => {
let _ = args.add(s.as_deref());
}
Value::Enum(e) => {
let value = match e {
OptionEnum::Some(v) => Some(v.value.into_owned()),
OptionEnum::None(_) => None,
};
let _ = args.add(value);
}
Value::Char(c) => {
let _ = args.add(c.map(|c| c.to_string()));
}
Value::Bytes(b) => {
let _ = args.add(b.as_deref());
}
#[cfg(feature = "with-chrono")]
Value::ChronoDate(d) => {
let _ = args.add(d);
}
#[cfg(feature = "with-chrono")]
Value::ChronoTime(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTime(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTimeUtc(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTimeLocal(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTimeWithTimeZone(t) => {
let _ = args
.add(Value::ChronoDateTimeWithTimeZone(t).chrono_as_naive_utc_in_string());
}
#[cfg(feature = "with-time")]
Value::TimeDate(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-time")]
Value::TimeTime(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-time")]
Value::TimeDateTime(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-time")]
Value::TimeDateTimeWithTimeZone(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-jiff")]
Value::JiffDate(_) => {
panic!("Mysql doesn't support JiffDate arguments");
}
#[cfg(feature = "with-jiff")]
Value::JiffTime(_) => {
panic!("Mysql doesn't support JiffTime arguments");
}
#[cfg(feature = "with-jiff")]
Value::JiffDateTime(_) => {
panic!("Mysql doesn't support JiffDateTime arguments");
}
#[cfg(feature = "with-jiff")]
Value::JiffTimestamp(_) => {
panic!("Mysql doesn't support JiffTimestamp arguments");
}
#[cfg(feature = "with-uuid")]
Value::Uuid(uuid) => {
let _ = args.add(uuid);
}
#[cfg(feature = "with-rust_decimal")]
Value::Decimal(d) => {
let _ = args.add(d);
}
#[cfg(feature = "with-bigdecimal")]
Value::BigDecimal(d) => {
let _ = args.add(d.as_deref());
}
#[cfg(feature = "with-json")]
Value::Json(j) => {
let _ = args.add(j.as_deref());
}
#[cfg(feature = "postgres-array")]
Value::Array(_, _) => {
panic!("Mysql doesn't support array arguments");
}
#[cfg(feature = "postgres-vector")]
Value::Vector(_) => {
panic!("Mysql doesn't support vector arguments");
}
#[cfg(feature = "with-ipnetwork")]
Value::IpNetwork(_) => {
panic!("Mysql doesn't support IpNetwork arguments");
}
#[cfg(feature = "with-mac_address")]
Value::MacAddress(_) => {
panic!("Mysql doesn't support MacAddress arguments");
} /* #[cfg(feature = "postgres-range")]
Value::Range(_) => {
panic!("Mysql doesn't support PgRange arguments");
} */
}
}
args
}
}
+387
View File
@@ -0,0 +1,387 @@
#[cfg(all(feature = "postgres-array", feature = "with-bigdecimal"))]
use sea_query::prelude::BigDecimal;
#[cfg(all(feature = "postgres-array", feature = "with-rust_decimal"))]
use sea_query::prelude::Decimal;
#[cfg(all(feature = "postgres-array", feature = "with-ipnetwork"))]
use sea_query::prelude::IpNetwork;
#[cfg(all(feature = "postgres-array", feature = "with-json"))]
use sea_query::prelude::Json;
#[cfg(all(feature = "postgres-array", feature = "with-mac_address"))]
use sea_query::prelude::MacAddress;
#[cfg(all(feature = "postgres-array", feature = "with-uuid"))]
use sea_query::prelude::Uuid;
#[cfg(all(feature = "postgres-array", feature = "with-time"))]
use sea_query::prelude::time;
#[cfg(all(feature = "postgres-array", feature = "with-chrono"))]
use sea_query::prelude::{DateTime, FixedOffset, Local, NaiveDate, NaiveDateTime, NaiveTime, Utc};
#[cfg(feature = "postgres-array")]
use sea_query::ArrayType;
use sea_query::{OptionEnum, Value};
use crate::SqlxValues;
impl sqlx::IntoArguments<sqlx::postgres::Postgres> for SqlxValues {
fn into_arguments(self) -> sqlx::postgres::PgArguments {
let mut args = sqlx::postgres::PgArguments::default();
for arg in self.0.into_iter() {
use sqlx::Arguments;
match arg {
Value::Bool(b) => {
let _ = args.add(b);
}
Value::TinyInt(i) => {
let _ = args.add(i);
}
Value::SmallInt(i) => {
let _ = args.add(i);
}
Value::Int(i) => {
let _ = args.add(i);
}
Value::BigInt(i) => {
let _ = args.add(i);
}
Value::TinyUnsigned(i) => {
let _ = args.add(i.map(|i| i as i16));
}
Value::SmallUnsigned(i) => {
let _ = args.add(i.map(|i| i as i32));
}
Value::Unsigned(i) => {
let _ = args.add(i.map(|i| i as i64));
}
Value::BigUnsigned(i) => {
let _ = args.add(i.map(|i| <i64 as TryFrom<u64>>::try_from(i).unwrap()));
}
Value::Float(f) => {
let _ = args.add(f);
}
Value::Double(d) => {
let _ = args.add(d);
}
Value::String(s) => {
let _ = args.add(s.as_deref());
}
Value::Enum(e) => {
let value = match e {
OptionEnum::Some(v) => Some(v.value.into_owned()),
OptionEnum::None(_) => None,
};
let _ = args.add(value);
}
Value::Char(c) => {
let _ = args.add(c.map(|c| c.to_string()));
}
Value::Bytes(b) => {
let _ = args.add(b.as_deref());
}
#[cfg(feature = "with-chrono")]
Value::ChronoDate(d) => {
let _ = args.add(d);
}
#[cfg(feature = "with-chrono")]
Value::ChronoTime(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTime(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTimeUtc(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTimeLocal(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTimeWithTimeZone(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-time")]
Value::TimeDate(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-time")]
Value::TimeTime(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-time")]
Value::TimeDateTime(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-time")]
Value::TimeDateTimeWithTimeZone(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-jiff")]
Value::JiffDate(_) => {
panic!("SQLx 0.9 does not support Jiff arguments for Postgres yet");
}
#[cfg(feature = "with-jiff")]
Value::JiffTime(_) => {
panic!("SQLx 0.9 does not support Jiff arguments for Postgres yet");
}
#[cfg(feature = "with-jiff")]
Value::JiffDateTime(_) => {
panic!("SQLx 0.9 does not support Jiff arguments for Postgres yet");
}
#[cfg(feature = "with-jiff")]
Value::JiffTimestamp(_) => {
panic!("SQLx 0.9 does not support Jiff arguments for Postgres yet");
}
#[cfg(feature = "with-uuid")]
Value::Uuid(uuid) => {
let _ = args.add(uuid);
}
#[cfg(feature = "with-rust_decimal")]
Value::Decimal(d) => {
let _ = args.add(d);
}
#[cfg(feature = "with-bigdecimal")]
Value::BigDecimal(d) => {
let _ = args.add(d.as_deref());
}
#[cfg(feature = "with-json")]
Value::Json(j) => {
let _ = args.add(j.as_deref());
}
#[cfg(feature = "with-ipnetwork")]
Value::IpNetwork(ip) => {
let _ = args.add(ip);
}
#[cfg(feature = "with-mac_address")]
Value::MacAddress(mac) => {
let _ = args.add(mac);
}
#[cfg(feature = "postgres-array")]
Value::Array(ty, v) => match ty {
ArrayType::Bool => {
let value: Option<Vec<bool>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::Bool");
let _ = args.add(value);
}
ArrayType::TinyInt => {
let value: Option<Vec<i8>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::TinyInt");
let _ = args.add(value);
}
ArrayType::SmallInt => {
let value: Option<Vec<i16>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::SmallInt");
let _ = args.add(value);
}
ArrayType::Int => {
let value: Option<Vec<i32>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::Int");
let _ = args.add(value);
}
ArrayType::BigInt => {
let value: Option<Vec<i64>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::BigInt");
let _ = args.add(value);
}
ArrayType::TinyUnsigned => {
let value: Option<Vec<u8>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::TinyUnsigned");
let value: Option<Vec<i16>> =
value.map(|vec| vec.into_iter().map(|i| i as i16).collect());
let _ = args.add(value);
}
ArrayType::SmallUnsigned => {
let value: Option<Vec<u16>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::SmallUnsigned");
let value: Option<Vec<i32>> =
value.map(|vec| vec.into_iter().map(|i| i as i32).collect());
let _ = args.add(value);
}
ArrayType::Unsigned => {
let value: Option<Vec<u32>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::Unsigned");
let value: Option<Vec<i64>> =
value.map(|vec| vec.into_iter().map(|i| i as i64).collect());
let _ = args.add(value);
}
ArrayType::BigUnsigned => {
let value: Option<Vec<u64>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::BigUnsigned");
let value: Option<Vec<i64>> = value.map(|vec| {
vec.into_iter()
.map(|i| <i64 as TryFrom<u64>>::try_from(i).unwrap())
.collect()
});
let _ = args.add(value);
}
ArrayType::Float => {
let value: Option<Vec<f32>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::Float");
let _ = args.add(value);
}
ArrayType::Double => {
let value: Option<Vec<f64>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::Double");
let _ = args.add(value);
}
ArrayType::String => {
let value: Option<Vec<String>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::String");
let _ = args.add(value);
}
ArrayType::Enum(_) => {
let value: Option<Vec<String>> = v.map(|values| {
values
.into_iter()
.map(|value| match value {
Value::Enum(OptionEnum::Some(value)) => value.value.into_owned(),
_ => {
panic!(
"Value::Array(ArrayType::Enum) should contain Value::Enum"
);
}
})
.collect()
});
let _ = args.add(value);
}
ArrayType::Char => {
let value: Option<Vec<char>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::Char");
let value: Option<Vec<String>> =
value.map(|vec| vec.into_iter().map(|c| c.to_string()).collect());
let _ = args.add(value);
}
ArrayType::Bytes => {
let value: Option<Vec<Vec<u8>>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::Bytes");
let _ = args.add(value);
}
#[cfg(feature = "with-chrono")]
ArrayType::ChronoDate => {
let value: Option<Vec<NaiveDate>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::ChronoDate");
let _ = args.add(value);
}
#[cfg(feature = "with-chrono")]
ArrayType::ChronoTime => {
let value: Option<Vec<NaiveTime>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::ChronoTime");
let _ = args.add(value);
}
#[cfg(feature = "with-chrono")]
ArrayType::ChronoDateTime => {
let value: Option<Vec<NaiveDateTime>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::ChronoDateTime");
let _ = args.add(value);
}
#[cfg(feature = "with-chrono")]
ArrayType::ChronoDateTimeUtc => {
let value: Option<Vec<DateTime<Utc>>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::ChronoDateTimeUtc");
let _ = args.add(value);
}
#[cfg(feature = "with-chrono")]
ArrayType::ChronoDateTimeLocal => {
let value: Option<Vec<DateTime<Local>>> = Value::Array(ty, v).expect(
"This Value::Array should consist of Value::ChronoDateTimeLocal",
);
let _ = args.add(value);
}
#[cfg(feature = "with-chrono")]
ArrayType::ChronoDateTimeWithTimeZone => {
let value: Option<Vec<DateTime<FixedOffset>>> = Value::Array(ty, v).expect(
"This Value::Array should consist of Value::ChronoDateTimeWithTimeZone",
);
let _ = args.add(value);
}
#[cfg(feature = "with-time")]
ArrayType::TimeDate => {
let value: Option<Vec<time::Date>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::TimeDate");
let _ = args.add(value);
}
#[cfg(feature = "with-time")]
ArrayType::TimeTime => {
let value: Option<Vec<time::Time>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::TimeTime");
let _ = args.add(value);
}
#[cfg(feature = "with-time")]
ArrayType::TimeDateTime => {
let value: Option<Vec<time::PrimitiveDateTime>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::TimeDateTime");
let _ = args.add(value);
}
#[cfg(feature = "with-time")]
ArrayType::TimeDateTimeWithTimeZone => {
let value: Option<Vec<time::OffsetDateTime>> = Value::Array(ty, v).expect(
"This Value::Array should consist of Value::TimeDateTimeWithTimeZone",
);
let _ = args.add(value);
}
#[cfg(feature = "with-jiff")]
ArrayType::JiffDate => {
panic!("SQLx 0.9 does not support Jiff array arguments for Postgres yet");
}
#[cfg(feature = "with-jiff")]
ArrayType::JiffTime => {
panic!("SQLx 0.9 does not support Jiff array arguments for Postgres yet");
}
#[cfg(feature = "with-jiff")]
ArrayType::JiffDateTime => {
panic!("SQLx 0.9 does not support Jiff array arguments for Postgres yet");
}
#[cfg(feature = "with-jiff")]
ArrayType::JiffTimestamp => {
panic!("SQLx 0.9 does not support Jiff array arguments for Postgres yet");
}
#[cfg(feature = "with-uuid")]
ArrayType::Uuid => {
let value: Option<Vec<Uuid>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::Uuid");
let _ = args.add(value);
}
#[cfg(feature = "with-rust_decimal")]
ArrayType::Decimal => {
let value: Option<Vec<Decimal>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::Decimal");
let _ = args.add(value);
}
#[cfg(feature = "with-bigdecimal")]
ArrayType::BigDecimal => {
let value: Option<Vec<BigDecimal>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::BigDecimal");
let _ = args.add(value);
}
#[cfg(feature = "with-json")]
ArrayType::Json => {
let value: Option<Vec<Json>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::Json");
let _ = args.add(value);
}
#[cfg(feature = "with-ipnetwork")]
ArrayType::IpNetwork => {
let value: Option<Vec<IpNetwork>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::IpNetwork");
let _ = args.add(value);
}
#[cfg(feature = "with-mac_address")]
ArrayType::MacAddress => {
let value: Option<Vec<MacAddress>> = Value::Array(ty, v)
.expect("This Value::Array should consist of Value::MacAddress");
let _ = args.add(value);
}
},
#[cfg(feature = "postgres-vector")]
Value::Vector(v) => {
let _ = args.add(v);
} /* #[cfg(feature = "postgres-range")]
Value::Range(v) => {
let _ = args.add(v);
} */
}
}
args
}
}
+155
View File
@@ -0,0 +1,155 @@
use crate::SqlxValues;
use sea_query::{OptionEnum, Value};
impl sqlx::IntoArguments<sqlx::sqlite::Sqlite> for SqlxValues {
fn into_arguments(self) -> sqlx::sqlite::SqliteArguments {
let mut args = sqlx::sqlite::SqliteArguments::default();
for arg in self.0.into_iter() {
use sqlx::Arguments;
match arg {
Value::Bool(b) => {
let _ = args.add(b);
}
Value::TinyInt(i) => {
let _ = args.add(i);
}
Value::SmallInt(i) => {
let _ = args.add(i);
}
Value::Int(i) => {
let _ = args.add(i);
}
Value::BigInt(i) => {
let _ = args.add(i);
}
Value::TinyUnsigned(i) => {
let _ = args.add(i);
}
Value::SmallUnsigned(i) => {
let _ = args.add(i);
}
Value::Unsigned(i) => {
let _ = args.add(i);
}
Value::BigUnsigned(i) => {
let _ = args
.add(i.map(|i| <i64 as std::convert::TryFrom<u64>>::try_from(i).unwrap()));
}
Value::Float(f) => {
let _ = args.add(f);
}
Value::Double(d) => {
let _ = args.add(d);
}
Value::String(s) => {
let _ = args.add(s);
}
Value::Enum(e) => {
let value = match e {
OptionEnum::Some(v) => Some(v.value.into_owned()),
OptionEnum::None(_) => None,
};
let _ = args.add(value);
}
Value::Char(c) => {
let _ = args.add(c.map(|c| c.to_string()));
}
Value::Bytes(b) => {
let _ = args.add(b);
}
#[cfg(feature = "with-chrono")]
Value::ChronoDate(d) => {
let _ = args.add(d);
}
#[cfg(feature = "with-chrono")]
Value::ChronoTime(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTime(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTimeUtc(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTimeLocal(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-chrono")]
Value::ChronoDateTimeWithTimeZone(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-time")]
Value::TimeDate(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-time")]
Value::TimeTime(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-time")]
Value::TimeDateTime(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-time")]
Value::TimeDateTimeWithTimeZone(t) => {
let _ = args.add(t);
}
#[cfg(feature = "with-jiff")]
Value::JiffDate(j) => {
let _ = args.add(j.map(|j| j.to_string()));
}
#[cfg(feature = "with-jiff")]
Value::JiffTime(j) => {
let _ = args.add(j.map(|j| j.to_string()));
}
#[cfg(feature = "with-jiff")]
Value::JiffDateTime(j) => {
let _ = args.add(j.map(|j| j.to_string()));
}
#[cfg(feature = "with-jiff")]
Value::JiffTimestamp(j) => {
let _ = args.add(j.map(|j| j.to_string()));
}
#[cfg(feature = "with-uuid")]
Value::Uuid(uuid) => {
let _ = args.add(uuid);
}
#[cfg(feature = "with-rust_decimal")]
Value::Decimal(decimal) => {
let _ = args.add(decimal.map(|d| d.to_string()));
}
#[cfg(feature = "with-bigdecimal")]
Value::BigDecimal(big_decimal) => {
let _ = args.add(big_decimal.map(|d| d.to_string()));
}
#[cfg(feature = "with-json")]
Value::Json(j) => {
let _ = args.add(j.map(|j| *j));
}
#[cfg(feature = "with-ipnetwork")]
Value::IpNetwork(_) => {
panic!("Sqlite doesn't support IpNetwork arguments");
}
#[cfg(feature = "with-mac_address")]
Value::MacAddress(_) => {
panic!("Sqlite doesn't support MacAddress arguments");
}
#[cfg(feature = "postgres-array")]
Value::Array(_, _) => {
panic!("Sqlite doesn't support array arguments");
}
#[cfg(feature = "postgres-vector")]
Value::Vector(_) => {
panic!("Sqlite doesn't support vector arguments");
} /* #[cfg(feature = "postgres-range")]
Value::Range(_) => {
panic!("Sqlite doesn't support PgRange arguments");
} */
}
}
args
}
}
+3
View File
@@ -0,0 +1,3 @@
#[derive(Clone, Debug, PartialEq)]
#[repr(transparent)]
pub struct SqlxValues(pub sea_query::Values);