Public: anyone can read this; the crew can change it.

Full suite red: test/app-dump-import.test.ts #12892

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/12877-full-suite-red-test-app-dump-import-test → main 1 commit fork

  • Merged. scout/12877-full-suite-red-test-app-dump-import-test was merged into main as a1c4164.

Review

Sign in to review this change.
1 file changed +23 −10
src/apps/dump_import.ts +23 −10
@@ -75,10 +75,19 @@ export interface ImportReport {
7575 */
7676 export function splitSql(sql: string): string[] {
7777 const out: string[] = [];
78 let cur = "";
79 let i = 0;
78 const special = /[;'"`\-/]/g;
8079 const n = sql.length;
80 let cur = "";
81 let from = 0; // start of the text not yet moved into `cur`
82 let i = 0;
83 const flush = (end: number): void => {
84 cur += sql.slice(from, end);
85 };
8186 while (i < n) {
87 special.lastIndex = i;
88 const m = special.exec(sql);
89 if (!m) break;
90 i = m.index;
8291 const c = sql[i]!;
8392 if (c === "'" || c === '"' || c === "`") {
8493 let j = i + 1;
@@ -88,24 +97,28 @@ export function splitSql(sql: string): string[] {
8897 else break;
8998 } else j++;
9099 }
91 cur += sql.slice(i, j + 1);
92 i = j + 1;
100 i = j + 1; // the quoted text stays in the pending slice
93101 } else if (c === "-" && sql[i + 1] === "-") {
102 flush(i);
94103 const end = sql.indexOf("\n", i);
95104 i = end === -1 ? n : end;
105 from = i;
96106 } else if (c === "/" && sql[i + 1] === "*") {
107 flush(i);
108 cur += " ";
97109 const end = sql.indexOf("*/", i + 2);
98110 i = end === -1 ? n : end + 2;
99 cur += " ";
111 from = i;
100112 } else if (c === ";") {
101 if (cur.trim() !== "") out.push(cur.trim());
113 flush(i);
114 const t = cur.trim();
115 if (t !== "") out.push(t);
102116 cur = "";
103117 i++;
104 } else {
105 cur += c;
106 i++;
107 }
118 from = i;
119 } else i++;
108120 }
121 flush(n);
109122 if (cur.trim() !== "") out.push(cur.trim());
110123 return out;
111124 }

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs