diff --git a/CHANGELOG.md b/CHANGELOG.md index 089fcc5f..cf4f7447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Fix a compilation error with migration files when CREATE UNIQUE INDEX referenced by FOREIGN KEY (https://github.com/sqldelight/sql-psi/pull/732) - Fix insert statement exposes columns to a select statement when used as the row source (https://github.com/sqldelight/sql-psi/pull/750) - Add rules ANY and ALL for dialects to use as SqlTypes (https://github.com/sqldelight/sql-psi/pull/760) +- Support keyword-colliding function names REPLACE, LEFT, RIGHT, LIKE, GLOB, IF, MATCH, REGEXP (https://github.com/sqldelight/sql-psi/pull/773) ## [0.7.3] - 2026-03-13 [0.7.3]: https://github.com/sqldelight/sql-psi/releases/tag/0.7.3 diff --git a/core/src/main/kotlin/com/alecstrong/sql/psi/core/sql.bnf b/core/src/main/kotlin/com/alecstrong/sql/psi/core/sql.bnf index ae57c448..2910f97c 100644 --- a/core/src/main/kotlin/com/alecstrong/sql/psi/core/sql.bnf +++ b/core/src/main/kotlin/com/alecstrong/sql/psi/core/sql.bnf @@ -464,7 +464,7 @@ foreign_table ::= id | string { } identifier ::= id pragma_name ::= id -function_name ::= id +function_name ::= id | REPLACE | LEFT | RIGHT | LIKE | GLOB | IF | MATCH | REGEXP string_literal ::= string table_or_index_name ::= id new_table_name ::= id | string { diff --git a/core/src/testFixtures/resources/fixtures/function-keyword-names/Test.s b/core/src/testFixtures/resources/fixtures/function-keyword-names/Test.s new file mode 100644 index 00000000..384bdc20 --- /dev/null +++ b/core/src/testFixtures/resources/fixtures/function-keyword-names/Test.s @@ -0,0 +1,27 @@ +CREATE TABLE foo ( + value TEXT +); + +SELECT REPLACE(value, 'foo', 'bar') +FROM foo; + +SELECT LEFT(value, 2) +FROM foo; + +SELECT RIGHT(value, 2) +FROM foo; + +SELECT LIKE(value, 'foo') +FROM foo; + +SELECT GLOB('*oo', value) +FROM foo; + +SELECT IF(value = 'foo', 'yes', 'no') +FROM foo; + +SELECT MATCH(value, 'foo') +FROM foo; + +SELECT REGEXP('f.o', value) +FROM foo;