def parse_validated_field(fld, selectable):
    """ Converts a validated field to sqlalchemy. Field references are
    looked up in selectable """
    aggr_fn = IngredientValidator.aggregation_lookup[fld['aggregation']]

    field = find_column(selectable, fld['value'])

    for operator in fld.get('operators', []):
        op = operator['operator']
        other_field = parse_validated_field(operator['field'], selectable)
        field = IngredientValidator.operator_lookup[op](field)(other_field)

    condition = fld.get('condition', None)
    if condition:
        condition = parse_condition(condition, selectable)
        field = case([(condition, field)])

    field = aggr_fn(field)
    return field
def parse_validated_field ( fld , selectable ) : aggr_fn = IngredientValidator . aggregation_lookup [ fld [ 'aggregation' ] ] field = find_column ( selectable , fld [ 'value' ] ) for operator in fld . get ( 'operators' , [ ] ) : op = operator [ 'operator' ] other_field = parse_validated_field ( operator [ 'field' ] , selectable ) field = IngredientValidator . operator_lookup [ op ] ( field ) ( other_field ) condition = fld . get ( 'condition' , None ) if condition : condition = parse_condition ( condition , selectable ) field = case ( [ ( condition , field ) ] ) field = aggr_fn ( field ) return field
Converts a validated field to sqlalchemy. Field references are
    looked up in selectable