Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to maintain keyword list #116

Open
apstndb opened this issue Sep 27, 2024 · 1 comment
Open

Need to maintain keyword list #116

apstndb opened this issue Sep 27, 2024 · 1 comment

Comments

@apstndb
Copy link
Contributor

apstndb commented Sep 27, 2024

I think the most important characteristic of "parse-unparse" is that it never changes the semantics of the query, but "parse-unparse" can break the semantics of the query.

(*ast.Ident).SQL() quote identifiers when the identifier is the keyword using QuoteSQLIdent.

$ go run ./tools/parse --mode query 'SELECT 1 AS `SELECT`'
...
--- SQL
SELECT 1 AS `SELECT`

There are bad cases.

$ go run ./tools/parse --mode query 'SELECT 1 AS `IF`'
...
--- SQL
SELECT 1 AS IF

It is not a valid query.

spanner> SELECT 1 AS IF;
ERROR: spanner: code = "InvalidArgument", desc = "Syntax error: Unexpected keyword IF [at 1:13]\\nSELECT 1 AS IF\\n            ^"

So, memefish must maintain token.Keywords in keywords.go to match with the official reserved keyword list.

It seems that the current diff is GRAPH_TABLE and IF.

--- keywords-in-go.txt  2024-09-28 00:12:47
+++ keywords.txt        2024-09-28 00:01:00
@@ -34,11 +34,13 @@
 FOR
 FROM
 FULL
+GRAPH_TABLE
 GROUP
 GROUPING
 GROUPS
 HASH
 HAVING
+IF
 IGNORE
 IN
 INNER
@apstndb
Copy link
Contributor Author

apstndb commented Sep 27, 2024

I think it it the reason to haveIfExpr.
Related: #47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant