ygrek / sqlgg

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

forbidden column name `uuid` #102

Closed Nymphium closed 3 years ago

Nymphium commented 3 years ago

Parser.parse_stmt rejects statements which contains uuid (, more presicely /\buuid\b/ as regexp) as column name. For example:

utop # Sqlgg.Parser.parse_stmt {|SELECT uuid FROM table|};;
Exception:
Sqlgg.Parser_utils.Error (Sqlgg.Sql_parser.MenhirBasics.Error,
 (1, 11, "uuid", " FROM table")).
utop # Sqlgg.Parser.parse_stmt {|SELECT * FROM tbl WHERE uuid = 'something' |};;
Exception:
Sqlgg.Parser_utils.Error (Sqlgg.Sql_parser.MenhirBasics.Error,
 (1, 28, "uuid", " = 'something' ")).
utop # Sqlgg.Parser.parse_stmt {|SELECT * FROM tbl WHERE name = 'uuid' |};; (* it's ok *)
- : Sqlgg.Sql.stmt =
Sqlgg.Sql.Select ...
ygrek commented 3 years ago

uuid is reserved identifier in sql, use escaping for column names (backticks in mysql).