ygrek / sqlgg

SQL Guided (code) Generator
https://ygrek.org/p/sqlgg/
GNU General Public License v2.0
62 stars 20 forks source link

Can't use @ in SET variable names. #59

Open cyberhuman opened 5 years ago

cyberhuman commented 5 years ago

e.g.

SET @noop = 0;

results in

==> SET @noop = 0
Position 1:9 Tokens: @noop = 0
Error: Sqlgg.Sql_parser.MenhirBasics.Error
Errors encountered, no code generated

Note that `@noop` is not the same as @noop (e.g. Mysql would complain that a system variable by that name does not exist, if backticks are used).

cyberhuman commented 5 years ago

I have just realized that we can live without noop :-) Closing this.

ygrek commented 5 years ago

It is not straightforward to fix, because while it is possible to parse such set with some hacks, but later when this var is referenced it will be confused with a parameter (because syntax is the same). I see two ways out : either keep track of all variable names defined and recover them when they are confused for parameters by lexer, or make selection of params syntax exclusive

ygrek commented 5 years ago

reopening as a reminder