Skip to content

Parser: return query/execute ... and parameters [...] fails ("Unexpected token in expression: KeywordParameters") #559

Description

@logbie

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions