Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query with optional where clause, in or clause, generates wrong query #69

Closed
ktoso opened this issue Nov 7, 2012 · 1 comment
Closed

Comments

@ktoso
Copy link
Contributor

ktoso commented Nov 7, 2012

Hey guys,
seems we encountered a bug in building a specific query, example bellow:

MyMeta
      .or(
        _.where(_.things in List(thing)),
        _.whereOpt(additionalThing))(_.additionalThings in List(_))
      )

Which generates such query (additionalThing = None):

... "$or": [ { "things" : { "$in" : [ "thingA"]}} , { }]},  ...

What we don't like here is the { } part in the or. We'd rather just have it left out.
This makes the query fetch the entire collection so we had to fallback to manual building of or if it's needed.

Cheers and thanks for the great lib :)
Konrad

@jliszka
Copy link
Contributor

jliszka commented Nov 7, 2012

Aha, thanks! Will fix.

Regards,
Jason

On Wed, Nov 7, 2012 at 8:09 AM, Konrad Malawski notifications@github.comwrote:

Hey guys,
seems we encountered a bug in building a specific query, example bellow:

MyMeta
.or(
.where(.things in List(thing)),
.whereOpt(additionalThing))(.additionalThings in List(_))
)

Which generates such query (additionalThing = None):

... "$or": [ { "postal_codes" : { "$in" : [ "95206"]}} , { }]}, ...

What we don't like here is the { } part in the or. We'd rather just have
it left out.
This impacts index use so we had to fallback to manual building of or if
it's needed.

Cheers and thanks for the great lib :)
Konrad


Reply to this email directly or view it on GitHubhttps://github.com//issues/69.

jliszka added a commit that referenced this issue Dec 26, 2012
Resolves #69 - in which or(where, whereOpt(None)) creates a bad query
jliszka pushed a commit that referenced this issue Jun 17, 2013
This solves an edge case when you have an or(_.where, _.whereOpt(None))
which would before leave a blank `{}` in the query string, making misbehave.

I've added `isEmpty` to `AndCondition`, please let me know if you'd
rather keep it method-less, and we can find a better place for this
method (or don't introduce one at all?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants