Open greghendershott opened 7 years ago
You're right, that code should use emit-scalar-expr
instead of emit-name
. I'll push the change.
Placeholders can only stand for SQL scalar constants, not expressions or things like order directions. Abusing ScalarExpr:INJECT
is probably the best solution for now.
Longer-term, I could imagine adding more dynamic AST manipulation support and more nonterminal escapes, so you could write something like
#:order-by (SelectOrderItem:AST
,(make-SelectOrderItem (make-Ident column-name)
(if asc? 'asc 'desc)))
First, this is a fantastic library -- thanks! I only discovered it yesterday so I'm still wrapping my head around it, but the documentation is really good.
The only wall I've hit so far:
I'd like to use placeholders for
#:order-by
. (Motivation: Imagine a query that wants to reflect a user clicking column headers.)But trying to use
gives an error because the
SelectOrderItem
syntax pattern usesScalarExpr
:whereas later
emit-select-order
usesemit-name
:In addition, I'm not sure how to specify
#:asc
or#:desc
keywords for the direction, using placeholders?I tried hacking the latter instead to use
emit-scalar-expression
. This way, I can at least do something likeand "it works". Albeit using INJECT isn't ideal.
Is this pilot error? Or if there's a bug/omission, is my change a reasonable fix I should PR, or a bad hack?
Thanks!