Skip to content

Commit 4ce9766

Browse files
committed
Allow no db
1 parent a15a2d6 commit 4ce9766

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: src/glue/insert.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@ pub trait ParameterValue {
1414
#[macro_export]
1515
macro_rules! INSERT {
1616
{$glue:expr, INTO $database:ident.$table:ident ($($column:ident),*) VALUES $(($($value:expr),*)),*} => {
17-
$glue.insert(stringify!($database), stringify!($table), &[$(stringify!($column)),*], vec![$(vec![$($value.into()),*]),*]);
18-
}
17+
$glue.insert(Some(stringify!($database)), stringify!($table), &[$(stringify!($column)),*], vec![$(vec![$($value.into()),*]),*]);
18+
};
19+
{$glue:expr, INTO $table:ident ($($column:ident),*) VALUES $(($($value:expr),*)),*} => {
20+
$glue.insert(None, stringify!($table), &[$(stringify!($column)),*], vec![$(vec![$($value.into()),*]),*]);
21+
};
1922
}
2023

2124
/// ## Insert (`INSERT`)
2225
impl Glue {
2326
pub fn insert(
2427
&mut self,
25-
database: &str,
28+
database: Option<&str>,
2629
table: &str,
2730
columns: &[&str],
2831
recipes: Vec<Vec<Recipe>>,
@@ -37,7 +40,7 @@ impl Glue {
3740
})
3841
.collect::<Result<Vec<Vec<Value>>>>()?;
3942
block_on(self.true_insert(
40-
&Some(database.to_string()),
43+
&database.map(|db| db.to_string()),
4144
table,
4245
columns,
4346
values,

0 commit comments

Comments
 (0)