adriank / ObjectPath

The agile query language for semi-structured data
http://objectpath.org
MIT License
380 stars 93 forks source link

in operator confusing behavior #41

Closed alecxe closed 8 years ago

alecxe commented 8 years ago

May be it is just me not understanding something obvious, but why this cannot find a substring in string:

>>> import objectpath
>>> tree = objectpath.Tree({'doc': {'title': 'Purple is Best Color'}})
>>> list(tree.execute('$..*["Purple" in @.title]'))
[]

But, explicitly converting the substring to string with str() works:

>>> list(tree.execute('$..*[str("Purple") in @.title]'))
[{'title': 'Purple is Best Color'}]

Is this a bug or an intended behavior? Thanks!

SO post for the reference: http://stackoverflow.com/questions/34820888/objectpath-trouble-with-in-operator

adriank commented 8 years ago

A bug. It's fixed now, but it may break rare queries. If you encounter anything that I've broken by this hotfix let me know! The fix is available through github (git clone https://github.com/adriank/ObjectPath.git).

If you have any other questions re ObjectPath, let me know!

Greetings, Adrian Kalbarczyk

http://kalbarczyk.co/ http://about.me/akalbarczyk

On Mon, Jan 18, 2016 at 4:55 PM, Alexander Afanasyev < notifications@github.com> wrote:

May be it is just me not understanding something obvious, but why this cannot find a substring in string:

import objectpath tree = objectpath.Tree({'doc': {'title': 'Purple is Best Color'}}) list(tree.execute('$..*["Purple" in @.title]')) []

But, explicitly converting the substring to string with str() works:

list(tree.execute('$..*[str("Purple") in @.title]')) [{'title': 'Purple is Best Color'}]

Is this a bug or an intended behavior? Thanks!

— Reply to this email directly or view it on GitHub https://github.com/adriank/ObjectPath/issues/41.