Skip to content

Comparisons ​

The comparison types behind each filter operator, one per family of column types.

GraphQLComparison ​

source

Base class for GraphQL comparison filters.

This class provides a foundation for creating comparison filters that can be used in GraphQL queries. It defines the basic structure and methods for comparing fields of a specific type.

Attributes:

NameTypeDescription
_descriptionA class variable that stores the description of the comparison.
_field_nodeA private attribute that stores the DTO field node.

field_node ​

python
field_node: QueryNodeType

has_operator ​

python
has_operator() -> bool

Whether an operator of this comparison, or of a nested comparison, is set.

restricted ​

python
restricted(data_type: Any, ops: tuple[ComparisonOperator, ...]) -> type[Self]

Builds (and caches) a comparison input over data_type exposing only ops.

The result is a standalone strawberry input carrying every operator attribute (unselected ones defaulted UNSET) so the query-time *Filter.to_expressions keep working, and the same __strawchemy_comparison__.filter as cls.

Parameters:

NameTypeDescriptionDefault
data_typeAnyThe scalar type the operators compare against.required
opstuple[ComparisonOperator, ...]Selected GraphQL operator names (order-independent).required

Returns:

TypeDescription
type[Self]A strawberry input type restricted to the selected operators.

Raises:

TypeDescription
StrawchemyFieldErrorIf an operator is not defined for this comparison.

to_expressions ​

python
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]

ArrayComparison ​

source

contained_in ​

python
contained_in: list[T] | None

contains ​

python
contains: list[T] | None

eq ​

python
eq: T | None

field_node ​

python
field_node: QueryNodeType

has_operator ​

python
has_operator() -> bool

Whether an operator of this comparison, or of a nested comparison, is set.

in_ ​

python
in_: list[T] | None

is_null ​

python
is_null: bool | None

neq ​

python
neq: T | None

nin ​

python
nin: list[T] | None

overlap ​

python
overlap: list[T] | None

restricted ​

python
restricted(data_type: Any, ops: tuple[ComparisonOperator, ...]) -> type[Self]

Builds (and caches) a comparison input over data_type exposing only ops.

The result is a standalone strawberry input carrying every operator attribute (unselected ones defaulted UNSET) so the query-time *Filter.to_expressions keep working, and the same __strawchemy_comparison__.filter as cls.

Parameters:

NameTypeDescriptionDefault
data_typeAnyThe scalar type the operators compare against.required
opstuple[ComparisonOperator, ...]Selected GraphQL operator names (order-independent).required

Returns:

TypeDescription
type[Self]A strawberry input type restricted to the selected operators.

Raises:

TypeDescription
StrawchemyFieldErrorIf an operator is not defined for this comparison.

to_expressions ​

python
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]

DateComparison ​

source

day ​

python
day: OrderComparison[int] | None

eq ​

python
eq: T | None

field_node ​

python
field_node: QueryNodeType

gt ​

python
gt: T | None

gte ​

python
gte: T | None

has_operator ​

python
has_operator() -> bool

Whether an operator of this comparison, or of a nested comparison, is set.

in_ ​

python
in_: list[T] | None

is_null ​

python
is_null: bool | None

iso_week_day ​

python
iso_week_day: OrderComparison[int] | None

iso_year ​

python
iso_year: OrderComparison[int] | None

lt ​

python
lt: T | None

lte ​

python
lte: T | None

month ​

python
month: OrderComparison[int] | None

neq ​

python
neq: T | None

nin ​

python
nin: list[T] | None

quarter ​

python
quarter: OrderComparison[int] | None

restricted ​

python
restricted(data_type: Any, ops: tuple[ComparisonOperator, ...]) -> type[Self]

Builds (and caches) a comparison input over data_type exposing only ops.

The result is a standalone strawberry input carrying every operator attribute (unselected ones defaulted UNSET) so the query-time *Filter.to_expressions keep working, and the same __strawchemy_comparison__.filter as cls.

Parameters:

NameTypeDescriptionDefault
data_typeAnyThe scalar type the operators compare against.required
opstuple[ComparisonOperator, ...]Selected GraphQL operator names (order-independent).required

Returns:

TypeDescription
type[Self]A strawberry input type restricted to the selected operators.

Raises:

TypeDescription
StrawchemyFieldErrorIf an operator is not defined for this comparison.

to_expressions ​

python
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]

week ​

python
week: OrderComparison[int] | None

week_day ​

python
week_day: OrderComparison[int] | None

year ​

python
year: OrderComparison[int] | None

DateTimeComparison ​

source

day ​

python
day: OrderComparison[int] | None

eq ​

python
eq: T | None

field_node ​

