fix(sql): quote all IN-list values uniformly in expaste

Previously, pure numeric values (e.g. 90001543) in the IN clause were not quoted while values with leading zeros (e.g. 00040787) were, causing inconsistent quoting. Now all non-NULL values are uniformly quoted.
This commit is contained in:
gggaiitx authored and GitHub committed 2026-07-08 10:36:01 +08:00
1 parent bb959697d0
commit 6041c3f70b
2 files changed
+3 -5

No files matched your search

@@ -25,7 +25,6 @@ interface ParsedPasteValues {
explicitList: boolean;
}
const SQL_NUMBER_LITERAL_RE = /^[+-]?(?:(?:0|[1-9]\d*)(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;
const SIMPLE_SLASH_LIST_VALUE_RE = /^[A-Za-z0-9_.:-]+$/;
export function buildSqlInConditionFromPasteSource(source: string): SqlInListPasteResult {
@@ -195,6 +194,5 @@ function hasSingleWrappingParentheses(value: string): boolean {
function formatSqlLiteral(token: ParsedPasteValue): string {
if (!token.quoted && /^null$/i.test(token.value)) return "NULL";
if (!token.quoted && SQL_NUMBER_LITERAL_RE.test(token.value)) return token.value;
return `'${token.value.replace(/'/g, "''")}'`;
}