pub struct ValuesBuilder { /* private fields */ }
Expand description

Builder to contruct a values command

Implementations

Gets the current state of the ValuesBuilder and returns it as string

Prints the current state of the ValuesBuilder into console output in a more ease to read version. This method is useful to debug complex queries or just to print the generated SQL while you type

use sql_query_builder::ValuesBuilder;

let values = ValuesBuilder::new()
  .values("(1, 'one'), (2, 'two')")
  .values("(3, 'three')")
  .debug();

Output

VALUES (1, 'one'), (2, 'two'), (3, 'three')

Create ValuesBuilder’s instance

Prints the current state of the ValuesBuilder into console output similar to debug method, the difference is that this method prints in one line.

Adds at the beginning a raw SQL query.

use sql_query_builder::ValuesBuilder;

let raw_query = "insert into my_table(nun, txt)";
let values = ValuesBuilder::new()
  .raw(raw_query)
  .values("(1, 'one'), (2, 'two')")
  .debug();

Output

insert into my_table(num, txt)
VALUES (1, 'one'), (2, 'two')

Adds a raw SQL query after a specified clause.

use sql_query_builder::{ValuesBuilder, ValuesClause};

let raw_query = ", (3, 'three')";
let values = ValuesBuilder::new()
  .values("(1, 'one'), (2, 'two')")
  .raw_after(ValuesClause::Values, raw_query)
  .debug();

Output

VALUES (1, 'one'), (2, 'two') , (3, 'three')

Adds a raw SQL query before a specified clause.

use sql_query_builder::{ValuesBuilder, ValuesClause};

let raw_query = "/* the values command */";
let values = ValuesBuilder::new()
  .raw_before(ValuesClause::Values, raw_query)
  .values("(1, 'one'), (2, 'two')")
  .debug();

Output

/* the values command */
VALUES (1, 'one'), (2, 'two')

The values clause

use sql_query_builder::ValuesBuilder;

let values = ValuesBuilder::new()
  .values("(1, 'one'), (2, 'two')")
  .values("(3, 'three')");

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.