Skip to content

Commit

Permalink
fix sqlserver named parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-zhengda committed Oct 23, 2024
1 parent 9117b42 commit 9246d82
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions obfuscate_and_normalize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,20 @@ multiline comment */
Size: 11,
},
},
{
input: `DELETE [discount] WHERE [description]=@1`,
expected: `DELETE discount WHERE description = @1`,
statementMetadata: StatementMetadata{
Tables: []string{"discount"},
Comments: []string{},
Commands: []string{"DELETE"},
Procedures: []string{},
Size: 11,
},
lexerOpts: []lexerOption{
WithDBMS(DBMSSQLServer),
},
},
}

obfuscator := NewObfuscator(
Expand Down
2 changes: 1 addition & 1 deletion sqllexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ func (s *Lexer) scanWhitespace() Token {
func (s *Lexer) scanOperator(lastCh rune) Token {
s.start = s.cursor
ch := s.next()
for isOperator(ch) && !(lastCh == '=' && ch == '?') {
for isOperator(ch) && !(lastCh == '=' && (ch == '?' || ch == '@')) {
// hack: we don't want to treat "=?" as an single operator
lastCh = ch
ch = s.next()
Expand Down

0 comments on commit 9246d82

Please sign in to comment.