Skip to content

Commit

Permalink
Fix missing SQL output if SQL is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
erikhofer committed Nov 7, 2024
1 parent 1a7e46b commit 4d59543
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/InjectionVisualizer/lexer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

// source: https://www.regextester.com/?fam=110716
const REGEX = /(\b(?:select|from|where|group|by|order|or|and|not|exists|having|join|left|right|inner)\b)|([A-Za-z][A-Za-z0-9]*)|([0-9]+\.[0-9]*)|([0-9]+)|('[^']*')|(\s+)|(\-\-[^\n\r]*)|([+\-\*/.=\(\),;])/gmi;
const REGEX = /(\b(?:select|from|where|group|by|order|or|and|not|exists|having|join|left|right|inner)\b)|([A-Za-z][A-Za-z0-9]*)|([0-9]+\.[0-9]*)|([0-9]+)|('[^']*')|(\s+)|(\-\-[^\n\r]*)|([+\-\*/.=\(\),;])|(.)/gmi;

export type Token = {
type: 'keyword' | 'identifier' | 'operator' | 'string' | 'integer' | 'decimal' | 'comment' | 'whitespace'
type: 'keyword' | 'identifier' | 'operator' | 'string' | 'integer' | 'decimal' | 'comment' | 'whitespace' | 'unknown'
text: string
}

Expand All @@ -16,7 +16,8 @@ const TOKEN_TYPES_BY_GROUP_INDEX: Array<Token['type'] | undefined> = [
'string',
'whitespace',
'comment',
'operator'
'operator',
'unknown'
]

export function tokenize(sql: string) {
Expand Down

0 comments on commit 4d59543

Please sign in to comment.