Comparisons
The comparison types behind each filter operator, one per family of column types.
GraphQLComparison
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:
| Name | Type | Description |
|---|---|---|
_description | A class variable that stores the description of the comparison. | |
_field_node | A private attribute that stores the DTO field node. |
field_node
field_node: QueryNodeTypehas_operator
has_operator() -> boolWhether an operator of this comparison, or of a nested comparison, is set.
restricted
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:
| Name | Type | Description | Default |
|---|---|---|---|
data_type | Any | The scalar type the operators compare against. | required |
ops | tuple[ComparisonOperator, ...] | Selected GraphQL operator names (order-independent). | required |
Returns:
| Type | Description |
|---|---|
type[Self] | A strawberry input type restricted to the selected operators. |
Raises:
| Type | Description |
|---|---|
StrawchemyFieldError | If an operator is not defined for this comparison. |
to_expressions
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]ArrayComparison
contained_in
contained_in: list[T] | Nonecontains
contains: list[T] | Noneeq
eq: T | Nonefield_node
field_node: QueryNodeTypehas_operator
has_operator() -> boolWhether an operator of this comparison, or of a nested comparison, is set.
in_
in_: list[T] | Noneis_null
is_null: bool | Noneneq
neq: T | Nonenin
nin: list[T] | Noneoverlap
overlap: list[T] | Nonerestricted
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:
| Name | Type | Description | Default |
|---|---|---|---|
data_type | Any | The scalar type the operators compare against. | required |
ops | tuple[ComparisonOperator, ...] | Selected GraphQL operator names (order-independent). | required |
Returns:
| Type | Description |
|---|---|
type[Self] | A strawberry input type restricted to the selected operators. |
Raises:
| Type | Description |
|---|---|
StrawchemyFieldError | If an operator is not defined for this comparison. |
to_expressions
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]DateComparison
day
day: OrderComparison[int] | Noneeq
eq: T | Nonefield_node
field_node: QueryNodeTypegt
gt: T | Nonegte
gte: T | Nonehas_operator
has_operator() -> boolWhether an operator of this comparison, or of a nested comparison, is set.
in_
in_: list[T] | Noneis_null
is_null: bool | Noneiso_week_day
iso_week_day: OrderComparison[int] | Noneiso_year
iso_year: OrderComparison[int] | Nonelt
lt: T | Nonelte
lte: T | Nonemonth
month: OrderComparison[int] | Noneneq
neq: T | Nonenin
nin: list[T] | Nonequarter
quarter: OrderComparison[int] | Nonerestricted
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:
| Name | Type | Description | Default |
|---|---|---|---|
data_type | Any | The scalar type the operators compare against. | required |
ops | tuple[ComparisonOperator, ...] | Selected GraphQL operator names (order-independent). | required |
Returns:
| Type | Description |
|---|---|
type[Self] | A strawberry input type restricted to the selected operators. |
Raises:
| Type | Description |
|---|---|
StrawchemyFieldError | If an operator is not defined for this comparison. |
to_expressions
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]week
week: OrderComparison[int] | Noneweek_day
week_day: OrderComparison[int] | Noneyear
year: OrderComparison[int] | NoneDateTimeComparison
day
day: OrderComparison[int] | Noneeq
eq: T | Nonefield_node
field_node: QueryNodeTypegt
gt: T | Nonegte
gte: T | Nonehas_operator
has_operator() -> boolWhether an operator of this comparison, or of a nested comparison, is set.
hour
hour: OrderComparison[int] | Nonein_
in_: list[T] | Noneis_null
is_null: bool | Noneiso_week_day
iso_week_day: OrderComparison[int] | Noneiso_year
iso_year: OrderComparison[int] | Nonelt
lt: T | Nonelte
lte: T | Noneminute
minute: OrderComparison[int] | Nonemonth
month: OrderComparison[int] | Noneneq
neq: T | Nonenin
nin: list[T] | Nonequarter
quarter: OrderComparison[int] | Nonerestricted
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:
| Name | Type | Description | Default |
|---|---|---|---|
data_type | Any | The scalar type the operators compare against. | required |
ops | tuple[ComparisonOperator, ...] | Selected GraphQL operator names (order-independent). | required |
Returns:
| Type | Description |
|---|---|
type[Self] | A strawberry input type restricted to the selected operators. |
Raises:
| Type | Description |
|---|---|
StrawchemyFieldError | If an operator is not defined for this comparison. |
second
second: OrderComparison[int] | Noneto_expressions
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]week
week: OrderComparison[int] | Noneweek_day
week_day: OrderComparison[int] | Noneyear
year: OrderComparison[int] | NoneEqualityComparison
eq
eq: T | Nonefield_node
field_node: QueryNodeTypehas_operator
has_operator() -> boolWhether an operator of this comparison, or of a nested comparison, is set.
in_
in_: list[T] | Noneis_null
is_null: bool | Noneneq
neq: T | Nonenin
nin: list[T] | Nonerestricted
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:
| Name | Type | Description | Default |
|---|---|---|---|
data_type | Any | The scalar type the operators compare against. | required |
ops | tuple[ComparisonOperator, ...] | Selected GraphQL operator names (order-independent). | required |
Returns:
| Type | Description |
|---|---|
type[Self] | A strawberry input type restricted to the selected operators. |
Raises:
| Type | Description |
|---|---|
StrawchemyFieldError | If an operator is not defined for this comparison. |
to_expressions
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]OrderComparison
eq
eq: T | Nonefield_node
field_node: QueryNodeTypegt
gt: T | Nonegte
gte: T | Nonehas_operator
has_operator() -> boolWhether an operator of this comparison, or of a nested comparison, is set.
in_
in_: list[T] | Noneis_null
is_null: bool | Nonelt
lt: T | Nonelte
lte: T | Noneneq
neq: T | Nonenin
nin: list[T] | Nonerestricted
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:
| Name | Type | Description | Default |
|---|---|---|---|
data_type | Any | The scalar type the operators compare against. | required |
ops | tuple[ComparisonOperator, ...] | Selected GraphQL operator names (order-independent). | required |
Returns:
| Type | Description |
|---|---|
type[Self] | A strawberry input type restricted to the selected operators. |
Raises:
| Type | Description |
|---|---|
StrawchemyFieldError | If an operator is not defined for this comparison. |
to_expressions
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]TextComparison
contains
contains: str | Noneendswith
endswith: str | Noneeq
eq: T | Nonefield_node
field_node: QueryNodeTypegt
gt: T | Nonegte
gte: T | Nonehas_operator
has_operator() -> boolWhether an operator of this comparison, or of a nested comparison, is set.
icontains
icontains: str | Noneiendswith
iendswith: str | Noneilike
ilike: str | Nonein_
in_: list[T] | Noneinregexp
inregexp: str | Noneiregexp
iregexp: str | Noneis_null
is_null: bool | Noneistartswith
istartswith: str | Nonelike
like: str | Nonelt
lt: T | Nonelte
lte: T | Noneneq
neq: T | Nonenilike
nilike: str | Nonenin
nin: list[T] | Nonenlike
nlike: str | Nonenregexp
nregexp: str | Noneregexp
regexp: str | Nonerestricted
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:
| Name | Type | Description | Default |
|---|---|---|---|
data_type | Any | The scalar type the operators compare against. | required |
ops | tuple[ComparisonOperator, ...] | Selected GraphQL operator names (order-independent). | required |
Returns:
| Type | Description |
|---|---|
type[Self] | A strawberry input type restricted to the selected operators. |
Raises:
| Type | Description |
|---|---|
StrawchemyFieldError | If an operator is not defined for this comparison. |
startswith
startswith: str | Noneto_expressions
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]TimeComparison
eq
eq: T | Nonefield_node
field_node: QueryNodeTypegt
gt: T | Nonegte
gte: T | Nonehas_operator
has_operator() -> boolWhether an operator of this comparison, or of a nested comparison, is set.
hour
hour: OrderComparison[int] | Nonein_
in_: list[T] | Noneis_null
is_null: bool | Nonelt
lt: T | Nonelte
lte: T | Noneminute
minute: OrderComparison[int] | Noneneq
neq: T | Nonenin
nin: list[T] | Nonerestricted
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:
| Name | Type | Description | Default |
|---|---|---|---|
data_type | Any | The scalar type the operators compare against. | required |
ops | tuple[ComparisonOperator, ...] | Selected GraphQL operator names (order-independent). | required |
Returns:
| Type | Description |
|---|---|
type[Self] | A strawberry input type restricted to the selected operators. |
Raises:
| Type | Description |
|---|---|
StrawchemyFieldError | If an operator is not defined for this comparison. |
second
second: OrderComparison[int] | Noneto_expressions
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]TimeDeltaComparison
days
days: OrderComparison[float] | Noneeq
eq: T | Nonefield_node
field_node: QueryNodeTypegt
gt: T | Nonegte
gte: T | Nonehas_operator
has_operator() -> boolWhether an operator of this comparison, or of a nested comparison, is set.
hours
hours: OrderComparison[float] | Nonein_
in_: list[T] | Noneis_null
is_null: bool | Nonelt
lt: T | Nonelte
lte: T | Noneminutes
minutes: OrderComparison[float] | Noneneq
neq: T | Nonenin
nin: list[T] | Nonerestricted
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:
| Name | Type | Description | Default |
|---|---|---|---|
data_type | Any | The scalar type the operators compare against. | required |
ops | tuple[ComparisonOperator, ...] | Selected GraphQL operator names (order-independent). | required |
Returns:
| Type | Description |
|---|---|
type[Self] | A strawberry input type restricted to the selected operators. |
Raises:
| Type | Description |
|---|---|
StrawchemyFieldError | If an operator is not defined for this comparison. |
seconds
seconds: OrderComparison[float] | Noneto_expressions
to_expressions(dialect: Dialect, model_attribute: QueryableAttribute[Any] | ColumnElement[Any]) -> list[ColumnElement[bool]]