From 24a04bc286c8692daa9b64f128dd6d8e41c47200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Almeida?= Date: Mon, 6 May 2024 12:33:00 +0100 Subject: [PATCH] adds PropagateUnscoped to db Config --- gorm.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gorm.go b/gorm.go index 775cd3de..24466609 100644 --- a/gorm.go +++ b/gorm.go @@ -50,6 +50,8 @@ type Config struct { CreateBatchSize int // TranslateError enabling error translation TranslateError bool + // PropagateUnscoped propagate Unscoped to every other nested statement + PropagateUnscoped bool // ClauseBuilders clause builder ClauseBuilders map[string]clause.ClauseBuilder @@ -409,6 +411,9 @@ func (db *DB) getInstance() *DB { Vars: make([]interface{}, 0, 8), SkipHooks: db.Statement.SkipHooks, } + if db.Config.PropagateUnscoped { + tx.Statement.Unscoped = db.Statement.Unscoped + } } else { // with clone statement tx.Statement = db.Statement.clone()