Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion pql/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def handle_Name(self, name):
return name.id
def handle_Attribute(self, attr):
return '{0}.{1}'.format(self.handle(attr.value), attr.attr)


class OperatorMap(object):
def resolve_field(self, node):
Expand Down Expand Up @@ -366,6 +367,16 @@ def handle_Call(self, node):
def handle_Str(self, node):
return node.s

class ConstantField(AlgebricField):
"""
Converting constants into a string
(ast parser assigns a value of "Constant" to quoted strings and constant numeric values to the right
and lef part of comparison expression(comparison operators). for handling these constants we convert this constant into a string.
adding a ConsatntField handler class which we pass in a GenericField class)
"""
def handle_Constant(self, node):
return node.s

class IntField(AlgebricField):
def handle_Num(self, node):
return node.n
Expand Down Expand Up @@ -424,6 +435,6 @@ def handle_Str(self, node):
def handle_Call(self, node):
return IdFunc().handle(node)

class GenericField(IntField, BoolField, StringField, ListField, DictField, GeoField):
class GenericField(IntField, BoolField, StringField, ListField, DictField, GeoField,ConstantField):
def handle_Call(self, node):
return GenericFunc().handle(node)