@@ -86,28 +86,68 @@ func (i *insertStatement) apply(opts *insertOptions) {
8686
8787// InsertSelectStatement is the interface for building INSERT SELECT statements.
8888type InsertSelectStatement interface {
89- InsertStatement
89+ // Into sets the table name for the INSERT SELECT statement.
90+ // Overrides the table name provided by the entity.
91+ Into (table string ) InsertSelectStatement
92+
93+ // SetColumns sets the columns to be inserted.
94+ SetColumns (columns ... string ) InsertSelectStatement
95+
96+ // SetExcludedColumns sets the columns to be excluded from the INSERT SELECT statement.
97+ // Excludes also columns set by SetColumns.
98+ SetExcludedColumns (columns ... string ) InsertSelectStatement
9099
91100 // SetSelect sets the SELECT statement for the INSERT SELECT statement.
92101 SetSelect (stmt SelectStatement ) InsertSelectStatement
93102
103+ // Entity returns the entity associated with the INSERT SELECT statement.
104+ Entity () Entity
105+
106+ // Table returns the table name for the INSERT SELECT statement.
107+ Table () string
108+
109+ // Columns returns the columns to be inserted.
110+ Columns () []string
111+
112+ // ExcludedColumns returns the columns to be excluded from the INSERT statement.
113+ ExcludedColumns () []string
114+
94115 // Select returns the SELECT statement for the INSERT SELECT statement.
95116 Select () SelectStatement
96117}
97118
98- // NewInsertSelect returns a new insertSelectStatement for the given entity.
99- func NewInsertSelect (entity Entity ) InsertSelectStatement {
119+ // NewInsertSelectStatement returns a new insertSelectStatement for the given entity.
120+ func NewInsertSelectStatement (entity Entity ) InsertSelectStatement {
100121 return & insertSelectStatement {
101- insertStatement : insertStatement {
102- entity : entity ,
103- },
122+ entity : entity ,
104123 }
105124}
106125
107126// insertSelectStatement is the default implementation of the InsertSelectStatement interface.
108127type insertSelectStatement struct {
109- insertStatement
110- selectStmt SelectStatement
128+ entity Entity
129+ table string
130+ columns []string
131+ excludedColumns []string
132+ selectStmt SelectStatement
133+ }
134+
135+ func (i * insertSelectStatement ) Into (table string ) InsertSelectStatement {
136+ i .table = table
137+
138+ return i
139+ }
140+
141+ func (i * insertSelectStatement ) SetColumns (columns ... string ) InsertSelectStatement {
142+ i .columns = columns
143+
144+ return i
145+ }
146+
147+ func (i * insertSelectStatement ) SetExcludedColumns (columns ... string ) InsertSelectStatement {
148+ i .excludedColumns = columns
149+
150+ return i
111151}
112152
113153func (i * insertSelectStatement ) SetSelect (stmt SelectStatement ) InsertSelectStatement {
@@ -116,6 +156,22 @@ func (i *insertSelectStatement) SetSelect(stmt SelectStatement) InsertSelectStat
116156 return i
117157}
118158
159+ func (i * insertSelectStatement ) Entity () Entity {
160+ return i .entity
161+ }
162+
163+ func (i * insertSelectStatement ) Table () string {
164+ return i .table
165+ }
166+
167+ func (i * insertSelectStatement ) Columns () []string {
168+ return i .columns
169+ }
170+
171+ func (i * insertSelectStatement ) ExcludedColumns () []string {
172+ return i .excludedColumns
173+ }
174+
119175func (i * insertSelectStatement ) Select () SelectStatement {
120176 return i .selectStmt
121177}
0 commit comments