@rex0220/kintone-sql-tools 1.0.3 → 1.1.0
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/README.md +4 -1
- package/dist-cli/ksql.js +26 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ kintone アプリを SQL 風の構文で操作するツールセットです。
|
|
|
21
21
|
## npm(グローバル)
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
npm install -g kintone-sql-tools
|
|
24
|
+
npm install -g @rex0220/kintone-sql-tools
|
|
25
25
|
ksql --help
|
|
26
26
|
```
|
|
27
27
|
|
|
@@ -168,6 +168,9 @@ Options:
|
|
|
168
168
|
5. `@profile` を使った DELETE が失敗する
|
|
169
169
|
- 現在 `DELETE` の `@profile` は未対応です。
|
|
170
170
|
|
|
171
|
+
6. Windows で `ksql --help` 実行時にエディタが開いてしまう
|
|
172
|
+
- `.js` 関連付けの影響の可能性があります。`ksql.cmd --help` または `node dist-cli/ksql.js --help` で確認してください。
|
|
173
|
+
|
|
171
174
|
## 機密情報の取り扱い
|
|
172
175
|
|
|
173
176
|
- token / password は直書きせず、環境変数または `env:` 参照を推奨します。
|
package/dist-cli/ksql.js
CHANGED
|
@@ -3596,6 +3596,7 @@ function project(rows, columns, scalarCache) {
|
|
|
3596
3596
|
return { rows: projected2, columns: cols };
|
|
3597
3597
|
}
|
|
3598
3598
|
const orderedKeys = [];
|
|
3599
|
+
const defaultFieldKeys = buildDefaultFieldOutputKeys(columns);
|
|
3599
3600
|
const projected = rows.map((row, rowIdx) => {
|
|
3600
3601
|
const out = {};
|
|
3601
3602
|
for (const [colIdx, col] of columns.entries()) {
|
|
@@ -3612,7 +3613,7 @@ function project(rows, columns, scalarCache) {
|
|
|
3612
3613
|
break;
|
|
3613
3614
|
}
|
|
3614
3615
|
case "FIELD": {
|
|
3615
|
-
const key = col.alias ?? col.field;
|
|
3616
|
+
const key = col.alias ?? defaultFieldKeys.get(colIdx) ?? col.field;
|
|
3616
3617
|
out[key] = resolveFieldRef(row, col.field);
|
|
3617
3618
|
if (rowIdx === 0) orderedKeys.push(key);
|
|
3618
3619
|
break;
|
|
@@ -3667,6 +3668,30 @@ function project(rows, columns, scalarCache) {
|
|
|
3667
3668
|
});
|
|
3668
3669
|
return { rows: projected, columns: orderedKeys };
|
|
3669
3670
|
}
|
|
3671
|
+
function buildDefaultFieldOutputKeys(columns) {
|
|
3672
|
+
const qualifierCollisionCount = /* @__PURE__ */ new Map();
|
|
3673
|
+
for (const col of columns) {
|
|
3674
|
+
if (col.type !== "FIELD" || col.alias) continue;
|
|
3675
|
+
const unqualified = stripTableQualifier(col.field);
|
|
3676
|
+
qualifierCollisionCount.set(unqualified, (qualifierCollisionCount.get(unqualified) ?? 0) + 1);
|
|
3677
|
+
}
|
|
3678
|
+
const keys = /* @__PURE__ */ new Map();
|
|
3679
|
+
for (const [idx, col] of columns.entries()) {
|
|
3680
|
+
if (col.type !== "FIELD" || col.alias) continue;
|
|
3681
|
+
const unqualified = stripTableQualifier(col.field);
|
|
3682
|
+
const duplicate = (qualifierCollisionCount.get(unqualified) ?? 0) > 1;
|
|
3683
|
+
const hasTableQualifier = col.field.includes(".") && !col.field.startsWith("_p.");
|
|
3684
|
+
keys.set(idx, duplicate && hasTableQualifier ? col.field : unqualified);
|
|
3685
|
+
}
|
|
3686
|
+
return keys;
|
|
3687
|
+
}
|
|
3688
|
+
function stripTableQualifier(field) {
|
|
3689
|
+
if (field.startsWith("_p.")) return field;
|
|
3690
|
+
const dot = field.indexOf(".");
|
|
3691
|
+
if (dot <= 0) return field;
|
|
3692
|
+
const unqualified = field.slice(dot + 1);
|
|
3693
|
+
return unqualified || field;
|
|
3694
|
+
}
|
|
3670
3695
|
function stripParentShortcutColumns(row) {
|
|
3671
3696
|
const out = {};
|
|
3672
3697
|
for (const [k, v] of Object.entries(row)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rex0220/kintone-sql-tools",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "kintone SQL plugin and CLI tools (ksql)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"prepack": "npm run build:cli",
|
|
26
26
|
"start": "run-p develop upload",
|
|
27
27
|
"develop": "node build.mjs --watch",
|
|
28
|
-
"upload": "rex0220-plugin-uploader -f dist/ksql-plugin-v1.
|
|
28
|
+
"upload": "rex0220-plugin-uploader -f dist/ksql-plugin-v1.1.0.zip --watch"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"dist-cli/",
|