Example #1
0
 def between(value_a, value_b):
     value_a_key = f'{name}_a'
     value_b_key = f'{name}_b'
     def build(attrs):
         alias = get_safe_alias(name)
         value_a_attr = find_attr(attrs, original_name=value_a_key)
         value_b_attr = find_attr(attrs, original_name=value_b_key)
         return f'{alias} BETWEEN {value_a_attr.key} AND {value_b_attr.key}'
     return Condition(build, {
         value_a_key: value_a,
         value_b_key: value_b
     }, references=[name])
Example #2
0
 def begins_with(value):
     def build(attrs):
         a = find_attr(attrs)
         return f'begins_with({a.alias}, {a.key})'
     return Condition(build, { name: value })
Example #3
0
def cand(*conditions):
    def build(attrs):
        return ' AND '.join([f'({cond.expression(attrs)})' for cond in conditions])
    attributes = merge([cond.attributes for cond in conditions])
    references = flatten([cond.references for cond in conditions])
    return Condition(build, attributes, references=references)
Example #4
0
 def greater_than_or_equal(value):
     def build(attrs):
         a = find_attr(attrs)
         return f'{a.alias} >= {a.key}'
     return Condition(build, { name: value })
Example #5
0
 def less_than(value):
     def build(attrs):
         a = find_attr(attrs)
         return f'{a.alias} < {a.key}'
     return Condition(build, { name: value })
Example #6
0
 def equals(value):
     def build(attrs):
         a = find_attr(attrs)
         return f'{a.alias} = {a.key}'
     return Condition(build, { name: value })