From 09c585cdb1056fc48c59541b0c66f20a81282a25 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Thu, 1 Jun 2017 09:58:50 -0400 Subject: [PATCH] dont run delete query when there's nothing to delete --- templates/singleton/boil_queries.tpl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/templates/singleton/boil_queries.tpl b/templates/singleton/boil_queries.tpl index 8ff4edd..248fae1 100644 --- a/templates/singleton/boil_queries.tpl +++ b/templates/singleton/boil_queries.tpl @@ -80,6 +80,11 @@ func deleteConflictsBeforeMerge(tx *sql.Tx, conflict conflictingUniqueKey, prima args = append(args, value) } + // if no rows found, no need to delete anything + if len(args) < 2 { + return nil + } + query = fmt.Sprintf( "DELETE FROM %s WHERE %s = %s AND %s IN (%s)", conflict.table, conflict.objectIdColumn, strmangle.Placeholders(dialect.IndexPlaceholders, 1, 1, 1),