Skip to main content

build_insert_sql

Function build_insert_sql 

Source
pub fn build_insert_sql(
    table: &str,
    schema: Option<&str>,
    data: &[(String, SqlValue)],
    column_types: &HashMap<String, String>,
) -> Result<(String, Vec<SqlValue>), StoreError>
Expand description

Build a parameterized INSERT INTO "table" (…) VALUES (…).

A NULL data value renders as the inline NULL keyword (a fixed SQL token, injection-safe) and consumes no $N placeholder — the same discipline 35.b applies to NULL in a where clause. Postgres infers the column type for an inline NULL.

§v1.36.2 — each $N value placeholder is cast to its column’s introspected type (column_types) so a text-bound value writes into a uuid / int / timestamptz column. An empty column_types map emits bare $N (the pre-1.36.2 behaviour). §Fase 37.x.c (D2) — schema schema-qualifies the relation (INSERT INTO "schema"."table"); None renders the bare "table".