python
field_node: QueryNodeType

gt ​

python
gt: T | None

gte ​

python
gte: T | None

has_operator ​

python
has_operator() -> bool

Whether an operator of this comparison, or of a nested comparison, is set.

hour ​

python
hour: OrderComparison[int] | None

in_ ​

python
in_: list[T] | None

is_null ​

python
is_null: bool | None

iso_week_day ​

python
iso_week_day: OrderComparison[int] | None

iso_year ​

python
iso_year: OrderComparison[int] | None

lt ​

python
lt: T | None

lte ​

python
lte: T | None

minute ​

python
minute: OrderComparison[int] | None

month ​

python
month: OrderComparison[int] | None

neq ​

python
neq: T | None

nin ​

python
nin: list[T] | None

quarter ​

python
quarter: OrderComparison[int] | None

restricted ​

python
restricted(data_type: Any, ops: tuple[ComparisonOperator, ...]) -> type[Self]

Builds (and caches) a comparison input over data_type exposing only ops.

The result is a standalone strawberry input carrying every operator attribute (unselected ones defaulted UNSET) so the query-time *Filter.to_expressions keep working, and the same __strawchemy_comparison__.filter as cls.

Parameters:

NameTypeDescriptionDefault
data_typeAnyThe scalar type the operators compare against.required
opstuple[ComparisonOperator, ...]Selected GraphQL operator names (order-independent).required

Returns:

TypeDescription
type[Self]A strawberry input type restricted to the selected operators.

Raises:

TypeDescription
StrawchemyFieldErrorIf an operator is not defined for this comparison.

second ​

python
second: OrderComparison[int] | None

to_expressions ​

python
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]

week ​

python
week: OrderComparison[int] | None

week_day ​

python
week_day: OrderComparison[int] | None

year ​

python
year: OrderComparison[int] | None

EqualityComparison ​

source

eq ​

python
eq: T | None

field_node ​

python
field_node: QueryNodeType

has_operator ​

python
has_operator() -> bool

Whether an operator of this comparison, or of a nested comparison, is set.

in_ ​

python
in_: list[T] | None

is_null ​

python
is_null: bool | None

neq ​

python
neq: T | None

nin ​

python
nin: list[T] | None

restricted ​

python
restricted(data_type: Any, ops: tuple[ComparisonOperator, ...]) -> type[Self]

Builds (and caches) a comparison input over data_type exposing only ops.

The result is a standalone strawberry input carrying every operator attribute (unselected ones defaulted UNSET) so the query-time *Filter.to_expressions keep working, and the same __strawchemy_comparison__.filter as cls.

Parameters:

NameTypeDescriptionDefault
data_typeAnyThe scalar type the operators compare against.required
opstuple[ComparisonOperator, ...]Selected GraphQL operator names (order-independent).required

Returns:

TypeDescription
type[Self]A strawberry input type restricted to the selected operators.

Raises:

TypeDescription
StrawchemyFieldErrorIf an operator is not defined for this comparison.

to_expressions ​

python
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]

OrderComparison ​

source

eq ​

python
eq: T | None

field_node ​

python
field_node: QueryNodeType

gt ​

python
gt: T | None

gte ​

python
gte: T | None

has_operator ​

python
has_operator() -> bool

Whether an operator of this comparison, or of a nested comparison, is set.

in_ ​

python
in_: list[T] | None

is_null ​

python
is_null: bool | None

lt ​

python
lt: T | None

lte ​

python
lte: T | None

neq ​

python
neq: T | None

nin ​

python
nin: list[T] | None

restricted ​

python
restricted(data_type: Any, ops: tuple[ComparisonOperator, ...]) -> type[Self]

Builds (and caches) a comparison input over data_type exposing only ops.

The result is a standalone strawberry input carrying every operator attribute (unselected ones defaulted UNSET) so the query-time *Filter.to_expressions keep working, and the same __strawchemy_comparison__.filter as cls.

Parameters:

NameTypeDescriptionDefault
data_typeAnyThe scalar type the operators compare against.required
opstuple[ComparisonOperator, ...]Selected GraphQL operator names (order-independent).required

Returns:

TypeDescription
type[Self]A strawberry input type restricted to the selected operators.

Raises:

TypeDescription
StrawchemyFieldErrorIf an operator is not defined for this comparison.

to_expressions ​

python
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]

TextComparison ​

source

contains ​

python
contains: str | None

endswith ​

python
endswith: str | None

eq ​

python
eq: T | None

field_node ​

python
field_node: QueryNodeType

gt ​

python
gt: T | None

gte ​

python
gte: T | None

has_operator ​

python
has_operator() -> bool

