Skip to content

Commit 045b496

Browse files
committed
Introduce database#InsertSelectStatement
1 parent 869ae6a commit 045b496

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

database/statements.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,37 @@ func (i *insertStatement) ExcludedColumns() []string {
6363
return i.excludedColumns
6464
}
6565

66+
type InsertSelectStatement interface {
67+
InsertStatement
68+
69+
SetSelect(stmt SelectStatement) InsertSelectStatement
70+
71+
Select() SelectStatement
72+
}
73+
74+
func NewInsertSelect(entity Entity) InsertSelectStatement {
75+
return &insertSelectStatement{
76+
insertStatement: insertStatement{
77+
entity: entity,
78+
},
79+
}
80+
}
81+
82+
type insertSelectStatement struct {
83+
insertStatement
84+
selectStmt SelectStatement
85+
}
86+
87+
func (i *insertSelectStatement) SetSelect(stmt SelectStatement) InsertSelectStatement {
88+
i.selectStmt = stmt
89+
90+
return i
91+
}
92+
93+
func (i *insertSelectStatement) Select() SelectStatement {
94+
return i.selectStmt
95+
}
96+
6697
type SelectStatement interface {
6798
From(table string) SelectStatement
6899

0 commit comments

Comments
 (0)