Closed davidAtInleague closed 1 year ago
On October 28, 2022 at 9:22:05 AM, davidAtInleague @.**@.)) wrote:
Using an orWhere to produce a predicate OR'd with an outer clause from within a when conditional produces an unexpectedly AND'd result.
grammar is mssql.
repro
// component "X" component extends="quick.models.BaseEntity" table="X" accessors=true { property name="ID" type="string" sqltype="idstamp"; } // table create table X(id uniqueidentifier); // do it a = getInstance("X") .whereID(createGUID()) .when(/someRuntimeBoolean/ true, (X) => X.orWhereID(createGUID()) ) b = getInstance("X").whereID(createGUID()) if (/someRuntimeBoolean/ true) { // workaround, use if statement b.orWhereID(createGUID()) } writedump(a.toSql()); // unexpected AND, expected OR -- select ID from X where ID = ? AND ID = ? writedump(b.toSql()) // workaround OK -- select ID from X where ID = ? OR ID = ?
— Reply to this email directly, view it on GitHub(https://github.com/coldbox-modules/quick/issues/210), or unsubscribe(https://github.com/notifications/unsubscribe-auth/AATWYXVJEH4GDIV6VJNWZWLWFPVR3ANCNFSM6AAAAAARRFSNUU). You are receiving this because you are subscribed to this thread.Message ID: @.***>
Ok, I see that this is working as intended and the solution is either the following
a = getInstance("X")
.whereID(createGUID())
.orWhere((X) => {
X.when(/*someRuntimeBoolean*/ true,
(X) => X.whereID(createGUID())
)
})
or the literal if-statement based guard. Thanks!
Using an
orWhere
to produce a predicate OR'd with an outer clause from within awhen
conditional produces an unexpectedly AND'd result.grammar is mssql.
repro
The above repro is against v4.1.3 and v5.2.7