canonical / sqlair

Friendly type mapping for SQL databases
Apache License 2.0
16 stars 8 forks source link

Inputs within other expressions not parsed by SQLair #146

Open Aflynn50 opened 2 months ago

Aflynn50 commented 2 months ago

SQLair does not parse input expressions nested within other parsed expressions. This can cause issues with input expressions in functions that are saved in output expressions or sub expressions that are inserted in INSERT statements.

For example, when selecting a value directly into an insert the $M.val below will not be parsed:

INSERT INTO t
    (col1, col2)
VALUES
        (&M.col1, SELECT col3 FROM s WHERE x = $M.val)

Or, when selecting a function into an output, again, the $M.val will not be parsed.

SELECT MyFunc($M.val) AS &M.out FROM t

This can be fixed by parsing these sub-expressions recursively.