alonho/pql

Add support for hyphenated attributes

cjmaynar opened this issue · 2 comments

PQL should have the ability to support queries against attributes that contain a dash in the name.

Current Behavior:

> import pql
> q1 = 'fieldname=="test"'
> pql.find(q1)
>> {'fieldname': 'test'}
> q2 = 'field-name=="test"'
> pql.find(q2)
>> ParseError: Unsupported syntax (BinOp). options: ['Attribute', 'Name']

Expected Behavior:

> import pql
> q1 = 'fieldname=="test"'
> pql.find(q1)
>> {'fieldname': 'test'}
> q2 = 'field-name=="test"'
> pql.find(q2)
>> {'field-name': 'test'}

The solution isn't ideal but it works: wrap the hyphenated field in a string: "field-name" == "test"
In the future I'll implement a specific parser for pql that doesn't rely on the python syntax and it will support hyphenated fields.

I also uploaded a version to pypi: 0.4.2