Class: Sqlx::EnumWriter
- Defined in:
- runtime/sqlx/enum.rb,
runtime/sqlx/enum.rbs
Overview
The bound writer behind Enum#writer — one column of one table. It owns
the UPDATE shape so the model carries no per-field write helper; the
label -> stored-value conversion stays with the bound declaration, so
the write's mapping is single-sourced the way reads are.
Instance Method Summary collapse
-
#initialize(table:, column:, declaration:) ⇒ EnumWriter
constructor
binds the writer to its column.
-
#write!(id, label) ⇒ nil
the single-column UPDATE: stores the label's value on the bound column, stamps
updated_atwith the current UTC time, and matches the row by primary key.
Constructor Details
#initialize(table:, column:, declaration:) ⇒ EnumWriter
binds the writer to its column. This body runs behind Enum#writer, the
entry members use for their bang writers.
131 |
# File 'runtime/sqlx/enum.rb', line 131
def initialize: (table: String, column: String, declaration: Enum) -> void
|
Instance Method Details
#write!(id, label) ⇒ nil
the single-column UPDATE: stores the label's value on the bound column,
stamps updated_at with the current UTC time, and matches the row by
primary key. An unknown label raises through the bound declaration's
strict value before any SQL runs, so a redeclared enum cannot leave a
writer pinned to a stale slot. A row the id does not match is a silent
no-op, the way the per-model helpers this replaces behaved — the bang
promises the write attempt, not that a row existed. The target table
carries updated_at; one without it fails loud from the driver. The write
entry answers the rows it returned; this writer answers nil — the bang
promises the attempt, and a non-RETURNING UPDATE returns no row.
155 |
# File 'runtime/sqlx/enum.rb', line 155
def write!: (untyped id, untyped label) -> nil
|