ExSQL.AST.Insert (exsql v0.1.2)

Copy Markdown

An INSERT (or REPLACE INTO) statement.

columns is nil when the column list is omitted (all table columns in declaration order); column names may also be rowid/oid/_rowid_ to set the rowid explicitly. source is one of:

  • {:values, rows} — a list of value-expression lists
  • {:select, query}INSERT INTO ... SELECT ...
  • :default_valuesINSERT INTO ... DEFAULT VALUES

or_conflict carries the OR clause (REPLACE INTO parses as or_conflict: :replace). upsert is the list of ON CONFLICT clauses in source order: {:nothing, target} or {:update, target, assignments, where}, with target either nil (catch-all, last only) or {columns, where} for a targeted clause.

Summary

Types

source()

@type source() ::
  {:values, [[ExSQL.Parser.expr()]]}
  | {:select, ExSQL.Parser.statement()}
  | :default_values

t()

@type t() :: %ExSQL.AST.Insert{
  columns: [String.t()] | nil,
  or_conflict: nil | :replace | :ignore | :abort | :fail | :rollback,
  returning: list(),
  schema: String.t() | nil,
  source: source(),
  table: String.t(),
  target_qualified: boolean(),
  upsert: [term()]
}