Struct sql_query_builder::Values
source · pub struct Values { /* private fields */ }
Expand description
Builder to contruct a Values command
Implementations§
source§impl Values
impl Values
sourcepub fn debug(self) -> Self
pub fn debug(self) -> Self
Prints the current state of the Values to the standard output in a more ease to read version. This method is useful to debug complex queries or just print the generated SQL while you type
§Example
let values = sql::Values::new()
.values("(1, 'one'), (2, 'two')")
.values("(3, 'three')")
.debug();
Prints to the standard output
-- ------------------------------------------------------------------------------
VALUES (1, 'one'), (2, 'two'), (3, 'three')
-- ------------------------------------------------------------------------------
sourcepub fn print(self) -> Self
pub fn print(self) -> Self
Prints the current state of the Values to the standard output similar to debug method, the difference is that this method prints in one line.
sourcepub fn raw(self, raw_sql: &str) -> Self
pub fn raw(self, raw_sql: &str) -> Self
Adds at the beginning a raw SQL query.
§Example
let raw_query = "insert into my_table(num, txt)";
let values_query = sql::Values::new()
.raw(raw_query)
.values("(1, 'one'), (2, 'two')")
.as_string();
Output
insert into my_table(num, txt)
VALUES (1, 'one'), (2, 'two')
sourcepub fn raw_after(self, clause: ValuesClause, raw_sql: &str) -> Self
pub fn raw_after(self, clause: ValuesClause, raw_sql: &str) -> Self
Adds a raw SQL query after a specified clause.
§Example
let raw_query = ", (3, 'three')";
let values_query = sql::Values::new()
.values("(1, 'one'), (2, 'two')")
.raw_after(sql::ValuesClause::Values, raw_query)
.as_string();
Output
VALUES (1, 'one'), (2, 'two') , (3, 'three')
sourcepub fn raw_before(self, clause: ValuesClause, raw_sql: &str) -> Self
pub fn raw_before(self, clause: ValuesClause, raw_sql: &str) -> Self
Adds a raw SQL query before a specified clause.
§Example
let raw_query = "/* the values command */";
let values_query = sql::Values::new()
.raw_before(sql::ValuesClause::Values, raw_query)
.values("(1, 'one'), (2, 'two')")
.as_string();
Output
/* the values command */
VALUES (1, 'one'), (2, 'two')
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Values
impl RefUnwindSafe for Values
impl Send for Values
impl Sync for Values
impl Unpin for Values
impl UnwindSafe for Values
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more