Model¶
Model is the base class every Ferro model inherits from. The lifecycle is: define a subclass with annotated fields (which registers its table schema), connect() to a database, then perform CRUD through classmethods (create, get, where, ...) and instance methods (save, delete, refresh). Because Model is a Pydantic model, instances validate on construction and serialize like any other Pydantic object.
Model
¶
Model(**data: Any)
Bases: BaseModel
The base class of every Ferro model: a Pydantic model backed by a table.
A subclass declares its columns as annotated fields, and its table is
created on connect with auto_migrate=True. Every
database call runs inside a session, opened with
async with engines.session():, and the examples on this page run in
one. See Models and fields to declare a
model and Connections for
sessions.
A model declares table-wide constraints in class attributes:
__ferro_composite_uniques__ and __ferro_composite_indexes__ (see
Composite uniques and
Composite indexes),
__ferro_checks__ (see
Table checks) and
__ferro_rls__ (see Using with Postgres RLS).
Examples:
mary = await Author.create(name="Mary Somerville", email="mary@example.com")
fetched = await Author.get(mary.id)
assert fetched is mary
Within a session, fetching a row you already hold returns the same object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**data
|
Any
|
The field values. A forward relation is set through its
foreign-key column, |
{}
|
Raises:
| Type | Description |
|---|---|
TypeError
|
A keyword names a retired field, a generated one or a forward relation. |
ValidationError
|
A keyword names no field, or a value does not validate. |
-
Reference
Python API
connect, Session and the registry
evict_instance
Methods:
| Name | Description |
|---|---|
model_dump |
Dump the instance's fields to a dict, as Pydantic's |
model_dump_json |
Dump the instance's fields to JSON, as Pydantic's |
model_copy |
Copy the instance, as Pydantic's |
save |
Write the instance to its row: insert it when new, update it otherwise. |
delete |
Delete the instance's row. |
all |
Fetch every row of the model's table. |
get |
Fetch one record by primary key. |
get_or_none |
Fetch one record by primary key, or |
refresh |
Reload the instance's fields from its row, in place. |
load |
Fill an unloaded instance from its row, in place, and return it. |
where |
Start a query filtered by a lambda predicate. |
select |
Start a query, of whole records or of some columns. |
using |
Run this model's operations on a named connection. |
create |
Insert a new record and return it. |
upsert |
Insert a record, or update the row that has its primary key. |
bulk_create |
Insert many new records in one call. |
get_or_create |
Fetch the first record whose fields match, or create it. |
update_or_create |
Update the first record whose fields match, or create it. |
model_dump
¶
Dump the instance's fields to a dict, as Pydantic's model_dump does.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Pydantic's positional |
()
|
**kwargs
|
Any
|
Pydantic's keyword |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The field values by name. |
Raises:
| Type | Description |
|---|---|
InstanceNotLoaded
|
The instance is unloaded; load it with
|
model_dump_json
¶
Dump the instance's fields to JSON, as Pydantic's model_dump_json does.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
Any
|
Pydantic's positional |
()
|
**kwargs
|
Any
|
Pydantic's keyword |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
The JSON text. |
Raises:
| Type | Description |
|---|---|
InstanceNotLoaded
|
The instance is unloaded; load it with
|
model_copy
¶
Copy the instance, as Pydantic's model_copy does.
A cached relation the copy's foreign-key column no longer points at is dropped, so the copy reads the relation its own key names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
update
|
Mapping[str, Any] | None
|
Field values to change in the copy. Defaults to |
None
|
deep
|
bool
|
Copy the field values too. Defaults to |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
The copy. |
Raises:
| Type | Description |
|---|---|
InstanceNotLoaded
|
|
TypeError
|
|
save
async
¶
save(*, using: str | None = None, session: Session | None = None, on_conflict: Literal['update'] | None = None, only: set[str] | frozenset[str] | list[str] | tuple[str, ...] | None = None, exclude: set[str] | frozenset[str] | list[str] | tuple[str, ...] | None = None) -> None
Write the instance to its row: insert it when new, update it otherwise.
An instance you built and never saved is inserted. One fetched from
the database, or saved before, updates its row by primary key, and
only= or exclude= limit that update to some columns. For an
update across many rows, use Query.update.
See Saving: INSERT or UPDATE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
using
|
str | None
|
The named connection to write on. Defaults to |
None
|
session
|
Session | None
|
The session to run in. Defaults to |
None
|
on_conflict
|
Literal['update'] | None
|
|
None
|
only
|
set[str] | frozenset[str] | list[str] | tuple[str, ...] | None
|
On an update, the columns to write, as a set, list or
tuple of field names. Defaults to |
None
|
exclude
|
set[str] | frozenset[str] | list[str] | tuple[str, ...] | None
|
On an update, the columns not to write. Defaults to
|
None
|
Raises:
| Type | Description |
|---|---|
InstanceNotLoaded
|
The instance is unloaded; load it with
|
UniqueViolationError
|
An insert repeats a primary key or unique value. |
ModelDoesNotExist
|
The row behind a saved instance no longer exists, or its primary key was changed in memory. |
TypeError
|
|
ValueError
|
|
Note
The instance is not reloaded after a partial update, so a field
left out of only keeps its value in memory even if the row
differs. A copy made with model_copy() updates the same row as
the original. An instance inserted in a transaction that rolled
back still counts as saved, so its next save() raises
ModelDoesNotExist.
Examples:
Saving a new instance inserts it:
mary = Author(name="Mary Somerville", email="mary@example.com")
await mary.save()
assert mary.id == 3
Saving a fetched instance with only= updates just those columns:
post = await Post.get(2)
post.views = 1000
post.title = "Not written to the row"
await post.save(only={"views"})
rows = await Post.select("title", "views").where(lambda post: post.id == 2).all()
assert rows[0].title == "The Education of a Computer"
assert rows[0].views == 1000
delete
async
¶
Delete the instance's row.
The instance stays in memory and counts as new again: saving it inserts a new row. An instance without a primary key value has no row, and the call does nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
using
|
str | None
|
The named connection to delete on. Defaults to |
None
|
session
|
Session | None
|
The session to run in. Defaults to |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Examples:
all
async
classmethod
¶
Fetch every row of the model's table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
using
|
str | None
|
The named connection to read from. Defaults to |
None
|
session
|
Session | None
|
The session to run in. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
list[Self]
|
One instance per row, in the order the database returns them. |
Examples:
get
async
classmethod
¶
Fetch one record by primary key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pk
|
Any
|
The primary key value to look up. |
required |
session
|
Session | None
|
The session to run in. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
The record whose primary key is |
Raises:
| Type | Description |
|---|---|
ModelDoesNotExist
|
No row has that key. Use
|
RuntimeError
|
The model declares no primary key. |
Examples:
- Guide Queries Fetching by primary key
-
Reference
FerroError and its subclasses
ModelDoesNotExist
get_or_none
async
classmethod
¶
Fetch one record by primary key, or None when no row has it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pk
|
Any
|
The primary key value to look up. |
required |
session
|
Session | None
|
The session to run in. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
Self | None
|
The record whose primary key is |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
The model declares no primary key. |
Examples:
- Guide Queries Fetching by primary key
-
Reference
-
FerroError and its subclasses
ModelDoesNotExist -
Python API
Model
Modelget
-
FerroError and its subclasses
refresh
async
¶
Reload the instance's fields from its row, in place.
A change made in memory and not saved is lost. See
refresh().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
using
|
str | None
|
The named connection to read from. Defaults to |
None
|
session
|
Session | None
|
The session to run in. Defaults to |
None
|
Raises:
| Type | Description |
|---|---|
ModelDoesNotExist
|
The row no longer exists. |
RuntimeError
|
The instance has no primary key value. |
Examples:
load
async
¶
load() -> Self
Fill an unloaded instance from its row, in place, and return it.
A forward relation nothing loaded reads as an unloaded instance that
holds only its primary key. load() reads the row through the
connection the instance came from and fills the same object, so every
reference to it sees the row. On a complete instance it sends no
statement. See
Loaded relations.
Returns:
| Type | Description |
|---|---|
Self
|
The instance itself, now complete. |
Raises:
| Type | Description |
|---|---|
ModelDoesNotExist
|
The row no longer exists. |
Examples:
where
classmethod
¶
Start a query filtered by a lambda predicate.
The lambda receives a stand-in for one row; comparing its fields builds the SQL condition. Name the parameter after the model, in lowercase. A field name the model does not declare raises when the query is built. See Queries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predicate
|
Predicate[Self]
|
A lambda that takes the row stand-in and returns a
condition, such as |
required |
session
|
Session | None
|
The session the query runs in. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
Query[Self]
|
A query over the matching rows; nothing runs until you await one
of its methods, such as |
Examples:
select
classmethod
¶
select(selector: RowSelector[Self], *, session: Session | None = None) -> ProjectedQuery[Self]
select(*columns: str, session: Session | None = None) -> ProjectedQuery[Self]
select(*selectors: RowSelector[Self] | str, session: Session | None = None) -> Query[Self] | ProjectedQuery[Self]
Start a query, of whole records or of some columns.
With no argument, the query returns model instances. With a lambda
that picks fields, or with column names, it returns
Row records holding only those columns. See
Selecting a column subset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*selectors
|
RowSelector[Self] | str
|
Nothing; one lambda returning a field, a tuple of fields or a dict naming them; or column names as strings. |
()
|
session
|
Session | None
|
The session the query runs in. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
Query[Self] | ProjectedQuery[Self]
|
A |
Raises:
| Type | Description |
|---|---|
AttributeError
|
A selector names a column the model does not have. |
TypeError
|
The selectors mix a lambda with column names, or are not a lambda or strings. |
ValueError
|
The selection is empty, two fields share an output name, or a string names a related column. |
Examples:
using
classmethod
¶
using(name: str) -> ModelConnection[Self]
Run this model's operations on a named connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The connection's name, as given to |
required |
Returns:
| Type | Description |
|---|---|
ModelConnection[Self]
|
An object with this model's |
Examples:
from ferro import connect, engines
await connect("sqlite::memory:", name="archive", auto_migrate=True)
async with engines.session("archive"):
await Author.using("archive").create(name="Mary Somerville", email="mary@example.com")
archived = await Author.using("archive").all()
assert [author.name for author in archived] == ["Mary Somerville"]
- Reference Python API Model
create
async
classmethod
¶
Insert a new record and return it.
create always inserts; use upsert to update
a row whose primary key exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session | None
|
The session to run in. Defaults to |
None
|
**fields
|
Any
|
The field values. A forward relation is set through its
foreign-key column, |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The saved instance, with a generated primary key filled in. |
Raises:
| Type | Description |
|---|---|
TypeError
|
A keyword names a forward relation, or a retired or generated field. |
ValidationError
|
A keyword names no field, or a value does not validate. |
UniqueViolationError
|
A row with the same primary key or unique value exists. |
Examples:
upsert
async
classmethod
¶
Insert a record, or update the row that has its primary key.
Without a primary key value, an auto-increment key has nothing to conflict on and the record is inserted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session | None
|
The session to run in. Defaults to |
None
|
**fields
|
Any
|
The field values, including the primary key. |
{}
|
Returns:
| Type | Description |
|---|---|
Self
|
The saved instance. |
Examples:
bulk_create
async
classmethod
¶
bulk_create(instances: list[Self], *, using: str | None = None, session: Session | None = None) -> int
Insert many new records in one call.
Every record is inserted or none is. Ferro splits a batch too large for one statement into several, inside the same all-or-nothing boundary. See Creating rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instances
|
list[Self]
|
The instances to insert. |
required |
using
|
str | None
|
The named connection to write on. Defaults to |
None
|
session
|
Session | None
|
The session to run in. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
int
|
The number of rows inserted. |
Examples:
get_or_create
async
classmethod
¶
get_or_create(defaults: dict[str, Any] | None = None, *, session: Session | None = None, **fields: Any) -> tuple[Self, bool]
Fetch the first record whose fields match, or create it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
defaults
|
dict[str, Any] | None
|
Extra field values used only when creating. Defaults to
|
None
|
session
|
Session | None
|
The session to run in. Defaults to |
None
|
**fields
|
Any
|
The values to match exactly, also used when creating. |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Self, bool]
|
The record, and |
Examples:
update_or_create
async
classmethod
¶
update_or_create(defaults: dict[str, Any] | None = None, *, session: Session | None = None, **fields: Any) -> tuple[Self, bool]
Update the first record whose fields match, or create it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
defaults
|
dict[str, Any] | None
|
The field values to write, on the found record or the
new one. Defaults to |
None
|
session
|
Session | None
|
The session to run in. Defaults to |
None
|
**fields
|
Any
|
The values to match exactly, also used when creating. |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[Self, bool]
|
The record, and |
Examples:
Routing one call¶
Model.using(name) binds the model's class methods to one named connection and returns a ModelConnection.
ModelConnection
¶
A model's class methods bound to one named connection.
Model.using returns one. Each method behaves like
the model's class method of the same name and runs on the bound
connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_cls
|
type[M]
|
The model class. |
required |
connection_name
|
str
|
The name of the connection to run on. |
required |
Methods:
| Name | Description |
|---|---|
create |
Insert a new record on the connection and return it. |
upsert |
Insert a record on the connection, or update the row with its primary key. |
all |
Fetch every row of the model's table on the connection. |
select |
Start a query of whole records on the connection. |
where |
Start a query on the connection, filtered by a lambda predicate. |
get |
Fetch one record by primary key on the connection. |
get_or_none |
Fetch one record by primary key on the connection, or |
bulk_create |
Insert many new records on the connection in one call. |
get_or_create |
Fetch the first matching record on the connection, or create it. |
update_or_create |
Update the first matching record on the connection, or create it. |
Attributes:
| Name | Type | Description |
|---|---|---|
model_cls |
type[M]
|
The bound model class. |
create
async
¶
create(**fields: Any) -> M
Insert a new record on the connection and return it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**fields
|
Any
|
The field values. |
{}
|
Returns:
| Type | Description |
|---|---|
M
|
The saved instance. |
Raises:
| Type | Description |
|---|---|
UniqueViolationError
|
A row with the same primary key or unique value exists. |
upsert
async
¶
upsert(**fields: Any) -> M
Insert a record on the connection, or update the row with its primary key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**fields
|
Any
|
The field values, including the primary key. |
{}
|
Returns:
| Type | Description |
|---|---|
M
|
The saved instance. |
all
async
¶
all() -> list[M]
Fetch every row of the model's table on the connection.
Returns:
| Type | Description |
|---|---|
list[M]
|
One instance per row. |
select
¶
select() -> Query[M]
Start a query of whole records on the connection.
Returns:
| Type | Description |
|---|---|
Query[M]
|
A query over every row. |
where
¶
get
async
¶
get(pk: Any) -> M
Fetch one record by primary key on the connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pk
|
Any
|
The primary key value to look up. |
required |
Returns:
| Type | Description |
|---|---|
M
|
The record whose primary key is |
Raises:
| Type | Description |
|---|---|
ModelDoesNotExist
|
No row has that key. |
get_or_none
async
¶
get_or_none(pk: Any) -> M | None
Fetch one record by primary key on the connection, or None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pk
|
Any
|
The primary key value to look up. |
required |
Returns:
| Type | Description |
|---|---|
M | None
|
The record whose primary key is |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
The model declares no primary key. |
bulk_create
async
¶
get_or_create
async
¶
Fetch the first matching record on the connection, or create it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
defaults
|
dict[str, Any] | None
|
Extra field values used only when creating. Defaults to
|
None
|
**fields
|
Any
|
The values to match exactly, also used when creating. |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[M, bool]
|
The record, and whether it was created. |
update_or_create
async
¶
Update the first matching record on the connection, or create it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
defaults
|
dict[str, Any] | None
|
The field values to write, on the found record or the
new one. Defaults to |
None
|
**fields
|
Any
|
The values to match exactly, also used when creating. |
{}
|
Returns:
| Type | Description |
|---|---|
tuple[M, bool]
|
The record, and whether it was created. |
Table-level declarations¶
A model declares its table checks in __ferro_checks__ and its row security in __ferro_rls__; see Table checks and Using with Postgres RLS.
Check
dataclass
¶
A CHECK constraint across the columns of one row, declared in __ferro_checks__.
Ferro names the constraint ck_<table>_<suffix> and writes it inside
CREATE TABLE, on SQLite and Postgres alike. The predicate is a lambda
written like a where filter. See
Table checks for the
predicates it accepts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suffix
|
str
|
The end of the constraint's name: a lowercase identifier
( |
required |
predicate
|
Predicate[Any]
|
A lambda over the model's own columns, its parameter named after the model. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
|
Examples:
from typing import ClassVar
from ferro import Check, CheckViolationError, Field, Model, create_tables
class Payment(Model):
__ferro_checks__: ClassVar[tuple[Check, ...]] = (
Check("positive_amount", lambda payment: payment.amount > 0),
)
id: int | None = Field(default=None, primary_key=True)
amount: int
await create_tables()
try:
await Payment.create(amount=0)
except CheckViolationError as error:
assert "ck_payment_positive_amount" in str(error)
else:
raise AssertionError("expected CheckViolationError")
-
Reference
Python API
Field, FerroField and DbType
fn
Attributes:
| Name | Type | Description |
|---|---|---|
suffix |
str
|
The constraint name's suffix, after |
predicate |
Predicate[Any]
|
The lambda the constraint's body is rendered from. |
RowSecurity
dataclass
¶
A model's row security: its policies and the table's flags.
Assign it to the model's __ferro_rls__. On Postgres the table gets
ENABLE ROW LEVEL SECURITY and one CREATE POLICY per policy; on
SQLite, which has no row security, Ferro warns and creates the table
without them. See
Scope rows by tenant for the setup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*policies
|
RowPolicy
|
The table's policies. |
()
|
force
|
bool
|
Also emit |
True
|
Raises:
| Type | Description |
|---|---|
TypeError
|
A policy is not a |
Examples:
from typing import ClassVar
from uuid import UUID
from ferro import Field, Model, RowPolicy, RowSecurity
class Invoice(Model):
id: int | None = Field(default=None, primary_key=True)
tenant_id: UUID
total: int
__ferro_rls__: ClassVar = RowSecurity(
RowPolicy(column="tenant_id", setting="app.tenant_id")
)
On Postgres, Invoice's table is created with:
ALTER TABLE "invoice" ENABLE ROW LEVEL SECURITY
ALTER TABLE "invoice" FORCE ROW LEVEL SECURITY
CREATE POLICY "rls_invoice_tenant_id" ON "invoice" FOR ALL
USING ("tenant_id" = NULLIF(current_setting('app.tenant_id', true), '')::uuid)
WITH CHECK ("tenant_id" = NULLIF(current_setting('app.tenant_id', true), '')::uuid)
Attributes:
| Name | Type | Description |
|---|---|---|
policies |
tuple[RowPolicy, ...]
|
The table's policies, in declaration order. |
force |
bool
|
Whether the table also gets |
RowPolicy
dataclass
¶
RowPolicy(name: str | None = None, command: str = 'all', restrictive: bool = False, column: str | None = None, setting: str | None = None, using: str | None = None, with_check: str | None = None)
One Postgres row policy: which rows a command may read or write.
It comes in two forms. The shorthand, RowPolicy(column=..., setting=...),
compares a column with a session setting and renders, for both USING
and WITH CHECK:
The cast follows the column's type: uuid, text, varchar and the
integer types are supported, and any other type is refused when the
class is defined. The NULLIF makes an unset or reset setting match no
rows instead of raising a cast error; see
Policy expressions.
The raw form, RowPolicy(name=..., using=...), takes the SQL expressions
as written and needs a name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
The end of the policy's name, |
None
|
command
|
str
|
The command the policy covers: |
'all'
|
restrictive
|
bool
|
Make the policy |
False
|
column
|
str | None
|
Shorthand: the model column holding the scope value. |
None
|
setting
|
str | None
|
Shorthand: the dotted Postgres setting to compare it with,
such as |
None
|
using
|
str | None
|
Raw: the |
None
|
with_check
|
str | None
|
Raw: the |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
The two forms are mixed or neither is given, a clause is one the command does not accept, or a name, command or flag has the wrong shape. |
ValueError
|
|
Examples:
from ferro import RowPolicy
tenant = RowPolicy(column="tenant_id", setting="app.tenant_id")
invitee = RowPolicy(
name="invitee_read",
command="select",
using="id IN (SELECT document_id FROM membership)",
)
assert (tenant.resolved_name, invitee.resolved_name) == ("tenant_id", "invitee_read")
-
Reference
Python API
Model
RowSecurity
-
Reference
Python API
Model
RowSecuritypolicies
-
Reference
Python API
Model
RowSecurity
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str | None
|
The policy name's suffix, or |
command |
str
|
The command the policy covers. |
restrictive |
bool
|
Whether the policy is |
column |
str | None
|
Shorthand: the column holding the scope value. |
setting |
str | None
|
Shorthand: the Postgres setting the column is compared with. |
using |
str | None
|
Raw: the |
with_check |
str | None
|
Raw: the |
resolved_name |
str
|
The policy name's suffix: |
name
class-attribute
instance-attribute
¶
name: str | None = None
The policy name's suffix, or None for the shorthand's column name.
restrictive
class-attribute
instance-attribute
¶
restrictive: bool = False
Whether the policy is AS RESTRICTIVE.
column
class-attribute
instance-attribute
¶
column: str | None = None
Shorthand: the column holding the scope value.
setting
class-attribute
instance-attribute
¶
setting: str | None = None
Shorthand: the Postgres setting the column is compared with.