-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
16 changed files
with
520 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { QueryFormatter } from "./base"; | ||
|
||
const CHARS_GLOBAL_REGEXP = /[\0\b\t\n\r\x1a"'\\]/g; // eslint-disable-line no-control-regex | ||
|
||
const CHARS_ESCAPE_MAP: Record<string, string> = { | ||
"\0": "\\0", | ||
"\b": "\\b", | ||
"\t": "\\t", | ||
"\n": "\\n", | ||
"\r": "\\r", | ||
"\x1a": "\\Z", | ||
'"': '\\"', | ||
"'": "\\'", | ||
"\\": "\\\\" | ||
}; | ||
// Matches: | ||
// - ' strings with \ escapes | ||
// - " strings with \ escapes | ||
// - /* */ comments | ||
// - -- comments | ||
// - ? parameters | ||
// - :: operator | ||
// - :named parameters | ||
// Captures the ? and :named parameters that are not inside strings or quotes | ||
// and special characters | ||
const tokenizer = | ||
/'(?:[^'\\]+|\\.)*'|"(?:[^"\\]+|\\.)*"|\/\*[\s\S]*\*\/|--.*|(\?)|::|:(\w+)/g; | ||
|
||
export class QueryFormatterV1 extends QueryFormatter { | ||
constructor() { | ||
super(); | ||
} | ||
get CHARS_GLOBAL_REGEXP() { | ||
return CHARS_GLOBAL_REGEXP; | ||
} | ||
get CHARS_ESCAPE_MAP() { | ||
return CHARS_ESCAPE_MAP; | ||
} | ||
get tokenizer() { | ||
return tokenizer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { QueryFormatter } from "./base"; | ||
|
||
const CHARS_GLOBAL_REGEXP = /[']/g; // eslint-disable-line no-control-regex | ||
|
||
const CHARS_ESCAPE_MAP: Record<string, string> = { | ||
"'": "''" | ||
}; | ||
// Matches: | ||
// - ' strings | ||
// - " strings | ||
// - /* */ comments | ||
// - -- comments | ||
// - ? parameters | ||
// - :: operator | ||
// - :named parameters | ||
// Captures the ? and :named parameters that are not inside strings or quotes | ||
// and quotes that need escaping | ||
const tokenizer = /'[^']*'|"[^"]*"|\/\*[\s\S]*\*\/|--.*|(\?)|::|:(\w+)/g; | ||
|
||
export class QueryFormatterV2 extends QueryFormatter { | ||
constructor() { | ||
super(); | ||
} | ||
get CHARS_GLOBAL_REGEXP() { | ||
return CHARS_GLOBAL_REGEXP; | ||
} | ||
get CHARS_ESCAPE_MAP() { | ||
return CHARS_ESCAPE_MAP; | ||
} | ||
get tokenizer() { | ||
return tokenizer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.