Expand description
Mods for psql::insert.
use keelson_psql as psql;
use keelson_psql::{arg, insert};
let q = psql::insert((
insert::into("users").columns(["id", "name"]),
insert::values((arg(1i32), arg("ada"))),
insert::on_conflict("id").do_update(insert::set_excluded(["name"])),
insert::returning("*"),
));§The mods that are not for the INSERT itself
set, set_col, set_excluded and where_ apply to a
ConflictClause, not to an
InsertQuery — an INSERT has no SET and no WHERE. They are here because
this is where they are used: inside
on_conflict(..).do_update(..). An
InsertQuery does not implement the traits they need, so misplacing one is a
compile error rather than a surprise.
The two WHEREs of an ON CONFLICT are easy to conflate and behave nothing
alike: on_conflict(..).where_(..) is the index predicate, matched against a
partial unique index’s own definition, while where_ inside do_update
filters which conflicting rows are updated.
Re-exports§
pub use crate::shared::from_item as into;pub use crate::shared::on_conflict;pub use crate::shared::on_conflict_on_constraint;pub use crate::shared::recursive;pub use crate::shared::returning;pub use crate::shared::rows;pub use crate::shared::set;pub use crate::shared::set_col;pub use crate::shared::set_excluded;pub use crate::shared::values;pub use crate::shared::values_from_query as query;pub use crate::shared::where_;pub use crate::shared::with;
Functions§
- overriding_
system OVERRIDING SYSTEM VALUE— write the supplied value into aGENERATED ALWAYS AS IDENTITYcolumn, which otherwise refuses one.- overriding_
user OVERRIDING USER VALUE— ignore the supplied value and take the sequence’s, for aGENERATED BY DEFAULT AS IDENTITYcolumn.