Previous topic

asyncqlio.orm.inspection

Next topic

asyncqlio.backends

This Page

asyncqlio.orm.operators

Classes for operators returned from queries.

Functions

requires_bop(func) A decorator that marks a magic method as requiring another BaseOperator.

Classes

And(*ops) Represents an AND operator in a query.
AscSorter(*columns)
BaseOperator The base operator class.
BasicSetter(column, value) Represents a basic setting operation.
ColumnValueMixin(column, value) A mixin that specifies that an operator takes both a Column and a Value as arguments.
ComparisonOp(column, value) A helper class that implements easy generation of comparison-based operators.
DecrementSetter(column, value) Represents a decrement setter.
DescSorter(*columns)
Eq(column, value) Represents an equality operator.
Gt(column, value) Represents a more than operator.
Gte(column, value) Represents a more than or equals to operator.
HackyILike(column, value) A “hacky” ILIKE operator for databases that do not support it.
ILike(column, value) Represents an ILIKE operator.
In(column, value)
IncrementSetter(column, value) Represents an increment setter.
Like(column, value) Represents a LIKE operator.
Lt(column, value) Represents a less than operator.
Lte(column, value) Represents a less than or equals to operator.
NEq(column, value) Represents a non-equality operator.
OperatorResponse(sql, parameters) A storage class for the generated SQL from an operator.
Or(*ops) Represents an OR operator in a query.
Sorter(*columns) A generic sorter operator, for use in ORDER BY.
ValueSetter(column, value) Represents a value setter (col = 1).
class asyncqlio.orm.operators.OperatorResponse(sql, parameters)[source]

Bases: object

A storage class for the generated SQL from an operator.

Parameters:
  • sql (str) – The generated SQL for this operator.
  • parameters (dict) – A dict of parameters to use for this response.
asyncqlio.orm.operators.requires_bop(func)[source]

A decorator that marks a magic method as requiring another BaseOperator.

Parameters:func – The function to decorate.
Return type:Callable[[BaseOperator, BaseOperator], Any]
Returns:A function that returns NotImplemented when the class required isn’t specified.
class asyncqlio.orm.operators.BaseOperator[source]

Bases: abc.ABC

The base operator class.

generate_sql(emitter)[source]

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter (Callable[[], Tuple[str, str]]) – A callable that can be used to generate param placeholders in a query.
Return type:OperatorResponse
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.And(*ops)[source]

Bases: asyncqlio.orm.operators.BaseOperator

Represents an AND operator in a query.

This will join multiple other BaseOperator objects together.

generate_sql(emitter)[source]

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.Or(*ops)[source]

Bases: asyncqlio.orm.operators.BaseOperator

Represents an OR operator in a query.

This will join multiple other BaseOperator objects together.

generate_sql(emitter)[source]

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.Sorter(*columns)[source]

Bases: asyncqlio.orm.operators.BaseOperator

A generic sorter operator, for use in ORDER BY.

sort_order

The sort order for this row; ASC or DESC.

generate_sql(emitter)[source]

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.AscSorter(*columns)[source]

Bases: asyncqlio.orm.operators.Sorter

generate_sql(emitter)

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.DescSorter(*columns)[source]

Bases: asyncqlio.orm.operators.Sorter

generate_sql(emitter)

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.ColumnValueMixin(column, value)[source]

Bases: object

A mixin that specifies that an operator takes both a Column and a Value as arguments.

class MyOp(BaseOperator, ColumnValueMixin):
    ...

# myop is constructed MyOp(col, value)
class asyncqlio.orm.operators.BasicSetter(column, value)[source]

Bases: asyncqlio.orm.operators.BaseOperator, asyncqlio.orm.operators.ColumnValueMixin

Represents a basic setting operation. Used for bulk queries.

set_operator
Return type:str
Returns:The “setting” operator to use when generating the SQL.
generate_sql(emitter)[source]

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.ValueSetter(column, value)[source]

Bases: asyncqlio.orm.operators.BasicSetter

Represents a value setter (col = 1).

generate_sql(emitter)[source]

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.IncrementSetter(column, value)[source]

Bases: asyncqlio.orm.operators.BasicSetter

Represents an increment setter. (col = col + 1)

generate_sql(emitter)

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.DecrementSetter(column, value)[source]

Bases: asyncqlio.orm.operators.BasicSetter

Represents a decrement setter.

generate_sql(emitter)

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.In(column, value)[source]

Bases: asyncqlio.orm.operators.BaseOperator, asyncqlio.orm.operators.ColumnValueMixin

generate_sql(emitter)[source]

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter (Callable[[str], str]) – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.ComparisonOp(column, value)[source]

Bases: asyncqlio.orm.operators.ColumnValueMixin, asyncqlio.orm.operators.BaseOperator

A helper class that implements easy generation of comparison-based operators.

To customize the operator provided, set the value of operator in the class body.

generate_sql(emitter)[source]

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.Eq(column, value)[source]

Bases: asyncqlio.orm.operators.ComparisonOp

Represents an equality operator.

generate_sql(emitter)[source]

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.NEq(column, value)[source]

Bases: asyncqlio.orm.operators.ComparisonOp

Represents a non-equality operator.

generate_sql(emitter)[source]

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.Lt(column, value)[source]

Bases: asyncqlio.orm.operators.ComparisonOp

Represents a less than operator.

generate_sql(emitter)

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.Gt(column, value)[source]

Bases: asyncqlio.orm.operators.ComparisonOp

Represents a more than operator.

generate_sql(emitter)

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.Lte(column, value)[source]

Bases: asyncqlio.orm.operators.ComparisonOp

Represents a less than or equals to operator.

generate_sql(emitter)

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.Gte(column, value)[source]

Bases: asyncqlio.orm.operators.ComparisonOp

Represents a more than or equals to operator.

generate_sql(emitter)

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.Like(column, value)[source]

Bases: asyncqlio.orm.operators.ComparisonOp

Represents a LIKE operator.

generate_sql(emitter)

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.ILike(column, value)[source]

Bases: asyncqlio.orm.operators.ComparisonOp

Represents an ILIKE operator.

Warning

This operator is not natively supported on all dialects. If used on a dialect that doesn’t support it, it will fallback to a lowercase LIKE.

generate_sql(emitter)

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.

class asyncqlio.orm.operators.HackyILike(column, value)[source]

Bases: asyncqlio.orm.operators.BaseOperator, asyncqlio.orm.operators.ColumnValueMixin

A “hacky” ILIKE operator for databases that do not support it.

generate_sql(emitter)[source]

Generates the SQL for an operator.

Parameters must be generated using the emitter callable.

Parameters:emitter – A callable that can be used to generate param placeholders in a query.
Returns:A OperatorResponse representing the result.

Warning

The param name and the param can be empty if none is to be returned.