@rex0220/kintone-sql-tools 3.26.0 → 3.27.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 CHANGED
@@ -10453,6 +10453,28 @@ function validateDeclaredBatchVariables(statements, input) {
10453
10453
  return normalized;
10454
10454
  }
10455
10455
 
10456
+ // src/core/outerJoinSearchAbortGuard.ts
10457
+ function isOuterJoinSelect(value) {
10458
+ if (value["type"] !== "SELECT" || !Array.isArray(value["joins"])) return false;
10459
+ return value["joins"].some((join2) => {
10460
+ if (join2 === null || typeof join2 !== "object") return false;
10461
+ const type = join2["type"];
10462
+ return type === "LEFT" || type === "RIGHT";
10463
+ });
10464
+ }
10465
+ function statementContainsOuterJoin(statement) {
10466
+ const seen = /* @__PURE__ */ new Set();
10467
+ const visit = (value) => {
10468
+ if (Array.isArray(value)) return value.some(visit);
10469
+ if (value === null || typeof value !== "object" || seen.has(value)) return false;
10470
+ seen.add(value);
10471
+ const object = value;
10472
+ if (isOuterJoinSelect(object)) return true;
10473
+ return Object.values(object).some(visit);
10474
+ };
10475
+ return visit(statement);
10476
+ }
10477
+
10456
10478
  // src/core/explainMetadata.ts
10457
10479
  function buildGroupingExplainMetadata(statement, canonicalItemCount) {
10458
10480
  const grouping = normalizeGroupingSpec(statement);
@@ -14840,7 +14862,7 @@ async function execute(sql, client, options = {}) {
14840
14862
  const guardedClient = wrapClientWithSearchAbort(
14841
14863
  countedClient,
14842
14864
  collector,
14843
- !isSelectLikeStatement(stmt)
14865
+ !isSelectLikeStatement(stmt) || statementContainsOuterJoin(stmt)
14844
14866
  );
14845
14867
  const result = await executeParsedStatement(
14846
14868
  stmt,
@@ -14959,9 +14981,14 @@ function wrapClientWithMetrics(client, metrics) {
14959
14981
  }
14960
14982
  };
14961
14983
  }
14984
+ var SEARCH_ABORT_FAIL_CLOSED = /* @__PURE__ */ Symbol("searchAbortFailClosed");
14962
14985
  function wrapClientWithSearchAbort(client, collector, failClosed) {
14986
+ if (failClosed && client[SEARCH_ABORT_FAIL_CLOSED]) {
14987
+ return client;
14988
+ }
14963
14989
  return {
14964
14990
  ...client,
14991
+ ...failClosed ? { [SEARCH_ABORT_FAIL_CLOSED]: true } : {},
14965
14992
  getRecords: async (params) => {
14966
14993
  const response = await client.getRecords(params);
14967
14994
  if (response.searchAborted) {
@@ -15446,7 +15473,7 @@ async function executeBatch(sql, client, options = {}) {
15446
15473
  const statementClient = wrapClientWithSearchAbort(
15447
15474
  countedClient,
15448
15475
  searchAbortCollector,
15449
- info.statementType !== "SELECT" && info.statementType !== "UNION" && info.statementType !== "WITH"
15476
+ info.statementType !== "SELECT" && info.statementType !== "UNION" && info.statementType !== "WITH" || statementContainsOuterJoin(statements[i])
15450
15477
  );
15451
15478
  const cursorScope = wrapClientWithCursorScope(statementClient);
15452
15479
  const outcome = await runWithDeadline(