inline-sql-toolkit 0.6.0 → 0.6.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 +8 -0
- package/dist/cli.js +19 -4
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.2 - 2026-11-11
|
|
4
|
+
|
|
5
|
+
- Fixed: ordinal replacement (`--ordinals` / `replaceOrdinals: true`) no longer miscounts a select item that holds an interpolation outside parentheses (`{dims}`, `%s`, `%(name)s`). Such an item may expand to several columns at runtime, so it is now treated like a `*` column: its ordinal and every later ordinal are kept, while ordinals before it still resolve. An interpolation inside parentheses (`SUM({col})`) remains one column. Previously `SELECT {dims}, cal_yr_mo_cd, … GROUP BY 1, 2, 3 ORDER BY 1, 2` could be rewritten to group and sort by `cal_yr_mo_cd` where the original ordinal `2` meant the second expanded column — silently changing ORDER BY ordering.
|
|
6
|
+
|
|
7
|
+
## 0.6.1 - 2026-11-06
|
|
8
|
+
|
|
9
|
+
- Security: pin the dev-only transitive `minimatch` to 11.0.1 via package overrides, resolving CVE-2026-118764 (GHSA-g3hv-75wg-m249) reported by the OSV scanner.
|
|
10
|
+
|
|
3
11
|
## 0.6.0 - 2026-11-06
|
|
4
12
|
|
|
5
13
|
- Feature: the CLI accepts directory arguments and processes every `.py` / `.mo.py` file below them recursively, in path order. Scans skip dot-prefixed directories, `node_modules`, `.venv`, and `__pycache__`, and never follow symbolic-link directories; a file named directly and also found in a directory is processed once. A directory with no Python files in it exits with code 2. Files named explicitly are still processed whatever their extension.
|
package/dist/cli.js
CHANGED
|
@@ -1448,7 +1448,7 @@ function firstItemStart(tokens, start) {
|
|
|
1448
1448
|
function normalizeName(text) {
|
|
1449
1449
|
return text.replace(/^["`]|["`]$/g, "").toLowerCase();
|
|
1450
1450
|
}
|
|
1451
|
-
function columnOf(tokens, start, end) {
|
|
1451
|
+
function columnOf(sql2, tokens, start, end) {
|
|
1452
1452
|
const visible = tokens.slice(start, end).filter((token) => !isCommentToken(token));
|
|
1453
1453
|
const first = visible[0];
|
|
1454
1454
|
const last2 = visible[visible.length - 1];
|
|
@@ -1459,10 +1459,22 @@ function columnOf(tokens, start, end) {
|
|
|
1459
1459
|
alias: void 0,
|
|
1460
1460
|
aggregate: false,
|
|
1461
1461
|
star: false,
|
|
1462
|
+
expands: false,
|
|
1462
1463
|
outputName: void 0,
|
|
1463
1464
|
names: []
|
|
1464
1465
|
};
|
|
1465
1466
|
}
|
|
1467
|
+
const expands = visible.some((token) => {
|
|
1468
|
+
if (token.depth !== first.depth) return false;
|
|
1469
|
+
if (token.text.startsWith("{")) return true;
|
|
1470
|
+
if (!/^[+\-*/%<>=!~|&^:]+$/.test(token.text)) return false;
|
|
1471
|
+
for (let offset = 0; offset < token.text.length; offset += 1) {
|
|
1472
|
+
if (token.text[offset] !== "%") continue;
|
|
1473
|
+
const next = sql2[token.start + offset + 1];
|
|
1474
|
+
if (next === "s" || next === "(") return true;
|
|
1475
|
+
}
|
|
1476
|
+
return false;
|
|
1477
|
+
});
|
|
1466
1478
|
const secondLast = visible[visible.length - 2];
|
|
1467
1479
|
const simpleColumn = visible.length % 2 === 1 && visible.every((token, i) => i % 2 === 0 ? isNameToken(token) : token.text === ".");
|
|
1468
1480
|
let alias;
|
|
@@ -1486,6 +1498,7 @@ function columnOf(tokens, start, end) {
|
|
|
1486
1498
|
alias,
|
|
1487
1499
|
aggregate,
|
|
1488
1500
|
star,
|
|
1501
|
+
expands,
|
|
1489
1502
|
outputName,
|
|
1490
1503
|
names
|
|
1491
1504
|
};
|
|
@@ -1493,7 +1506,9 @@ function columnOf(tokens, start, end) {
|
|
|
1493
1506
|
function ordinalReplacement(sql2, tokens, scope, clause, ordinal) {
|
|
1494
1507
|
const column = scope.columns[ordinal - 1];
|
|
1495
1508
|
if (column === void 0) return void 0;
|
|
1496
|
-
if (scope.columns.slice(0, ordinal).some((candidate) => candidate.star))
|
|
1509
|
+
if (scope.columns.slice(0, ordinal).some((candidate) => candidate.star || candidate.expands)) {
|
|
1510
|
+
return void 0;
|
|
1511
|
+
}
|
|
1497
1512
|
if (clause === "order" && scope.setOperand) return void 0;
|
|
1498
1513
|
const others = scope.columns.filter((candidate) => candidate !== column);
|
|
1499
1514
|
const otherNames = new Set(others.map((candidate) => candidate.outputName));
|
|
@@ -1608,12 +1623,12 @@ function replaceOrdinals(sql2) {
|
|
|
1608
1623
|
if (scope.phase === "select") {
|
|
1609
1624
|
if (isKeyword(token, "from")) {
|
|
1610
1625
|
if (scope.columnStart < index) {
|
|
1611
|
-
scope.columns.push(columnOf(tokens, scope.columnStart, index));
|
|
1626
|
+
scope.columns.push(columnOf(sql2, tokens, scope.columnStart, index));
|
|
1612
1627
|
}
|
|
1613
1628
|
scope.phase = "from";
|
|
1614
1629
|
} else if (token.text === ",") {
|
|
1615
1630
|
if (scope.columnStart < index) {
|
|
1616
|
-
scope.columns.push(columnOf(tokens, scope.columnStart, index));
|
|
1631
|
+
scope.columns.push(columnOf(sql2, tokens, scope.columnStart, index));
|
|
1617
1632
|
}
|
|
1618
1633
|
scope.columnStart = index + 1;
|
|
1619
1634
|
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/hidenobunagai/inline-sql-toolkit/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "0.6.
|
|
14
|
+
"version": "0.6.2",
|
|
15
15
|
"icon": "icon.png",
|
|
16
16
|
"type": "module",
|
|
17
17
|
"bin": {
|
|
@@ -181,6 +181,7 @@
|
|
|
181
181
|
"fast-uri": "3.1.9",
|
|
182
182
|
"glob": "14.0.3",
|
|
183
183
|
"js-yaml": "4.3.2",
|
|
184
|
+
"minimatch": "11.0.1",
|
|
184
185
|
"nanoid": "3.3.18",
|
|
185
186
|
"postcss": "8.5.23",
|
|
186
187
|
"qs": "6.16.1",
|