大修改
This commit is contained in:
1 parent
a1cbc9404a
commit
e81481623c
47 files changed
+1453
-285
No files matched your search
@@ -115,7 +115,12 @@ export function parseTupleList(payload: string): SqlValue[][] {
|
||||
|
||||
/** 取出某张表全部 INSERT 行。表不存在时返回空数组。 */
|
||||
export function readTable(sql: string, table: string): SqlValue[][] {
|
||||
const re = new RegExp('INSERT INTO `' + table.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '` VALUES (.*?);\\n', 'gs');
|
||||
// 结尾同时兼容 LF 与 CRLF:Windows 上导出的 dump 是 CRLF,
|
||||
// 只写 \n 会全部匹配失败,表现为「所有表都是空数组」这种静默错误。
|
||||
const re = new RegExp(
|
||||
'INSERT INTO `' + table.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '` VALUES (.*?);(?:\\r?\\n|$)',
|
||||
'gs',
|
||||
);
|
||||
const rows: SqlValue[][] = [];
|
||||
for (const m of sql.matchAll(re)) {
|
||||
rows.push(...parseTupleList(m[1]!));
|
||||
|
||||
Reference in new issue
Block a user