@rex0220/kintone-sql-tools 3.35.0 → 3.36.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/dist-cli/ksql.js +18 -12
- package/dist-engine/index.cjs +8 -8
- package/dist-engine/index.mjs +8 -8
- package/dist-engine/ksql-engine.umd.js +8 -8
- package/dist-engine/meta/bundle-baseline.json +7 -7
- package/dist-engine/meta/cjs.json +3 -3
- package/dist-engine/meta/esm.json +3 -3
- package/dist-engine/meta/umd.json +3 -3
- package/dist-mcp/ksql-mcp.js +20 -14
- package/dist-mcpb/ksql-mcp.mcpb +0 -0
- package/package.json +1 -1
package/dist-cli/ksql.js
CHANGED
|
@@ -18252,18 +18252,20 @@ function rememberSelectWhereCapability(stmt, capability) {
|
|
|
18252
18252
|
}
|
|
18253
18253
|
function isCountStarTotalCountEligible(stmt, whereCapability) {
|
|
18254
18254
|
if (whereCapability.capability !== "EXACT_PUSHDOWN") return false;
|
|
18255
|
-
|
|
18256
|
-
|
|
18257
|
-
|
|
18258
|
-
|
|
18259
|
-
|
|
18255
|
+
const countColumns = stmt.columns.filter(
|
|
18256
|
+
(column) => column.type === "AGGREGATE" && column.func === "COUNT" && !column.distinct && column.arg.type === "WILDCARD"
|
|
18257
|
+
);
|
|
18258
|
+
if (countColumns.length !== 1) return false;
|
|
18259
|
+
if (stmt.columns.some(
|
|
18260
|
+
(column) => column !== countColumns[0] && column.type !== "LITERAL_COL"
|
|
18261
|
+
)) return false;
|
|
18260
18262
|
return !stmt.distinct && normalizeGroupingSpec(stmt).type === "NONE" && stmt.having === null && stmt.joins.length === 0 && stmt.from.cteName === null && !stmt.from.subtableCode && stmt.limit === null && stmt.offset === null;
|
|
18261
18263
|
}
|
|
18262
18264
|
function isValidTotalCount(value) {
|
|
18263
18265
|
return typeof value === "string" && /^(?:0|[1-9]\d*)$/.test(value);
|
|
18264
18266
|
}
|
|
18265
18267
|
async function tryCountStarWithTotalCount(stmt, client) {
|
|
18266
|
-
const countColumn = stmt.columns
|
|
18268
|
+
const countColumn = stmt.columns.find((column) => column.type === "AGGREGATE");
|
|
18267
18269
|
if (countColumn?.type !== "AGGREGATE") return null;
|
|
18268
18270
|
const baseQuery = stmt.where === null ? "" : whereToKintone(stmt.where);
|
|
18269
18271
|
const response = await client.getRecords({
|
|
@@ -18274,11 +18276,15 @@ async function tryCountStarWithTotalCount(stmt, client) {
|
|
|
18274
18276
|
});
|
|
18275
18277
|
if (response.searchAborted) throw new SearchAbortedError();
|
|
18276
18278
|
if (!isValidTotalCount(response.totalCount)) return null;
|
|
18277
|
-
const
|
|
18279
|
+
const countKey = countColumn.alias ?? "COUNT(*)";
|
|
18280
|
+
const projected = project(
|
|
18281
|
+
[{ [countKey]: response.totalCount }],
|
|
18282
|
+
stmt.columns
|
|
18283
|
+
);
|
|
18278
18284
|
return {
|
|
18279
18285
|
type: "SELECT",
|
|
18280
|
-
rows:
|
|
18281
|
-
columns:
|
|
18286
|
+
rows: projected.rows,
|
|
18287
|
+
columns: projected.columns,
|
|
18282
18288
|
rowCount: 1,
|
|
18283
18289
|
warnings: []
|
|
18284
18290
|
};
|
|
@@ -18454,7 +18460,7 @@ async function executeUnion(stmt, client, options, cacheContext, captureColumnMe
|
|
|
18454
18460
|
captureColumnMeta,
|
|
18455
18461
|
forLibraryCapture
|
|
18456
18462
|
) : executeSelect(
|
|
18457
|
-
stmt.left,
|
|
18463
|
+
markCountTotalCountRoot(stmt.left),
|
|
18458
18464
|
client,
|
|
18459
18465
|
effectiveOptions,
|
|
18460
18466
|
cacheContext,
|
|
@@ -18463,7 +18469,7 @@ async function executeUnion(stmt, client, options, cacheContext, captureColumnMe
|
|
|
18463
18469
|
forLibraryCapture
|
|
18464
18470
|
),
|
|
18465
18471
|
executeSelect(
|
|
18466
|
-
stmt.right,
|
|
18472
|
+
markCountTotalCountRoot(stmt.right),
|
|
18467
18473
|
client,
|
|
18468
18474
|
effectiveOptions,
|
|
18469
18475
|
cacheContext,
|
|
@@ -23140,7 +23146,7 @@ function buildUnionPlan(stmt, capabilities, orderPlans, plainGroupByPlans) {
|
|
|
23140
23146
|
const lines = [];
|
|
23141
23147
|
selects.forEach((sel, i) => {
|
|
23142
23148
|
if (i > 0) lines.push("");
|
|
23143
|
-
lines.push(...buildSelectPlan(sel, `[union:${i + 1}]`, capabilities, orderPlans, plainGroupByPlans,
|
|
23149
|
+
lines.push(...buildSelectPlan(sel, `[union:${i + 1}]`, capabilities, orderPlans, plainGroupByPlans, true));
|
|
23144
23150
|
});
|
|
23145
23151
|
return lines;
|
|
23146
23152
|
}
|