Skip to content

Fix function_name to support REPLACE#773

Open
eyupcanakman wants to merge 3 commits into
lysine-dev:masterfrom
eyupcanakman:replace-function-name
Open

Fix function_name to support REPLACE#773
eyupcanakman wants to merge 3 commits into
lysine-dev:masterfrom
eyupcanakman:replace-function-name

Conversation

@eyupcanakman

Copy link
Copy Markdown

fixes lysine-dev/sqldelight#6109

Uppercase REPLACE(...) isn't parsed as a function name because REPLACE is a keyword and function_name ::= id only accepts id. Lowercase replace(...) already works.

  • Add REPLACE as a function_name alternative
  • Add fixture test
  • Tested with SqlDelight locally

@griffio griffio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function_name ::= id | REPLACE | LEFT | RIGHT | LIKE | GLOB | IF | MATCH | REGEX

The idea was to add in all the potential dialect functions that conflict with keywords. There are not many, as listed above. Assuming it doesn't break SqlDelight. Currently I can see that this test fixture breaks https://github.com/sqldelight/sqldelight/blob/98a75c85377e16f9d4efb83b4e57c803c0f8bded/dialects/sqlite-3-24/src/testFixtures/resources/fixtures_sqlite_3_24/extension_expr/Test.s#L3

Looks like it can be fixed by changing the test to avoid using LIKE, e.g use BETWEEN, so that the function_name rule is not accessed, while preserving the purpose of the test to check that expr is expected.

@eyupcanakman

Copy link
Copy Markdown
Author

Done, added the rest of the keyword functions you listed, each with a fixture (the token is spelled REGEXP rather than REGEX). The operator and join uses of those keywords still pass.

On the sqlite-3-24 side, swapping the dangling LIKE for BETWEEN keeps the <expr> error at col 39 and the dialect tests green. I can PR that to sqldelight once this lands.

@griffio griffio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Successfully merging this pull request may close these issues.

Postgres support REPLACE function

2 participants