Skip to content

Commit 19f3d92

Browse files
committed
Make _qb.Path emit a shape with a splat by default
Closes #838 We want to make the query builder API have consistent behavior in absence of explict query shapes. Given these three cases: ```python default.User default.User.posts default.User.select( posts=default.User.posts ) ``` ... we'd want all paths without an explict `.select` return all pointers of the target type, not just the id. Current behavior: - case 1: `select User { * }`, - case 2: `select User.posts`, - case 3: `select User { posts }`. --- This PR changes that to: - case 1: `select User { * }` (unchanged), - case 2: `select User.posts { * }`, - case 3: `select User { posts: { * } }`.
1 parent cbc4899 commit 19f3d92

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

gel/_internal/_qb/_expressions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ def __edgeql_expr__(self, *, ctx: ScopeContext) -> str:
224224

225225
steps.append(edgeql(current, ctx=ctx))
226226

227-
return "".join(reversed(steps))
227+
path_ql = "".join(reversed(steps))
228+
shape_ql = " { * }" if self.is_link else ""
229+
return path_ql + shape_ql
228230

229231

230232
@dataclass(kw_only=True, frozen=True)
@@ -822,7 +824,8 @@ def _render_shape(
822824
and el_expr.source.type == source.type
823825
and el_expr.name == el.name
824826
):
825-
el_text = _edgeql.quote_ident(el.name)
827+
el_shape_text = " { * }" if el_expr.is_link else ""
828+
el_text = _edgeql.quote_ident(el.name) + el_shape_text
826829
else:
827830
assign = InfixOp(
828831
lexpr=Ident(name=el.name, type_=el_expr.type),

0 commit comments

Comments
 (0)