1use crate::ops::{AsSql, Value};
2
3impl AsSql for Value {
4 fn as_sql(&self) -> String {
5 match self {
6 Value::String(s) => s.to_owned(),
7 _ => self.to_string(),
8 }
9 }
10}
11
12impl AsSql for &Value {
13 fn as_sql(&self) -> String {
14 match self {
15 Value::String(s) => s.to_owned(),
16 _ => self.to_string(),
17 }
18 }
19}
20
21impl AsSql for &&Value {
22 fn as_sql(&self) -> String {
23 match self {
24 Value::String(s) => s.to_owned(),
25 _ => self.to_string(),
26 }
27 }
28}
29
30macro_rules! to_sql {
31 ([$($ty:ty)*]) => {
32$(impl AsSql for $ty{
33 fn as_sql(&self) -> String {
34 self.to_string()
35 }
36})*
37 };
38}
39
40to_sql!([String & String && String]);
41to_sql!([&str && str]);
42to_sql!([i8 i16 i32 i64 isize]);
43to_sql!([u8 u16 u32 u64 usize]);
44to_sql!([f32 f64]);