diff --git a/go.sum b/go.sum index fb4240eb4..bd6104c9b 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,4 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= -github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas= -github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= diff --git a/gorm.go b/gorm.go index 4402a2df6..d47be155a 100644 --- a/gorm.go +++ b/gorm.go @@ -49,7 +49,8 @@ type Config struct { CreateBatchSize int // TranslateError enabling error translation TranslateError bool - + // SkipOutputStatement disable OUTPUT clause when inserting a row + SkipOutputStatement bool // ClauseBuilders clause builder ClauseBuilders map[string]clause.ClauseBuilder // ConnPool db conn pool @@ -110,6 +111,7 @@ type Session struct { AllowGlobalUpdate bool FullSaveAssociations bool QueryFields bool + SkipOutputStatement bool Context context.Context Logger logger.Interface NowFunc func() time.Time @@ -224,6 +226,11 @@ func (db *DB) Session(config *Session) *DB { clone: 1, } ) + + if config.SkipOutputStatement { + tx.Config.SkipOutputStatement = true + } + if config.CreateBatchSize > 0 { tx.Config.CreateBatchSize = config.CreateBatchSize } @@ -318,6 +325,14 @@ func (db *DB) Debug() (tx *DB) { }) } +// Skip the output statement +func (db *DB) SkipOutput() (tx *DB) { + tx = db.getInstance() + return tx.Session(&Session{ + SkipOutputStatement: true, + }) +} + // Set store value with key into current db instance's context func (db *DB) Set(key string, value interface{}) *DB { tx := db.getInstance()