Commit 47f544c
Fix(macros): @filter with a single non-array argument
@filter's docstring says "The first argument can be an Array or var args can
be used", the same contract @each and @reduce state. All three route their
arguments through _norm_var_arg_lambda, whose single-item branch returns a
bare expression rather than a list:
expressions = (
item.expressions if isinstance(item, (exp.Array, exp.Tuple))
else [item.this] if isinstance(item, exp.Paren)
else item # <- bare expression
)
@each and @reduce absorb that with ensure_collection(); @filter iterates it
directly, so a lone argument raises:
@each(a, x -> x + 1) -> SELECT a + 1
@reduce(a, (x, y) -> x+y) -> SELECT a
@filter(a, x -> x > 1) -> MacroEvalError: 'Column' object is not iterable
Wrap the items in ensure_collection() so @filter matches its siblings. An
explicit array was already working and is unaffected.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: chuenchen309 <48723787+chuenchen309@users.noreply.github.com>1 parent 97d60cb commit 47f544c
2 files changed
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
789 | 789 | | |
790 | 790 | | |
791 | 791 | | |
792 | | - | |
| 792 | + | |
793 | 793 | | |
794 | 794 | | |
795 | 795 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
361 | 373 | | |
362 | 374 | | |
363 | 375 | | |
| |||
0 commit comments