Skip to content

Commit ebaebad

Browse files
TimelordUKclaude
andcommitted
fix: Remove REPLACE keyword to avoid conflict with REPLACE() function
The REPLACE token was conflicting with the existing REPLACE() string function, breaking the showcase_deterministic formal test. **Problem:** - Added Token::Replace as a keyword for SELECT * REPLACE - This broke `REPLACE('text', 'old', 'new')` function calls - Parser error: "Unexpected token in primary expression: Replace" **Solution:** - Keep only EXCLUDE as a keyword token - REPLACE will be handled contextually in the parser - When we implement SELECT * REPLACE, we'll check for REPLACE as an identifier in the right context, not as a keyword **Test Results:** - ✅ REPLACE() function works again - ✅ showcase_deterministic formal test passes - ✅ All 119 example tests passing **Lesson Learned:** When adding new keywords, always check if they conflict with existing function names. Use contextual parsing when needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 21014c5 commit ebaebad

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

src/sql/parser/lexer.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ pub enum Token {
5555
Partition, // PARTITION keyword for window functions
5656
By, // BY keyword (used with PARTITION BY, ORDER BY)
5757
Exclude, // EXCLUDE keyword (for SELECT * EXCLUDE)
58-
Replace, // REPLACE keyword (for SELECT * REPLACE)
58+
// Note: REPLACE is NOT a keyword - it's handled as a function name
59+
// to avoid conflicting with the REPLACE() string function
5960

6061
// Window frame keywords
6162
Rows, // ROWS frame type
@@ -154,7 +155,6 @@ impl Token {
154155
"INTO" => Some(Token::Into),
155156
"DISTINCT" => Some(Token::Distinct),
156157
"EXCLUDE" => Some(Token::Exclude),
157-
"REPLACE" => Some(Token::Replace),
158158
"CASE" => Some(Token::Case),
159159
"WHEN" => Some(Token::When),
160160
"THEN" => Some(Token::Then),
@@ -244,7 +244,6 @@ impl Token {
244244
Token::Into => Some("INTO"),
245245
Token::Distinct => Some("DISTINCT"),
246246
Token::Exclude => Some("EXCLUDE"),
247-
Token::Replace => Some("REPLACE"),
248247
Token::Case => Some("CASE"),
249248
Token::When => Some("WHEN"),
250249
Token::Then => Some("THEN"),
@@ -863,7 +862,6 @@ impl Lexer {
863862
"END" => Token::End,
864863
"DISTINCT" => Token::Distinct,
865864
"EXCLUDE" => Token::Exclude,
866-
"REPLACE" => Token::Replace,
867865
"OVER" => Token::Over,
868866
"PARTITION" => Token::Partition,
869867
"BY" => Token::By,

src/text_navigation.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ impl TextNavigator {
189189
Token::End => "END",
190190
Token::Distinct => "DISTINCT",
191191
Token::Exclude => "EXCLUDE",
192-
Token::Replace => "REPLACE",
193192
Token::Over => "OVER",
194193
Token::Partition => "PARTITION",
195194
Token::By => "BY",

0 commit comments

Comments
 (0)