Closed frank-123456 closed 4 years ago
I think you are using the if statement incorrectly -- there's no endif
. You want to include ,
in the output if attributes
is falsy? Then use this:
SELECT $attributes:{a|d.$a$}; separator=\", \"$$if(attributes)$, $endif$max(f.$period$) as last_period
Right, that was the issue.
Using the following code:
I get the error message "1:60: mismatched input ',' expecting RDELIM". I did not find any way to escape the comma in the if-true expression ", ". Neither preceding it with backslash, nor by including it in quotes, curly braces, or any combination thereof helped. Could you somehow make the comma escapable in this case? Or did I miss an obvious way to escape it?
BTW: The requested output can - in this case - better be achieved by not using a separator, but including the comma in the attributes loop, i. e, the following template does not cause the error:
"SELECT $attributes:{a|d.$a$, }$max(f.$periodId$) as last_period",
Nevertheless, there may be valid cases where a comma is needed in an if expression result.