Skip to content

Commit ff52e52

Browse files
committed
added * support for update returning
1 parent bbd0934 commit ff52e52

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

sql/planbuilder/dml.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (b *Builder) buildInsert(inScope *scope, i *ast.Insert) (outScope *scope) {
150150
ins := plan.NewInsertInto(db, plan.NewInsertDestination(sch, dest), srcScope.node, isReplace, columns, onDupExprs, ignore)
151151
ins.LiteralValueSource = srcLiteralOnly
152152

153-
if i.Returning != nil {
153+
if len(i.Returning) > 0 {
154154
// TODO: read returning results from outScope instead of ins.Returning so that there is no need to return list
155155
// of expressions
156156
ins.Returning = b.analyzeSelectList(destScope, destScope, i.Returning)
@@ -581,11 +581,7 @@ func (b *Builder) buildUpdate(inScope *scope, u *ast.Update) (outScope *scope) {
581581
}
582582

583583
if len(u.Returning) > 0 {
584-
returningExprs := make([]sql.Expression, len(u.Returning))
585-
for i, selectExpr := range u.Returning {
586-
returningExprs[i] = b.selectExprToExpression(outScope, selectExpr)
587-
}
588-
update.Returning = returningExprs
584+
update.Returning = b.analyzeSelectList(outScope, outScope, u.Returning)
589585
}
590586

591587
outScope.node = update.WithChecks(checks)

0 commit comments

Comments
 (0)