@saptools/cf-hana 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cli.js +2680 -2650
- package/dist/cli.js.map +1 -1
- package/dist/index.js +40 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { homedir } from "os";
|
|
|
6
6
|
import { join } from "path";
|
|
7
7
|
|
|
8
8
|
// src/config.ts
|
|
9
|
-
var CLI_VERSION = "0.5.
|
|
9
|
+
var CLI_VERSION = "0.5.2";
|
|
10
10
|
var ENV_PREFIX = "CF_HANA";
|
|
11
11
|
var DEFAULT_QUERY_TIMEOUT_MS = 6e4;
|
|
12
12
|
var DEFAULT_CONNECT_TIMEOUT_MS = 6e4;
|
|
@@ -244,7 +244,7 @@ function formatResult(result, format, compactColumn) {
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
// src/
|
|
247
|
+
// src/backup-sql-parser.ts
|
|
248
248
|
function isIdentifierChar(char) {
|
|
249
249
|
return char !== void 0 && /[A-Za-z0-9_$#]/.test(char);
|
|
250
250
|
}
|
|
@@ -586,13 +586,37 @@ function matchingCloseParenIndex(masked, openIndex) {
|
|
|
586
586
|
function isAsKeywordAt(masked, index) {
|
|
587
587
|
return masked.slice(index, index + 2).toUpperCase() === "AS" && !isIdentifierChar2(masked.charAt(index - 1)) && !isIdentifierChar2(masked.charAt(index + 2));
|
|
588
588
|
}
|
|
589
|
-
function
|
|
590
|
-
let index =
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
589
|
+
function skipCteName(sql, masked, start) {
|
|
590
|
+
let index = start;
|
|
591
|
+
while (index < sql.length) {
|
|
592
|
+
const char = sql.charAt(index);
|
|
593
|
+
if (char.trim().length === 0) {
|
|
594
594
|
index += 1;
|
|
595
|
+
continue;
|
|
596
|
+
}
|
|
597
|
+
if (char === "-" && sql.charAt(index + 1) === "-") {
|
|
598
|
+
index = skipLineComment2(sql, index);
|
|
599
|
+
continue;
|
|
595
600
|
}
|
|
601
|
+
if (char === "/" && sql.charAt(index + 1) === "*") {
|
|
602
|
+
index = skipBlockComment2(sql, index);
|
|
603
|
+
continue;
|
|
604
|
+
}
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
if (sql.charAt(index) === "'" || sql.charAt(index) === '"') {
|
|
608
|
+
return skipQuotedText2(sql, index);
|
|
609
|
+
}
|
|
610
|
+
let end = index;
|
|
611
|
+
while (end < masked.length && isIdentifierChar2(masked.charAt(end))) {
|
|
612
|
+
end += 1;
|
|
613
|
+
}
|
|
614
|
+
return end;
|
|
615
|
+
}
|
|
616
|
+
function cteListEndIndex(sql, masked, afterWith) {
|
|
617
|
+
let index = afterWith;
|
|
618
|
+
for (; ; ) {
|
|
619
|
+
index = skipCteName(sql, masked, index);
|
|
596
620
|
index = skipWhitespace(masked, index);
|
|
597
621
|
if (masked.charAt(index) === "(") {
|
|
598
622
|
const columnListEnd = matchingCloseParenIndex(masked, index);
|
|
@@ -626,7 +650,7 @@ function resolveWithStatement(sql) {
|
|
|
626
650
|
return void 0;
|
|
627
651
|
}
|
|
628
652
|
const masked = maskIgnoredSqlText(sql);
|
|
629
|
-
const trailingIndex = cteListEndIndex(masked, withIndex + "WITH".length);
|
|
653
|
+
const trailingIndex = cteListEndIndex(sql, masked, withIndex + "WITH".length);
|
|
630
654
|
if (trailingIndex === void 0) {
|
|
631
655
|
return void 0;
|
|
632
656
|
}
|
|
@@ -721,7 +745,7 @@ function assertParamArity(sql, params) {
|
|
|
721
745
|
}
|
|
722
746
|
}
|
|
723
747
|
|
|
724
|
-
// src/
|
|
748
|
+
// src/backup-planner.ts
|
|
725
749
|
var WRITE_KEYWORDS = /* @__PURE__ */ new Set([
|
|
726
750
|
"UPDATE",
|
|
727
751
|
"UPSERT",
|
|
@@ -1009,6 +1033,11 @@ function buildWriteBackupPlan(sql, params = []) {
|
|
|
1009
1033
|
const trimmed = trimStatementSql(sql);
|
|
1010
1034
|
const leading = firstKeyword(trimmed);
|
|
1011
1035
|
const withResolved = leading === "WITH" ? resolveWithStatement(trimmed) : void 0;
|
|
1036
|
+
if (leading === "WITH" && withResolved === void 0) {
|
|
1037
|
+
throw new BackupRequiredError(
|
|
1038
|
+
"WITH write refused: cannot determine the statement's real trailing keyword"
|
|
1039
|
+
);
|
|
1040
|
+
}
|
|
1012
1041
|
const keyword = withResolved?.keyword ?? leading;
|
|
1013
1042
|
if (!isWriteKeyword(keyword)) {
|
|
1014
1043
|
return void 0;
|
|
@@ -2514,7 +2543,8 @@ function inspectStatement(sql) {
|
|
|
2514
2543
|
};
|
|
2515
2544
|
}
|
|
2516
2545
|
if (kind === "unknown") {
|
|
2517
|
-
|
|
2546
|
+
const unresolvedWith = leading === "WITH" && withResolved === void 0;
|
|
2547
|
+
return { kind, destructive: keyword === "CALL" || unresolvedWith };
|
|
2518
2548
|
}
|
|
2519
2549
|
return { kind, destructive: false };
|
|
2520
2550
|
}
|