Whether an operator of this comparison, or of a nested comparison, is set.

icontains ​

python
icontains: str | None

iendswith ​

python
iendswith: str | None

ilike ​

python
ilike: str | None

in_ ​

python
in_: list[T] | None

inregexp ​

python
inregexp: str | None

iregexp ​

python
iregexp: str | None

is_null ​

python
is_null: bool | None

istartswith ​

python
istartswith: str | None

like ​

python
like: str | None

lt ​

python
lt: T | None

lte ​

python
lte: T | None

neq ​

python
neq: T | None

nilike ​

python
nilike: str | None

nin ​

python
nin: list[T] | None

nlike ​

python
nlike: str | None

nregexp ​

python
nregexp: str | None

regexp ​

python
regexp: str | None

restricted ​

python
restricted(data_type: Any, ops: tuple[ComparisonOperator, ...]) -> type[Self]

Builds (and caches) a comparison input over data_type exposing only ops.

The result is a standalone strawberry input carrying every operator attribute (unselected ones defaulted UNSET) so the query-time *Filter.to_expressions keep working, and the same __strawchemy_comparison__.filter as cls.

Parameters:

NameTypeDescriptionDefault
data_typeAnyThe scalar type the operators compare against.required
opstuple[ComparisonOperator, ...]Selected GraphQL operator names (order-independent).required

Returns:

TypeDescription
type[Self]A strawberry input type restricted to the selected operators.

Raises:

TypeDescription
StrawchemyFieldErrorIf an operator is not defined for this comparison.

startswith ​

python
startswith: str | None

to_expressions ​

python
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]

TimeComparison ​

source

eq ​

python
eq: T | None

field_node ​

python
field_node: QueryNodeType

gt ​

python
gt: T | None

gte ​

python
gte: T | None

has_operator ​

python
has_operator() -> bool

Whether an operator of this comparison, or of a nested comparison, is set.

hour ​

python
hour: OrderComparison[int] | None

in_ ​

python
in_: list[T] | None

is_null ​

python
is_null: bool | None

lt ​

python
lt: T | None

lte ​

python
lte: T | None

minute ​

python
minute: OrderComparison[int] | None

neq ​

python
neq: T | None

nin ​

python
nin: list[T] | None

restricted ​

python
restricted(data_type: Any, ops: tuple[ComparisonOperator, ...]) -> type[Self]

Builds (and caches) a comparison input over data_type exposing only ops.

The result is a standalone strawberry input carrying every operator attribute (unselected ones defaulted UNSET) so the query-time *Filter.to_expressions keep working, and the same __strawchemy_comparison__.filter as cls.

Parameters:

NameTypeDescriptionDefault
data_typeAnyThe scalar type the operators compare against.required
opstuple[ComparisonOperator, ...]Selected GraphQL operator names (order-independent).required

Returns:

TypeDescription
type[Self]A strawberry input type restricted to the selected operators.

Raises:

TypeDescription
StrawchemyFieldErrorIf an operator is not defined for this comparison.

second ​

python
second: OrderComparison[int] | None

to_expressions ​

python
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]

TimeDeltaComparison ​

source

days ​

python
days: OrderComparison[float] | None

eq ​

python
eq: T | None

field_node ​

python
field_node: QueryNodeType

gt ​

python
gt: T | None

gte ​

python
gte: T | None

has_operator ​

python
has_operator() -> bool

Whether an operator of this comparison, or of a nested comparison, is set.

hours ​

python
hours: OrderComparison[float] | None

in_ ​

python
in_: list[T] | None

is_null ​

python
is_null: bool | None

lt ​

python
lt: T | None

lte ​

python
lte: T | None

minutes ​

python
minutes: OrderComparison[float] | None

neq ​

python
neq: T | None

nin ​

python
nin: list[T] | None

restricted ​

python
restricted(data_type: Any, ops: tuple[ComparisonOperator, ...]) -> type[Self]

Builds (and caches) a comparison input over data_type exposing only ops.

The result is a standalone strawberry input carrying every operator attribute (unselected ones defaulted UNSET) so the query-time *Filter.to_expressions keep working, and the same __strawchemy_comparison__.filter as cls.

Parameters:

NameTypeDescriptionDefault
data_typeAnyThe scalar type the operators compare against.required
opstuple[ComparisonOperator, ...]Selected GraphQL operator names (order-independent).required

Returns:

TypeDescription
type[Self]A strawberry input type restricted to the selected operators.

Raises:

TypeDescription
StrawchemyFieldErrorIf an operator is not defined for this comparison.

seconds ​

python
seconds: OrderComparison[float] | None

to_expressions ​

python
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]