From 18730d5a3e5dee4e046fcb06a5e285ee267aa2d9 Mon Sep 17 00:00:00 2001 From: Patrik Date: Tue, 12 Jul 2022 16:31:04 +0200 Subject: [PATCH] fix: make disableEager not trigger the race detector --- connection.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/connection.go b/connection.go index ecb3e87c..932b4777 100644 --- a/connection.go +++ b/connection.go @@ -241,8 +241,13 @@ func (c *Connection) Q() *Query { // disableEager disables eager mode for current connection. func (c *Connection) disableEager() { - c.eager = false - c.eagerFields = []string{} + // The check technically is not required, because (*Connection).Eager() creates a (shallow) copy. + // When not reusing eager connections, this should be safe. + // However, this write triggers the go race detector. + if c.eager { + c.eager = false + c.eagerFields = []string{} + } } // TruncateAll truncates all data from the datasource