sea_query_sqlx/
sqlx_any.rs

1use crate::SqlxValues;
2use sea_query::Value;
3
4impl<'q> sqlx::IntoArguments<'q, sqlx::any::Any> for SqlxValues {
5    fn into_arguments(self) -> sqlx::any::AnyArguments<'q> {
6        let mut args = sqlx::any::AnyArguments::default();
7        for arg in self.0.into_iter() {
8            use sqlx::Arguments;
9            match arg {
10                Value::Bool(b) => {
11                    let _ = args.add(b);
12                }
13                Value::TinyInt(i) => {
14                    let _ = args.add(i.map(Into::<i32>::into));
15                }
16                Value::SmallInt(i) => {
17                    let _ = args.add(i.map(Into::<i32>::into));
18                }
19                Value::Int(i) => {
20                    let _ = args.add(i);
21                }
22                Value::BigInt(i) => {
23                    let _ = args.add(i);
24                }
25                Value::TinyUnsigned(i) => {
26                    let _ = args.add(i.map(Into::<i32>::into));
27                }
28                Value::SmallUnsigned(i) => {
29                    let _ = args.add(i.map(Into::<i32>::into));
30                }
31                Value::Unsigned(i) => {
32                    let _ = args.add(i.map(Into::<i64>::into));
33                }
34                Value::BigUnsigned(i) => {
35                    let _ = args
36                        .add(i.map(|i| <i64 as std::convert::TryFrom<u64>>::try_from(i).unwrap()));
37                }
38                Value::Float(f) => {
39                    let _ = args.add(f);
40                }
41                Value::Double(d) => {
42                    let _ = args.add(d);
43                }
44                Value::String(s) => {
45                    let _ = args.add(s);
46                }
47                Value::Char(c) => {
48                    let _ = args.add(c.map(|c| c.to_string()));
49                }
50                Value::Bytes(b) => {
51                    let _ = args.add(b);
52                }
53                #[cfg(feature = "with-chrono")]
54                Value::ChronoDate(t) => {
55                    let _ = args.add(Value::ChronoDate(t).chrono_as_naive_utc_in_string());
56                }
57                #[cfg(feature = "with-chrono")]
58                Value::ChronoTime(t) => {
59                    let _ = args.add(Value::ChronoTime(t).chrono_as_naive_utc_in_string());
60                }
61                #[cfg(feature = "with-chrono")]
62                Value::ChronoDateTime(t) => {
63                    let _ = args.add(Value::ChronoDateTime(t).chrono_as_naive_utc_in_string());
64                }
65                #[cfg(feature = "with-chrono")]
66                Value::ChronoDateTimeUtc(t) => {
67                    let _ = args.add(Value::ChronoDateTimeUtc(t).chrono_as_naive_utc_in_string());
68                }
69                #[cfg(feature = "with-chrono")]
70                Value::ChronoDateTimeLocal(t) => {
71                    let _ = args.add(Value::ChronoDateTimeLocal(t).chrono_as_naive_utc_in_string());
72                }
73                #[cfg(feature = "with-chrono")]
74                Value::ChronoDateTimeWithTimeZone(t) => {
75                    let _ = args
76                        .add(Value::ChronoDateTimeWithTimeZone(t).chrono_as_naive_utc_in_string());
77                }
78                #[cfg(feature = "with-time")]
79                Value::TimeDate(t) => {
80                    let _ = args.add(Value::TimeDate(t).time_as_naive_utc_in_string());
81                }
82                #[cfg(feature = "with-time")]
83                Value::TimeTime(t) => {
84                    let _ = args.add(Value::TimeTime(t).time_as_naive_utc_in_string());
85                }
86                #[cfg(feature = "with-time")]
87                Value::TimeDateTime(t) => {
88                    let _ = args.add(Value::TimeDateTime(t).time_as_naive_utc_in_string());
89                }
90                #[cfg(feature = "with-time")]
91                Value::TimeDateTimeWithTimeZone(t) => {
92                    let _ =
93                        args.add(Value::TimeDateTimeWithTimeZone(t).time_as_naive_utc_in_string());
94                }
95                #[cfg(feature = "with-jiff")]
96                Value::JiffDate(_) => {
97                    panic!("SQLx doesn't support Jiff arguments for Any");
98                }
99                #[cfg(feature = "with-jiff")]
100                Value::JiffTime(_) => {
101                    panic!("SQLx doesn't support Jiff arguments for Any");
102                }
103                #[cfg(feature = "with-jiff")]
104                Value::JiffDateTime(_) => {
105                    panic!("SQLx doesn't support Jiff arguments for Any");
106                }
107                #[cfg(feature = "with-jiff")]
108                Value::JiffTimestamp(_) => {
109                    panic!("SQLx doesn't support Jiff arguments for Any");
110                }
111                #[cfg(feature = "with-jiff")]
112                Value::JiffZoned(_) => {
113                    panic!("SQLx doesn't support Jiff arguments for Any");
114                }
115                Value::Enum(_) => {
116                    panic!("SQLx doesn't support Postgres Enum arguments for Any");
117                }
118                #[cfg(feature = "with-uuid")]
119                Value::Uuid(_) => {
120                    panic!("UUID support not implemented for Any");
121                }
122                #[cfg(feature = "with-rust_decimal")]
123                Value::Decimal(_) => {
124                    panic!("Sqlite doesn't support decimal arguments");
125                }
126                #[cfg(feature = "with-bigdecimal")]
127                Value::BigDecimal(_) => {
128                    panic!("Sqlite doesn't support bigdecimal arguments");
129                }
130                #[cfg(feature = "with-json")]
131                Value::Json(_) => {
132                    panic!("Json support not implemented for Any");
133                }
134                #[cfg(feature = "with-ipnetwork")]
135                Value::IpNetwork(_) => {
136                    panic!("SQLx doesn't support IpNetwork arguments for Any");
137                }
138                #[cfg(feature = "with-mac_address")]
139                Value::MacAddress(_) => {
140                    panic!("SQLx doesn't support MacAddress arguments for Any");
141                }
142                #[cfg(feature = "postgres-array")]
143                Value::Array(_) => {
144                    panic!("SQLx doesn't support array arguments for Any");
145                }
146                #[cfg(feature = "postgres-vector")]
147                Value::Vector(_) => {
148                    panic!("SQLx doesn't support vector arguments for Any");
149                }
150                #[cfg(feature = "postgres-range")]
151                Value::Range(_) => {
152                    panic!("SQLx doesn't support PgRange arguments for Any");
153                }
154            }
155        }
156        args
157    }
158}