dql.expressions package

Module contents

Tools for parsing and handling expressions

class dql.expressions.ConstraintExpression[source]

Bases: dql.expressions.base.Expression

Base class and entry point for constraint expressions

e.g. WHERE foo = 1

build(visitor)[source]

Build string expression, using the visitor to encode values

classmethod from_clause(clause)[source]

Factory method

classmethod from_where(where)[source]

Factory method for creating the top-level expression

hash_field[source]

The field of the hash key this expression can select, if any

possible_hash_fields()[source]

Set of field names this expression could possibly be selecting for the hash key of a query.

Hash keys must be exactly specified with “hash_key = value”

possible_range_fields()[source]

Set of field names this expression could possibly be selecting for the range key of a query.

Range keys can use operations such as <, >, <=, >=, begins_with, etc.

range_field[source]

The field of the range key this expression can select, if any

class dql.expressions.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]

Build string expression, using the visitor to encode values

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.UpdateExpression(expressions)[source]

Bases: dql.expressions.base.Expression

Entry point for Update expressions

build(visitor)[source]

Build string expression, using the visitor to encode values

classmethod from_update(update)[source]

Factory for creating an Update expression

class dql.expressions.DummyVisitor(reserved_words=None)[source]

Bases: dql.expressions.visitor.Visitor

No-op visitor for testing

get_field(field)[source]

No-op

get_value(value)[source]

No-op

class dql.expressions.Visitor(reserved_words=None)[source]

Bases: object

Visitor that replaces field names and values with encoded versions

Parameters:
reserved_words : set, optional

Set of (uppercase) words that are reserved by DynamoDB. These are used when encoding field names. If None, will default to encoding all fields.

attribute_names[source]

Dict of encoded field names to original names

expression_values[source]

Dict of encoded variable names to the variables

get_field(field)[source]

Get the safe representation of a field name

For example, since ‘order’ is reserved, it would encode it as ‘#f1’

get_value(value)[source]

Replace variable names with placeholders (e.g. ‘:v1’)