feat: add returning to mysql

This commit is contained in:
Christian Groschupp 2025-11-13 16:57:58 +01:00
parent 0585cd1949
commit b2b1a59a45
5 changed files with 42 additions and 6 deletions

View file

@ -19,6 +19,8 @@ type InsertStatement interface {
ON_DUPLICATE_KEY_UPDATE(assigments ...ColumnAssigment) InsertStatement
QUERY(selectStatement SelectStatement) InsertStatement
RETURNING(projections ...Projection) InsertStatement
}
func newInsertStatement(table Table, columns []jet.Column) InsertStatement {
@ -27,6 +29,7 @@ func newInsertStatement(table Table, columns []jet.Column) InsertStatement {
&newInsert.Insert,
&newInsert.ValuesQuery,
&newInsert.OnDuplicateKey,
&newInsert.Returning,
)
newInsert.Insert.Table = table
@ -40,6 +43,7 @@ type insertStatementImpl struct {
Insert jet.ClauseInsert
ValuesQuery jet.ClauseValuesQuery
Returning jet.ClauseReturning
OnDuplicateKey onDuplicateKeyUpdateClause
}
@ -63,6 +67,11 @@ func (is *insertStatementImpl) MODELS(data interface{}) InsertStatement {
return is
}
func (i *insertStatementImpl) RETURNING(projections ...jet.Projection) InsertStatement {
i.Returning.ProjectionList = projections
return i
}
func (is *insertStatementImpl) AS_NEW() InsertStatement {
is.ValuesQuery.As = "new"
return is