@rex0220/kintone-sql-tools 3.66.0 → 3.66.1

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
@@ -25461,9 +25461,13 @@ async function buildExplainWhereAnalysis(query, client, cacheContext, maxRecords
25461
25461
  const joinField = leftAlias === joinAlias ? join2.on.left.field : join2.on.right.field;
25462
25462
  if (!sourceAlias) continue;
25463
25463
  const sourceTable = [select.from, ...select.joins.map((candidate) => candidate.table)].find((table) => effectiveTableAlias(table) === sourceAlias);
25464
- const targetInfos = await getFieldsCached(join2.table.appId, tracedClient, cacheContext);
25465
- const targetInfo = targetInfos.find((info) => info.code === fieldCodeForTypeLookup(join2.table, joinField));
25466
- const targetMeta = targetInfo ? materializedMetaFromFieldInfo(targetInfo, join2.table.appId) : systemColumnMeta(joinField);
25464
+ let targetMeta;
25465
+ if (join2.table.cteName !== null) {
25466
+ targetMeta = explainRelations.get(join2.table.cteName)?.columnMeta?.get(joinField);
25467
+ } else {
25468
+ const targetInfo = (await getFieldsCached(join2.table.appId, tracedClient, cacheContext)).find((info) => info.code === fieldCodeForTypeLookup(join2.table, joinField));
25469
+ targetMeta = targetInfo ? materializedMetaFromFieldInfo(targetInfo, join2.table.appId) : systemColumnMeta(joinField);
25470
+ }
25467
25471
  let sourceMeta;
25468
25472
  let values;
25469
25473
  let sourceRowCount;