From e661b389ee771cae36a97bb32b93201deb87606e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ey=C3=BCp=20Can=20Akman?= Date: Tue, 7 Jul 2026 18:50:01 +0300 Subject: [PATCH 1/3] Fix function_name to support REPLACE --- core/src/main/kotlin/com/alecstrong/sql/psi/core/sql.bnf | 2 +- .../testFixtures/resources/fixtures/function-replace/Test.s | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 core/src/testFixtures/resources/fixtures/function-replace/Test.s 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..2f999f33 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 string_literal ::= string table_or_index_name ::= id new_table_name ::= id | string { diff --git a/core/src/testFixtures/resources/fixtures/function-replace/Test.s b/core/src/testFixtures/resources/fixtures/function-replace/Test.s new file mode 100644 index 00000000..e1b167bd --- /dev/null +++ b/core/src/testFixtures/resources/fixtures/function-replace/Test.s @@ -0,0 +1,6 @@ +CREATE TABLE foo ( + value TEXT +); + +SELECT REPLACE(value, 'foo', 'bar') +FROM foo; From cf17ebbdec97511bbd7de8a5a075af72172f0272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ey=C3=BCp=20Can=20Akman?= Date: Tue, 7 Jul 2026 20:33:23 +0300 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 089fcc5f..9f8ec6c7 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 REPLACE as a function name (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 From 995d13877f0d5cf83d2a0dbb563a8e5bc9a2b51a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ey=C3=BCp=20Can=20Akman?= Date: Thu, 9 Jul 2026 21:54:07 +0300 Subject: [PATCH 3/3] Extend function_name to the other keyword-colliding function names --- CHANGELOG.md | 2 +- .../com/alecstrong/sql/psi/core/sql.bnf | 2 +- .../fixtures/function-keyword-names/Test.s | 27 +++++++++++++++++++ .../fixtures/function-replace/Test.s | 6 ----- 4 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 core/src/testFixtures/resources/fixtures/function-keyword-names/Test.s delete mode 100644 core/src/testFixtures/resources/fixtures/function-replace/Test.s diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f8ec6c7..cf4f7447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +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 REPLACE as a function name (https://github.com/sqldelight/sql-psi/pull/773) +- 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 2f999f33..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 | REPLACE +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; diff --git a/core/src/testFixtures/resources/fixtures/function-replace/Test.s b/core/src/testFixtures/resources/fixtures/function-replace/Test.s deleted file mode 100644 index e1b167bd..00000000 --- a/core/src/testFixtures/resources/fixtures/function-replace/Test.s +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE foo ( - value TEXT -); - -SELECT REPLACE(value, 'foo', 'bar') -FROM foo;