Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

Closed
ktoso opened this Issue · 1 comment

2 participants

Konrad Malawski Jason Liszka
Konrad Malawski

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

Jason Liszka
Owner
Konrad Malawski ktoso referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Konrad Malawski ktoso referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Jason Liszka jliszka closed this issue from a commit
Konrad Malawski ktoso resolves #69, a blank `{}` should not be included in or queries
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?)
b979c66
Jason Liszka jliszka referenced this issue from a commit
Konrad Malawski ktoso resolves #69, a blank `{}` should not be included in or queries
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?)
ca54db9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.