From f0118ab8ea548668f2558cdf8ce61f249ed61d6e Mon Sep 17 00:00:00 2001 From: Florian Beisel Date: Thu, 18 Jan 2024 00:11:39 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Use=20OldHostname=20when=20query?= =?UTF-8?q?ing=20the=20Database?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In BaseRule.baseUpdate our goal is to check if a hostname exists before trying to rename that hostname into something else. This patch fixes an error where the newly generated Hostname was used to check for the existence of the old hostname. --- rules/interface.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/interface.go b/rules/interface.go index 9e95f60..f79885f 100644 --- a/rules/interface.go +++ b/rules/interface.go @@ -32,7 +32,7 @@ func (br *BaseRule) baseInsert(category string, hostname string, paramsJSON []by } func (br *BaseRule) baseUpdate(category string, oldhostname string, hostname string, paramsJSON []byte) error { - exists, err := db.HostnameExists(category, hostname) + exists, err := db.HostnameExists(category, oldhostname) if err != nil { return fmt.Errorf("error checking existence of hostname: %v", err.Error()) }