mirror of
https://github.com/isar/rusqlite.git
synced 2025-08-19 12:29:34 +08:00
Support Rust expression like {x.y}
in SQL strings
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user