Skip to content

Commit f34cdc9

Browse files
committed
feat: canonicalize INSERT / SELECT
1 parent 7252e40 commit f34cdc9

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

reshape.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,18 @@ func reshapeNode(n *pg_query.Node) {
389389
reshapeUpdate(v.UpdateStmt)
390390
case *pg_query.Node_DeleteStmt:
391391
reshapeDelete(v.DeleteStmt)
392+
case *pg_query.Node_InsertStmt:
393+
reshapeInsert(v.InsertStmt)
394+
}
395+
}
396+
397+
// reshapeInsert canonicalizes an INSERT ... SELECT body; VALUES is a no-op
398+
func reshapeInsert(i *pg_query.InsertStmt) {
399+
if i == nil || i.SelectStmt == nil {
400+
return
401+
}
402+
if s, ok := i.SelectStmt.Node.(*pg_query.Node_SelectStmt); ok {
403+
reshapeSelect(s.SelectStmt)
392404
}
393405
}
394406

0 commit comments

Comments
 (0)