defmodule ExSQL.AST.ColumnDef do @moduledoc """ A column definition inside `CREATE TABLE`. `affinity` follows SQLite's type affinity model (section 3.1 of the SQLite datatype docs): every column has one of five affinities derived from its declared type, rather than a strict type. """ defstruct name: nil, declared_type: nil, affinity: :blob, primary_key: false, autoincrement: false, not_null: false, unique: false, default: nil, collate: nil, references: nil, generated: nil, check: nil, check_name: nil @type affinity :: :integer | :text | :real | :numeric | :blob | :any @type t :: %__MODULE__{ name: String.t(), declared_type: String.t() | nil, affinity: affinity(), primary_key: boolean(), autoincrement: boolean(), not_null: boolean(), unique: boolean(), default: ExSQL.Parser.expr() | nil, collate: String.t() | nil, references: term() | nil, generated: {:virtual | :stored, ExSQL.Parser.expr()} | nil, check: ExSQL.Parser.expr() | nil, check_name: String.t() | nil } end