Op.build can't chain?
Like this codes:
it can update.
return Op.build { Members.id greaterEq 0 }.let {
var o = it
if (query.id != null) {
o = o.and {
Members.id eq query.id
}
}
o
}
but, it can't be updated.
return Op.build { Members.id greaterEq 0 }.let {
var o = it
if (query.id != null) {
o.and {
Members.id eq query.id
}
}
o
}
Condition is True in above codes. But return value is different. Why?
And Apply not be useful.
o.and { Members.id eq query.id } - return new object
val other = o.and { Members.id eq query.id }
println(other == o)
println(o)
println(other)
As detailed above, the operator and() (as well as or() and both their variants) returns a new Op<Boolean> object.
It does not mutate the object that invokes it.
Apologies if your use case is not relevant to this suggestion, but if you are interested in mutating, for example, an existing Query, then andWhere() could be an option. Something like this:
val ogQuery = Members.select { Members.id greaterEq 0 }
query.id?.let {
ogQuery.andWhere { Members.id eq it }
}
Please consider reopening this issue on YouTrack if the problem requires more answers.