#[macro_export]
macro_rules! prepare {
(struct $name:ident { $($field:ident : $ty:ty),* $(,)? }) => {
#[derive(Debug, Clone, Default)]
pub struct $name {
$(pub $field: <$ty as $crate::expr::SqlType>::Native,)*
}
#[allow(dead_code, non_snake_case)]
impl $name {
$(
pub fn $field() -> $crate::expr::Expr<$crate::scope::Nil, $ty> {
$crate::expr::placeholder::<$ty>(::std::concat!(
::std::module_path!(), "::", ::std::stringify!($name),
".", ::std::stringify!($field)
))
}
)*
}
impl $crate::select::PreparedParams for $name {
fn into_named_values(self) -> ::std::vec::Vec<(&'static str, $crate::expr::Value)> {
::std::vec![
$((
::std::concat!(
::std::module_path!(), "::", ::std::stringify!($name),
".", ::std::stringify!($field)
),
::std::convert::Into::into(self.$field),
),)*
]
}
}
};
}