@rex0220/kintone-sql-tools 3.73.0 → 3.74.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.
@@ -1060,7 +1060,7 @@
1060
1060
  "format": "esm"
1061
1061
  },
1062
1062
  "src/core/explainMetadata.ts": {
1063
- "bytes": 5562,
1063
+ "bytes": 6340,
1064
1064
  "imports": [
1065
1065
  {
1066
1066
  "path": "src/core/grouping.ts",
@@ -1492,7 +1492,7 @@
1492
1492
  "format": "esm"
1493
1493
  },
1494
1494
  "src/execute.ts": {
1495
- "bytes": 632385,
1495
+ "bytes": 633278,
1496
1496
  "imports": [
1497
1497
  {
1498
1498
  "path": "src/lexer/lexer.ts",
@@ -2313,7 +2313,7 @@
2313
2313
  "bytesInOutput": 412
2314
2314
  },
2315
2315
  "src/execute.ts": {
2316
- "bytesInOutput": 251805
2316
+ "bytesInOutput": 252062
2317
2317
  },
2318
2318
  "src/api/cursorLeaseManager.ts": {
2319
2319
  "bytesInOutput": 1777
@@ -2340,7 +2340,7 @@
2340
2340
  "bytesInOutput": 442
2341
2341
  }
2342
2342
  },
2343
- "bytes": 692256
2343
+ "bytes": 692513
2344
2344
  }
2345
2345
  }
2346
2346
  }
@@ -1060,7 +1060,7 @@
1060
1060
  "format": "esm"
1061
1061
  },
1062
1062
  "src/core/explainMetadata.ts": {
1063
- "bytes": 5562,
1063
+ "bytes": 6340,
1064
1064
  "imports": [
1065
1065
  {
1066
1066
  "path": "src/core/grouping.ts",
@@ -1492,7 +1492,7 @@
1492
1492
  "format": "esm"
1493
1493
  },
1494
1494
  "src/execute.ts": {
1495
- "bytes": 632385,
1495
+ "bytes": 633278,
1496
1496
  "imports": [
1497
1497
  {
1498
1498
  "path": "src/lexer/lexer.ts",
@@ -2322,7 +2322,7 @@
2322
2322
  "bytesInOutput": 412
2323
2323
  },
2324
2324
  "src/execute.ts": {
2325
- "bytesInOutput": 251805
2325
+ "bytesInOutput": 252062
2326
2326
  },
2327
2327
  "src/api/cursorLeaseManager.ts": {
2328
2328
  "bytesInOutput": 1777
@@ -2352,7 +2352,7 @@
2352
2352
  "bytesInOutput": 5769
2353
2353
  }
2354
2354
  },
2355
- "bytes": 691610
2355
+ "bytes": 691867
2356
2356
  }
2357
2357
  }
2358
2358
  }
@@ -29765,7 +29765,7 @@ var import_docsResourceBuilder = __toESM(require_docsResourceBuilder());
29765
29765
 
29766
29766
  // src/mcp/serverVersion.ts
29767
29767
  init_define_KSQL_DOCS();
29768
- var SERVER_VERSION = true ? "3.73.0" : "0.0.0-dev";
29768
+ var SERVER_VERSION = true ? "3.74.0" : "0.0.0-dev";
29769
29769
 
29770
29770
  // src/mcp/docsResources.ts
29771
29771
  function loadFromRepoDocs() {
@@ -43716,6 +43716,19 @@ function explainNeedsAppMetadata(statement) {
43716
43716
  };
43717
43717
  return visit(statement);
43718
43718
  }
43719
+ function explainNeedsNativeUpsertTargetMetadata(statement) {
43720
+ const seen = /* @__PURE__ */ new Set();
43721
+ const visit = (node) => {
43722
+ if (node === null || typeof node !== "object") return false;
43723
+ if (seen.has(node)) return false;
43724
+ seen.add(node);
43725
+ if (Array.isArray(node)) return node.some(visit);
43726
+ const item = node;
43727
+ if (item["type"] === "UPSERT" || item["type"] === "UPSERT_SELECT") return true;
43728
+ return Object.values(item).some(visit);
43729
+ };
43730
+ return visit(statement);
43731
+ }
43719
43732
 
43720
43733
  // src/api/fetchAll.ts
43721
43734
  init_define_KSQL_DOCS();
