Ensure DML result shape is compiled as output if top-level
The result shape of top-level DML statements (`INSERT` et al),
although not explicit, must still be compiled the same way a
top-level `SELECT` shape is.
@@ -294,12 +294,16 @@ def compile_InsertQuery(
ctx=ctx,
)
+ with ictx.new() as resultctx:
+ if ictx.stmt is ctx.toplevel_stmt:
+ resultctx.expr_exposed = True
+
stmt.result = compile_query_subject(
result,
view_scls=ctx.view_scls,
view_name=ctx.toplevel_result_view_name,
compile_views=ictx.stmt is ictx.toplevel_stmt,
- ctx=ictx,
+ ctx=resultctx,
)
result = fini_stmt(stmt, expr, ctx=ictx, parent_ctx=ctx)
@@ -358,12 +362,16 @@ def compile_UpdateQuery(
ctx=ctx,
)
+ with ictx.new() as resultctx:
+ if ictx.stmt is ctx.toplevel_stmt:
+ resultctx.expr_exposed = True
+
stmt.result = compile_query_subject(
result,
view_scls=ctx.view_scls,
view_name=ctx.toplevel_result_view_name,
compile_views=ictx.stmt is ictx.toplevel_stmt,
- ctx=ictx,
+ ctx=resultctx,
)
result = fini_stmt(stmt, expr, ctx=ictx, parent_ctx=ctx)
@@ -445,12 +453,16 @@ def compile_DeleteQuery(
ctx=ctx,
)
+ with ictx.new() as resultctx:
+ if ictx.stmt is ctx.toplevel_stmt:
+ resultctx.expr_exposed = True
+
stmt.result = compile_query_subject(
result,
view_scls=ctx.view_scls,
view_name=ctx.toplevel_result_view_name,
compile_views=ictx.stmt is ictx.toplevel_stmt,
- ctx=ictx,
+ ctx=resultctx,
)
result = fini_stmt(stmt, expr, ctx=ictx, parent_ctx=ctx)
