dql.expressions.selection module

Selection expressions

class dql.expressions.selection.AttributeSelection(expr1, op=None, expr2=None)[source]

Bases: dql.expressions.base.Expression

A tree of select expressions

build(visitor)[source]
evaluate(item)[source]

Evaluate this expression for a partiular item

classmethod from_statement(statement)[source]

Factory for creating a Attribute expression

class dql.expressions.selection.NamedExpression(expr, alias=None)[source]

Bases: dql.expressions.base.Expression

Wrapper around AttributeSelection that holds the alias (if any)

build(visitor)[source]
classmethod from_statement(statement)[source]

Parse the selection expression and alias from a statement

key[source]

The name that this will occupy in the final result dict

populate(item, ret, sanitize)[source]

Evaluate the child expression and put result into return value

class dql.expressions.selection.NowFunction(utc)[source]

Bases: dql.expressions.selection.SelectFunction

Function to grab the current time

build(visitor)[source]
evaluate(item)[source]
classmethod from_statement(statement)[source]
class dql.expressions.selection.SelectFunction[source]

Bases: dql.expressions.base.Expression

Base class for special select functions

evaluate(item)[source]

Evaluate this expression for a partiular item

classmethod from_statement(statement)[source]

Create a selection function from a statement

class dql.expressions.selection.SelectionExpression(expressions, is_count=False)[source]

Bases: dql.expressions.base.Expression

Entry point for Selection expressions

all_fields[source]

A set of all fields that are required by this statement

all_keys[source]

The keys, in order, that are selected by the statement

build(visitor)[source]
convert(item, sanitize=False)[source]

Convert an item into an OrderedDict with the selected fields

classmethod from_selection(selection)[source]

Factory for creating a Selection expression

class dql.expressions.selection.TimestampFunction(expr, utc)[source]

Bases: dql.expressions.selection.SelectFunction

Function that parses a field or literal as a datetime

build(visitor)[source]
evaluate(item)[source]
classmethod from_statement(statement)[source]
dql.expressions.selection.add(a, b)[source]

Add two values, ignoring None

dql.expressions.selection.div(a, b)[source]

Divide two values, ignoring None

dql.expressions.selection.mul(a, b)[source]

Multiply two values, ignoring None

dql.expressions.selection.parse_expression(clause)[source]

For a clause that could be a field, value, or expression

dql.expressions.selection.sub(a, b)[source]

Subtract two values, ignoring None