Skip to content

Commit

Permalink
Fix flags on listItem bucket root step
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed May 14, 2024
1 parent 82ea7d1 commit a1a2b1f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions grafast/grafast/src/engine/LayerPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import te from "tamedevil";
import * as assert from "../assert.js";
import type { Bucket } from "../bucket.js";
import { inspect } from "../inspect.js";
import type { UnaryExecutionValue } from "../interfaces.js";
import type { ExecutionValue, UnaryExecutionValue } from "../interfaces.js";
import {
FLAG_ERROR,
FLAG_INHIBITED,
FLAG_NULL,
FORBIDDEN_BY_NULLABLE_BOUNDARY_FLAGS,
NO_FLAGS,
} from "../interfaces.js";
import { resolveType } from "../polymorphic.js";
import type {
Expand Down Expand Up @@ -519,17 +520,15 @@ export class LayerPlan<TReason extends LayerPlanReason = LayerPlanReason> {
}
const itemStepId = this.rootStep.id;
// Item steps are **NOT** unary
const itemStepIdList: any[] | null = this.rootStep._isUnary ? null : [];
let ev: ExecutionValue;
if (this.rootStep._isUnary) {
// handled later
const list = listStepStore.at(0);
store.set(
itemStepId,
unaryExecutionValue(Array.isArray(list) ? list[0] : list),
);
ev = unaryExecutionValue(Array.isArray(list) ? list[0] : list);
} else {
store.set(itemStepId, batchExecutionValue(itemStepIdList!));
ev = batchExecutionValue([]);
}
store.set(itemStepId, ev);

for (const stepId of copyStepIds) {
const ev = parentBucket.store.get(stepId)!;
Expand All @@ -556,8 +555,10 @@ export class LayerPlan<TReason extends LayerPlanReason = LayerPlanReason> {
for (let j = 0, l = list.length; j < l; j++) {
const newIndex = size++;
newIndexes.push(newIndex);
if (itemStepIdList !== null) {
itemStepIdList[newIndex] = list[j];
if (ev.isBatch) {
(ev.entries[newIndex] as any[]) = list[j];
// TODO: are these the right flags?
ev._flags[newIndex] = list[j] == null ? FLAG_NULL : NO_FLAGS;
}

polymorphicPathList[newIndex] =
Expand Down

0 comments on commit a1a2b1f

Please sign in to comment.