perdumonocle / sql-builder

Simple SQL code generator.
MIT License
123 stars 13 forks source link

How i can save instance sql builder for later use #8

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hi, how to do the following:

let value = Some("Hard".to_string());
let query = SqlBuilder::select_from("users")
    .field("name")
    .field("surname")
    .and_where("surname = ?".bind(&"John"));
if let Some(surname) = value {
    query.and_where("surname = ?".bind(&surname));
}
let res = query.sql()?;

Is it possible?

ghost commented 3 years ago

I found a solution to this question

LastLightSith commented 3 years ago

@myduomilia would be helpful for feature readers to see the solution you found :)