Summary
A parameterized database query/execute can be used as the value of a store, but not directly after return — the and parameters [...] clause fails to parse in return position. return query ... without parameters parses fine, so it's specifically the and parameters clause.
Environment
- WFL
26.7.4, Linux release build
Reproduction
store db_url as "sqlite::memory:"
open database at db_url as db
store ig as execute db with "CREATE TABLE t (id INT, n INT)"
store ig2 as execute db with "INSERT INTO t (id, n) VALUES (1, 5)"
define action called get_n with parameters conn and id:
return query conn with "SELECT n FROM t WHERE id = ?" and parameters [id]
end action
store rows as call get_n with db and 1
display rows[0]["n"]
Result:
error[ERROR]: Parse error: Unexpected token in expression: KeywordParameters
What works
- Without parameters, return is fine:
return query conn with "SELECT n FROM t" // parses OK
- Storing first, then returning, works (this is the workaround):
store rows as query conn with "SELECT n FROM t WHERE id = ?" and parameters [id]
return rows
store x as query ... and parameters [...] works everywhere else.
So the and parameters [...] suffix is handled when the query expression is the RHS of a store, but the return-value expression parser stops before it.
Expected
return query ... and parameters [...] (and return execute ... and parameters [...]) should parse the same as the store form — returning a parameterized query/execute result directly from an action is natural, especially for small data-access helpers like db_rows_for(id).
Impact
Minor — the store-then-return workaround is trivial. Reporting because a one-line data-access action is a common shape and the asymmetry with store is surprising.
Summary
A parameterized database
query/executecan be used as the value of astore, but not directly afterreturn— theand parameters [...]clause fails to parse in return position.return query ...without parameters parses fine, so it's specifically theand parametersclause.Environment
26.7.4, Linux release buildReproduction
Result:
What works
store x as query ... and parameters [...]works everywhere else.So the
and parameters [...]suffix is handled when the query expression is the RHS of astore, but thereturn-value expression parser stops before it.Expected
return query ... and parameters [...](andreturn execute ... and parameters [...]) should parse the same as thestoreform — returning a parameterized query/execute result directly from an action is natural, especially for small data-access helpers likedb_rows_for(id).Impact
Minor — the store-then-return workaround is trivial. Reporting because a one-line data-access action is a common shape and the asymmetry with
storeis surprising.