From f63c5f8468461269e7267e13a5d196a0a10b72a6 Mon Sep 17 00:00:00 2001 From: Jorge Rojas Date: Tue, 21 Jan 2025 20:26:32 -0400 Subject: [PATCH] refactor: check for inserted rows logic --- components/results_table.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/components/results_table.go b/components/results_table.go index a27a738..53468c1 100644 --- a/components/results_table.go +++ b/components/results_table.go @@ -1375,20 +1375,21 @@ func (table *ResultsTable) UpdateSidebar() { func (table *ResultsTable) isAnInsertedRow(rowIndex int) (isAnInsertedRow bool, DBChangeIndex int) { for i, dmlChange := range *table.state.listOfDBChanges { - values := dmlChange.Values - - for _, value := range values { - if value.TableRowIndex == rowIndex { - cellReference := table.GetCell(rowIndex, 0).GetReference() - - isAnInsertedRow := cellReference != nil && cellReference.(string) != "NULL&" && cellReference.(string) != "EMPTY&" && cellReference.(string) != "DEFAULT&" - - if isAnInsertedRow { - return true, i - } + for _, value := range dmlChange.Values { + if value.TableRowIndex != rowIndex { + continue } + cellReference := table.GetCell(rowIndex, 0).GetReference() + if cellReference == nil { + break + } + switch cellReference.(string) { + case "NULL&", "EMPTY&", "DEFAULT&": + default: + return true, i + } + break } - } return false, -1 }