Packages

An Elixir SQLite database library utilising the rusqlite Rust crate

Current section

Files

Jump to
xqlite lib xqlite schema column_info.ex
Raw

lib/xqlite/schema/column_info.ex

defmodule Xqlite.Schema.ColumnInfo do
@moduledoc """
Information about a specific column in a table, corresponding to `PRAGMA table_info`.
"""
alias Xqlite.Schema.Types
@typedoc """
Struct definition.
* `:column_id` - The zero-indexed ID of the column within the table.
* `:name` - Name of the column.
* `:type_affinity` - The resolved data type affinity (see `t:Types.type_affinity/0`).
* `:declared_type` - The original data type string exactly as declared in the `CREATE TABLE` statement (e.g., "VARCHAR(50)", "INTEGER", "BOOLEAN").
* `:nullable` - `true` if the column allows NULL values, `false` otherwise (derived from `NOT NULL` constraint).
* `:default_value` - The default value expression as a string literal (e.g., "'default'", "123", "CURRENT_TIMESTAMP"), or `nil` if no default.
* `:primary_key_index` - If this column is part of the primary key, its 1-based index within the key (e.g., 1 for single PK, 1 or 2 for compound PK). `0` if not part of the primary key.
* `:hidden_kind` - Indicates if and how a column is hidden/generated (see `t:Types.column_hidden_kind/0`).
"""
@type t :: %__MODULE__{
column_id: integer(),
name: String.t(),
type_affinity: Types.type_affinity(),
declared_type: String.t(),
nullable: boolean(),
default_value: String.t() | nil,
primary_key_index: non_neg_integer(),
hidden_kind: Types.column_hidden_kind()
}
@enforce_keys [
:column_id,
:name,
:type_affinity,
:declared_type,
:nullable,
:primary_key_index,
:hidden_kind
]
defstruct [
:column_id,
:name,
:type_affinity,
:declared_type,
:nullable,
:default_value,
:primary_key_index,
:hidden_kind
]
end