coollection icon indicating copy to clipboard operation
coollection copied to clipboard

how is one supposed to chain "and" with "or"

Open buckyball opened this issue 14 years ago • 1 comments

maybe a simple question, but I cannot make it work. Example:


from(article).where( "customerNr", eq(custno) )
          .and    ("articlenumber_intern", startsWith(searchTerm))
          .or     ("articlenumber_extern", startsWith(searchTerm))
          .all()

that way, coolection will only return items that are matched by "articlenumber_intern", ignoring the "or" criteria.

Oh, btw, as you can see I added a "startsWith" critera because the contains function wasn't sufficient for me. I would like to suggest to add it in your coolection lib, as this seems to be a common requirement when working with lists.

Thanks for your wonderful little helper, coolection rocks !

buckyball avatar Sep 27 '11 13:09 buckyball

Hi,

I have similar problem using "or" matcher. I have query like this:

from(some_list).where("prop1", eq(some_val)) .or("prop2", eq(some_val)) .or("prop3", eq(some_val)) .all();

but I receive objects that match only first matcher :( Any solutions yet?

Thanks :)

mkrivacek avatar Jan 23 '12 13:01 mkrivacek