persvr / rql

Resource Query Language
http://www.persvr.org/
267 stars 49 forks source link

how do i query against nested properties? #39

Open neonstalwart opened 10 years ago

neonstalwart commented 10 years ago

my first thought was to try a dot-separated path

q = new Query().eq('user.id', id);

but the only way i've found to work is to use an array of path segments

q = new Query().eq(['user', 'id'], id);

should the dot-separated path work or is the array the right way?

wshager commented 10 years ago

What about slash separated? That should be converted to an array.

neonstalwart commented 10 years ago

oh right... i had forgotten slashes was actually what i had expected should work based on reading the parser code and tests. nothing but an array of the segments works - i tried ., ,, /.

wshager commented 10 years ago

It says return "(" + slashed.replace(/\//g, ",") + ")"; so I think (user,id) should be parsed out as well. But it isn't clear that a query string is treated differently then a constructed object.

neonstalwart commented 10 years ago

parsing isn't used when constructing via Query

wshager commented 10 years ago

IMO this is an inconsistency that needs to be addressed. I think property names should be treated the same when constructing an object. So q.eq('this/is/a/path','value') should be parsed out. I don't see a reason not to.

wshager commented 10 years ago

At least it should be documented........