Breeze / breeze-client

Breeze for JavaScript clients
MIT License
38 stars 16 forks source link

or predicates getting mixed up #46

Closed graphicsxp closed 3 years ago

graphicsxp commented 3 years ago

I came across an odd issue with the following predicate :

image

the resulting where clause should be :

where (statusValue = 1 or statusValue = 4 or statusValue = 5) and (claimedByUserId = "the guid" or claimedByUserId = null)

Instead the query sent to the server has the following where clause :

image

The problem seems to be in adapter-uri-builder-json.ts at line let json = entityQuery.toJSONExt( { entityType: entityType, toNameOnServer: true}) as any;

I'm using breeze-client 2.0.7.

Any idea how this could be fixed? This is a rather critical issue for me.

SOME MORE INFO :

If I add a third predicate (just a binary predicate) then the query is built correctly !

Check this out; I've added a predicate requetNumber

image

and now the output query is :

image

looks like a bug to me. Can you confirm ?

steveschmitt commented 3 years ago

Very strange! I'll look into it.

graphicsxp commented 3 years ago

Indeed. For the time being I am adding a dummy predicate to all my queries to force an extra AND on the 'id' of my entity (which is never null)

predicate.push(new Predicate('id', FilterQueryOp.NotEquals, null));

that forces the query to be built correctly, but that's obviously a hack. I hope you can come up with a solution !

steveschmitt commented 3 years ago

Found the problem - the predicate attempts to simplify the "and" operation but it doesn't work when the clauses are "or" operations. Will be fixed in next release.

steveschmitt commented 3 years ago

Fixed in release 2.1.0