obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

`row` cannot be used as lambda variable name in DQL

Open cg505 opened this issue 9 months ago • 0 comments

Please provide a link to the documentation page and section

Describe the problem The FAQ and Expressions docs describe the use of row to access field names that otherwise can't be referenced.

It seems that this means that "row" itself is silently a reserved keyword, and you will get weird unexpected behavior if you use row as the variable name in a lambda, which can be a very natural thing to do (map(rows, (row) => row.a + row.b)). I just wasted around an hour figuring this out.

Describe the solution you'd like Specifically call out that row cannot be used as a lambda variable name in the documentation on lambdas, and preferably also in the documentation for GROUP BY and map() (or other functions that take lambdas).

(Side note: the docs for lambdas say that they can be used in reduce, but the docs for reduce say that it takes an "operand" and only "+", "-", "*", "/", "&", and "|" are valid.)

Additional context Alternative solution: allow the lambda variable name to override the definition of row, or at least throw an error when this happens.

cg505 avatar May 24 '24 13:05 cg505