geddy / model

Datastore-agnostic ORM in JavaScript
265 stars 55 forks source link

When id is included in query parameters then rest of query is ignored. #85

Closed hamsterready closed 11 years ago

hamsterready commented 11 years ago

It seems like there is kind-of optimization in code which ignores other query parameters when there is "id" included in original query.

For instance query like:

geddy.model.User.first({id: x, companyId: y}, ...

may return user with companyId != y.

It seems to be here: https://github.com/mde/model/blob/master/lib/query/query.js#L289

Easy to workaround in my code (as I can query by id and then compare manually against y...) but not very intuitive and results were at least confusing ;-)

ben-ng commented 11 years ago

Yes, this does appear to be broken. Added a test in baa99ad4a15f2c6557aa42c7bde136c052473892

ben-ng commented 11 years ago

@mde does that fix look right to you?

mde commented 11 years ago

Pushed to NPM, v0.2.8.