1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#[cfg(feature = "pg")]
#[macro_export]
macro_rules! pg_fns {
	(from_table $name:ident $($rust_name:ident,$db_name:tt);+) => {
		impl From<&$crate::Row> for $name{
			fn from(r:&$crate::Row)->Self{
				Self{
					$($rust_name:r.get(stringify!($db_name))),+
				}
			}
		}
		impl From<$crate::Row> for $name{
			fn from(r:$crate::Row)->Self{
				Self::from(&r)
			}
		}
  };
	(create_table_str $name:ident $($db_name:tt,$db_type:expr);+) => {
			pub fn to_pg_create_table_str()->String{
				let fields = [
					$(concat!("\"",stringify!($db_name),"\""," ",$db_type)),+
				];
				format!("CREATE TABLE IF NOT EXISTS {} ({});",<Self as $crate::legacy::Table>::table_name(),fields.join(","))
			}
  };
}
/// add here the default macros for no backend enabled
#[cfg(not(feature = "pg"))]
#[macro_export]
macro_rules! pg_fns {
	(from_table $name:ident $($rust_name:ident,$db_name:tt);+) => {};
	(create_table_str $name:ident $($db_name:tt,$db_type:expr);+) => {};
}
#[cfg(feature = "pg")]
#[macro_export]
macro_rules! pg_params {
	($($param:expr),*) => {
		&[$(&$param),*]
	};
}