Skip to main content

lib/ex_sql/ast/update.ex

defmodule ExSQL.AST.Update do
  @moduledoc "An `UPDATE [OR ...] ... SET ... [WHERE ...]` statement."

  defstruct table: nil,
            schema: nil,
            target_qualified: false,
            index_hint: nil,
            assignments: [],
            from: nil,
            where: nil,
            or_conflict: nil,
            returning: [],
            order_by: [],
            limit: nil,
            offset: nil

  @type t :: %__MODULE__{
          table: String.t(),
          schema: String.t() | nil,
          target_qualified: boolean(),
          index_hint: nil | {:indexed_by, String.t()} | :not_indexed,
          assignments: [{String.t(), ExSQL.Parser.expr()}],
          from: term() | nil,
          where: ExSQL.Parser.expr() | nil,
          or_conflict: nil | :replace | :ignore | :abort | :fail | :rollback,
          returning: list(),
          order_by: list(),
          limit: ExSQL.Parser.expr() | nil,
          offset: ExSQL.Parser.expr() | nil
        }
end