Skip to content

Commit

Permalink
Add DatabaseId and DatabaseVariable structs
Browse files Browse the repository at this point in the history
Summary:
# Problem Statement
- In this diff I finish the implementation started by wtetzner of `DatabaseId` and `DatabaseVariable` structs.
- Found that the macro `mysql_query!()` does not support mysql variables, asking for feedback in this diff comments.

Reviewed By: wtetzner

Differential Revision: D63909712

fbshipit-source-id: 9d31588bc0da2feb2710c13974068601ed0b2ffd
  • Loading branch information
mbassale authored and facebook-github-bot committed Nov 27, 2024
1 parent 63c543b commit 7d02be5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion shed/sql/common/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl<'a, T: AsSql> AsSql for SqlList<'a, T> {

/// mysql_query!("SELECT foo FROM table WHERE col = {id}", id = "foo");
/// mysql_query!("SELECT foo FROM table WHERE col = {}", "foo");
/// mysql_query!("SELECT foo FROM table WHERE col1 = {my_var} AND col = {id}", id = "foo"; my_var = "@bar");
#[macro_export]
macro_rules! mysql_query {
($query:expr) => {
Expand All @@ -130,7 +131,14 @@ macro_rules! mysql_query {
::sql::mysql::MySqlQuery::new(format!(
$query, $( &::sql::mysql::AsSql::as_sql(&$arg, false) ),*
))
}
};
($query:expr, $($key:ident = $value:expr),* ; $($key2:ident = $variable:expr),*) => {
::sql::mysql::MySqlQuery::new(format!(
$query,
$( $key = &::sql::mysql::AsSql::as_sql(&$value, false), )*
$( $key2 = &$variable.as_sql(false), )*
))
};
}
pub use mysql_query;

Expand Down

0 comments on commit 7d02be5

Please sign in to comment.