Skip to content

Commit 65c5de3

Browse files
kevinburke1kyleconroy
authored andcommitted
internal: allow CTE to be used with UPDATE (#268)
Previously we only populated the CTE field if the outer query was a SELECT, but there's no reason you can't use a CTE with an UPDATE. Fixes #267.
1 parent 10e3f8d commit 65c5de3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

internal/dinosql/parser.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ func sourceTables(c core.Catalog, node nodes.Node) ([]core.Table, error) {
675675
Items: []nodes.Node{*n.Relation},
676676
}
677677
case nodes.UpdateStmt:
678+
with = n.WithClause
678679
list = nodes.List{
679680
Items: append(n.FromClause.Items, *n.Relation),
680681
}

internal/pg/errors.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package pg
22

3-
import "fmt"
3+
import (
4+
"fmt"
5+
)
46

57
type Error struct {
68
Message string

0 commit comments

Comments
 (0)