nene / sql-parser-cst

Parses SQL into Concrete Syntax Tree (CST)
GNU General Public License v2.0
115 stars 7 forks source link

Support for query placeholders #41

Closed vsviridov closed 7 months ago

vsviridov commented 7 months ago

I was wondering if it would be possible to add support for query placeholders (for lack of a better/proper term).

Some libraries allow use of ?, ?1, :var_name, $var_name, @var_name, etc to signify where the variable will be plugged in once a prepared query is executed.

https://github.com/WiseLibs/better-sqlite3/blob/HEAD/docs/api.md#binding-parameters as one example.

My use-case for the parser is to try to derive types of query parameters by parsing the queries and mapping those variables against the schema.

nene commented 7 months ago

Simply use the paramTypes config option.

vsviridov commented 7 months ago

Derp. I'm blind :D Thank you very much.

vsviridov commented 7 months ago

I guess I was playing with the queries in the https://nene.github.io/sql-explorer/, but because this option was not exposed via UI it kept failing... So maybe add it to the UI if you get a chance...