You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One way to solve this issue however would be to introduce a beta-reduction that would select the then or else clause of a If AST if it sees that the value of condition is trivially true e.g. if it's Constant("foo") == Constant("foo"). That way it would be possible to use conditionals to choose one Query versus another inside of a quotation.
valq= quote {
(cond:String) =>if (cond=="foo")
query[Person].filter(_.name =="Joe")
else
query[Person]
}
// doing q("foo") reduces the AST to: query[Person].filter(_.name == "Joe")
run(q("foo"))
// SELECT p.name, p.age FROM Person p where p.name = 'Joe'
@getquill/maintainers
The text was updated successfully, but these errors were encountered:
Version: (e.g.
3.4.8
)Module: (e.g.
quill-core
)Database: (e.g.
ALL
)As is well known, using a conditional to select a query based on a runtime variable does not work for compile-time queries.
One way to solve this issue however would be to introduce a beta-reduction that would select the
then
orelse
clause of aIf
AST if it sees that the value ofcondition
is trivially true e.g. if it'sConstant("foo") == Constant("foo")
. That way it would be possible to use conditionals to choose one Query versus another inside of a quotation.@getquill/maintainers
The text was updated successfully, but these errors were encountered: