Skip to content

Commit

Permalink
Fix query gen for dataview when link targeting object type with acces…
Browse files Browse the repository at this point in the history
…s policy shares name with computed link (#285)
  • Loading branch information
jaclarke authored Nov 9, 2023
1 parent f19ca24 commit b5d2143
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion shared/studio/tabs/dataview/state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1040,13 +1040,21 @@ export class DataInspector extends Model({
if (this.omittedLinks.has(field.name)) {
return `__count_${field.queryName} := <int64>{}`;
}
const typeUnionNames = resolveObjectTypeUnion(
this.objectType!
).map((t) => t.escapedName);
return `__count_${field.queryName} := (for g in (
group ${
field.targetHasSelectAccessPolicy && field.required
? `(
with sourceId := .id
select ${field.escapedTypename}
filter .<${field.escapedName}.id = sourceId
filter ${typeUnionNames
.map(
(name) =>
`.<${field.escapedName}[is ${name}].id = sourceId`
)
.join(" or ")}
)`
: selectName
}
Expand Down

0 comments on commit b5d2143

Please sign in to comment.