Support Rust expression like {x.y} in SQL strings

This commit is contained in:
gwenn
2023-08-20 10:35:26 +02:00
parent e8f73c93c4
commit b86d9321b5
4 changed files with 34 additions and 7 deletions

View File

@@ -16,7 +16,30 @@ fn test_literal() -> Result {
let first_name = "El";
let last_name = "Barto";
let mut stmt = Stmt;
__bind!(stmt "SELECT $first_name, $last_name");
__bind!(stmt "SELECT $first_name, {last_name}");
Ok(())
}
#[test]
fn test_tuple() -> Result {
let names = ("El", "Barto");
let mut stmt = Stmt;
__bind!(stmt "SELECT {names.0}, {names.1}");
Ok(())
}
#[test]
fn test_struct() -> Result {
struct Person<'s> {
first_name: &'s str,
last_name: &'s str,
}
let p = Person {
first_name: "El",
last_name: "Barto",
};
let mut stmt = Stmt;
__bind!(stmt "SELECT {p.first_name}, {p.last_name}");
Ok(())
}