pub struct InsertBuilder<'a> { /* private fields */ }
Expand description

Builder to contruct a Insert query

Implementations

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

Prints the current state of the InsertBuilder 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::InsertBuilder;

let select = InsertBuilder::new()
  .insert_into("users (login, name)")
  .values("('foo', 'Foo')")
  .debug()
  .values("('bar', 'Bar')");

Output

INSERT INTO users (login, name)
VALUES ('foo', 'Foo')

The insert into clause. This method overrides the previous value

use sql_query_builder::InsertBuilder;

let select = InsertBuilder::new()
  .insert_into("users (login, name)");

let select = InsertBuilder::new()
  .insert_into("address (state, country)")
  .insert_into("users (login, name)");

Create InsertBuilder’s instance

The overriding clause

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

Adds at the beginning a raw SQL query.

use sql_query_builder::InsertBuilder;

let raw_query = "insert into users (login, name)";
let select = InsertBuilder::new()
  .raw(raw_query)
  .values("('foo', 'Foo')");

Output

insert into users (login, name)
VALUES ('bar', 'Bar')

Adds a raw SQL query after a specified clause.

use sql_query_builder::{InsertClause, InsertBuilder};

let raw = "values ('foo', 'Foo')";
let select = InsertBuilder::new()
  .insert_into("users (login, name)")
  .raw_after(InsertClause::InsertInto, raw);

Output

INSERT INTO users (login, name)
values ('foo', 'Foo')

Adds a raw SQL query before a specified clause.

use sql_query_builder::{InsertClause, InsertBuilder};

let raw = "insert into users (login, name)";
let select = InsertBuilder::new()
  .raw_before(InsertClause::Values, raw)
  .values("('bar', 'Bar')");

Output

insert into users (login, name)
VALUES ('bar', 'Bar')

The values clause

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.