-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partial fix to delete row functionality #154
Conversation
Typo spotted: functionality, not funcionality |
components/results_table.go
Outdated
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 | ||
} | ||
} | ||
} | ||
|
||
} | ||
return false, -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to suggest
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 | |
} | |
} | |
} | |
} | |
return false, -1 | |
func (table *ResultsTable) isAnInsertedRow(rowIndex int) (isAnInsertedRow bool, DBChangeIndex int) { | |
for i, dmlChange := range *table.state.listOfDBChanges { | |
for _, value := range dmlChange.Values { | |
if value.TableRowIndex != rowIndex { | |
continue | |
} | |
cellReference := table.GetCell(rowIndex, 0).GetReference() | |
if cellReference == nil { | |
continue | |
} | |
switch cellReference.(string) { | |
case "NULL&", "EMPTY&", "DEFAULT&": | |
continue | |
default: | |
return true, i | |
} | |
} | |
} | |
return false, -1 |
this is pseudo code written on my phone, please check it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But maybe this would be more efficient
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 | |
} | |
} | |
} | |
} | |
return false, -1 | |
func (table *ResultsTable) isAnInsertedRow(rowIndex int) (isAnInsertedRow bool, DBChangeIndex int) { | |
for i, dmlChange := range *table.state.listOfDBChanges { | |
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 |
Co-authored-by: ccoVeille <[email protected]>
This is a partial fix to be able to mark and unmark rows to be deleted and keep row coloring.
But i am aware there are a lot of problems to keep the state of the changes being made to the rows (update, delete, append).
I will make a huge revamp to that logic in another PR.
Fixes #153