Conversation
feat: googlesql dialect setup
* feat: googlesql columns * feat: googlesql dialect specifics * feat: dialect with and view intrinsics
* fix: rm unique constraint as its not supported by spanner * feat: googlesql serializer
* feat: googlesql sql generator * tests: google sql serialization/sql generator tests * chore: lint * feat: generate command for googlesql
| } | ||
|
|
||
| export function escapeSingleQuotesGooglesql(str: string): string { | ||
| return str.replace(/'/g, "\\'"); |
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that backslashes in the input string are also escaped. This can be done by first replacing all backslashes with double backslashes and then replacing single quotes with a backslash followed by a single quote. This approach ensures that both backslashes and single quotes are properly escaped.
| @@ -373,3 +373,3 @@ | ||
| export function escapeSingleQuotesGooglesql(str: string): string { | ||
| return str.replace(/'/g, "\\'"); | ||
| return str.replace(/\\/g, "\\\\").replace(/'/g, "\\'"); | ||
| } |
| } | ||
|
|
||
| escapeString(str: string): string { | ||
| return `'${str.replace(/'/g, "\\'")}'`; |
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that the escapeString method correctly escapes backslashes in addition to single quotes. This can be achieved by first replacing backslashes with double backslashes and then replacing single quotes with escaped single quotes. This ensures that all occurrences of these characters are properly escaped.
The best way to fix the problem without changing existing functionality is to update the escapeString method to use two replace calls: one for backslashes and one for single quotes. This approach ensures that both characters are handled correctly.
| @@ -102,3 +102,3 @@ | ||
| escapeString(str: string): string { | ||
| return `'${str.replace(/'/g, "\\'")}'`; | ||
| return `'${str.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`; | ||
| } |
No description provided.