@@ -48908,6 +48921,7 @@ async function executeParsedStatement(stmt, client, options, cacheContext) {
48908
48921
  options.recursiveCteMaxDepth,
48909
48922
  options.recursiveCteMaxRows,
48910
48923
  options.recursiveCteMaxExpansions,
48924
+ options.resolveMetadata !== false,
48911
48925
  hasNativeUpsertExecutionOption(options) ? {
48912
48926
  surface: "CLI",
48913
48927
  enableNativeUpsert: nativeUpsertExecutionEnabled(options),
@@ -56855,6 +56869,10 @@ async function buildExplainWhereAnalysis(query, client, cacheContext, maxRecords
56855
56869
  return;
56856
56870
  }
56857
56871
  const typed = node;
56872
+ if (typed["type"] === "UPSERT" || typed["type"] === "UPSERT_SELECT") {
56873
+ const upsert = node;
56874
+ await getFieldsCached(upsert.appId, tracedClient, cacheContext);
56875
+ }
56858
56876
  if (typed["type"] === "SELECT") {
56859
56877
  const select = node;
56860
56878
  await validateSelectGroupingPlanning(select, tracedClient, cacheContext);
@@ -57898,21 +57916,29 @@ var explainMaterializedTables = /* @__PURE__ */ new WeakMap();
57898
57916
  function defaultRecursiveExplainContext() {
57899
57917
  return { maxRecords: 1e4, recursiveLimits: resolveRecursiveCteLimits({}) };
57900
57918
  }
57901
- async function executeExplain(stmt, client, cacheContext, maxRecords2, cursorMaxActive2, dmlMaxRows = 100, dmlMaxSubtableRows = DEFAULT_APPLY_MAX_SUBTABLE_ROWS, relativeDatePlan, recursiveCteMaxDepth2, recursiveCteMaxRows2, recursiveCteMaxExpansions2, nativeUpsertOptions = { surface: "DOCUMENT_ONLY" }) {
57919
+ async function executeExplain(stmt, client, cacheContext, maxRecords2, cursorMaxActive2, dmlMaxRows = 100, dmlMaxSubtableRows = DEFAULT_APPLY_MAX_SUBTABLE_ROWS, relativeDatePlan, recursiveCteMaxDepth2, recursiveCteMaxRows2, recursiveCteMaxExpansions2, resolveMetadata = true, nativeUpsertOptions = { surface: "DOCUMENT_ONLY" }) {
57902
57920
  const recursiveLimits = resolveRecursiveCteLimits({
57903
57921
  recursiveCteMaxDepth: recursiveCteMaxDepth2,
57904
57922
  recursiveCteMaxRows: recursiveCteMaxRows2,
57905
57923
  recursiveCteMaxExpansions: recursiveCteMaxExpansions2
57906
57924
  });
57907
57925
  const sharedPlan = relativeDatePlan ?? await resolveRelativeDateExecutionPlan(stmt.query, client, cacheContext);
57908
- const analysis = await buildExplainWhereAnalysis(
57926
+ const analysis = resolveMetadata ? await buildExplainWhereAnalysis(
57909
57927
  stmt.query,
57910
57928
  client,
57911
57929
  cacheContext,
57912
57930
  maxRecords2,
57913
57931
  sharedPlan,
57914
57932
  explainMaterializedTables.get(stmt)
57915
- );
57933
+ ) : {
57934
+ capabilities: /* @__PURE__ */ new Map(),
57935
+ orderPlans: /* @__PURE__ */ new Map(),
57936
+ plainGroupByPlans: /* @__PURE__ */ new Map(),
57937
+ fieldApps: /* @__PURE__ */ new Set(),
57938
+ processStatusApps: /* @__PURE__ */ new Set(),
57939
+ numberPrecisionApps: /* @__PURE__ */ new Set(),
57940
+ relativeDatePlan: sharedPlan
57941
+ };
57916
57942
  const fetchCollector = { sources: [] };
57917
57943
  const relativeLines = relativeDateExplainLines(sharedPlan);
57918
57944
  const planLines = sharedPlan.hasServerOnlyWhereFunction && !sharedPlan.allowed ? [...explainMetadataLines(analysis), ...relativeLines] : [
@@ -62145,7 +62171,9 @@ function createKsqlMcpTools(serverOptions, deps = {}) {
62145
62171
  const restored = restoreSqlContextError(err, normalized.sourceSql, normalized.sqlContext);
62146
62172
  throw toMcpImportError(restored, importOptions.enableImport === true);
62147
62173
  }
62148
- const needsAppMetadata = normalized.appBindingByMappedApp.size > 0 && statements.some(explainNeedsAppMetadata);
62174
+ const needsAppMetadata = normalized.appBindingByMappedApp.size > 0 && statements.some(
62175
+ (statement) => explainNeedsAppMetadata(statement) || explainNeedsNativeUpsertTargetMetadata(statement)
62176
+ );
62149
62177
  const runtime = needsAppMetadata ? await createRuntime(serverOptions, {
62150
62178
  sql: input.sql,
62151
62179
  sqlContext: normalized.sqlContext,
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rex0220/kintone-sql-tools",
3
- "version": "3.73.0",
3
+ "version": "3.74.0",
4
4
  "description": "kintone SQL plugin, CLI, and MCP tools (ksql)",
5
5
  "publishConfig": {
6
6
  "access": "public"