Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the leading dot notation in inserts #5142

Merged
merged 24 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion edb/edgeql/compiler/viewgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,7 @@ def _compile_qlexpr(
ptrsource: s_sources.Source,
ptr_name: sn.QualName,
is_linkprop: bool,
should_set_partial_prefix: bool,
s_ctx: ShapeContext,
ctx: context.ContextLevel,
) -> Tuple[irast.Set, context.ViewRPtr]:
Expand All @@ -1268,7 +1269,9 @@ def _compile_qlexpr(
source_set = setgen.fixup_computable_source_set(
ir_source, ctx=shape_expr_ctx
)
shape_expr_ctx.partial_path_prefix = source_set

if should_set_partial_prefix:
shape_expr_ctx.partial_path_prefix = source_set

if s_ctx.exprtype.is_mutation() and ptrcls is not None:
shape_expr_ctx.expr_exposed = context.Exposure.EXPOSED
Expand Down Expand Up @@ -1438,6 +1441,7 @@ def _normalize_view_ptr_expr(
ptrsource=ptrsource,
ptr_name=ptr_name,
is_linkprop=is_linkprop,
should_set_partial_prefix=True,
s_ctx=s_ctx,
ctx=ctx,
)
Expand Down Expand Up @@ -1521,6 +1525,10 @@ def _normalize_view_ptr_expr(
ptrsource=ptrsource,
ptr_name=ptr_name,
is_linkprop=is_linkprop,
# do not set partial path prefix if in the insert
# shape but not in defaults
should_set_partial_prefix=(
not s_ctx.exprtype.is_insert() or from_default),
s_ctx=s_ctx,
ctx=ctx,
)
Expand Down
9 changes: 9 additions & 0 deletions tests/test_edgeql_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ async def test_edgeql_insert_fail_5(self):
INSERT Person.notes { name := "note1" };
''')

async def test_edgeql_insert_fail_6(self):
with self.assertRaisesRegex(
edgedb.QueryError,
r"could not resolve partial path",
):
await self.con.execute('''
INSERT Person { name := .name };
''')

async def test_edgeql_insert_simple_01(self):
await self.con.execute(r"""
INSERT InsertTest {
Expand Down
Loading