@@ -190,11 +190,17 @@ func (table *ResultsTable) AddRows(rows [][]string) {
190
190
for i , row := range rows {
191
191
for j , cell := range row {
192
192
tableCell := tview .NewTableCell (cell )
193
+ tableCell .SetTextColor (tview .Styles .PrimaryTextColor )
194
+
195
+ if cell == "EMPTY&" || cell == "NULL&" {
196
+ tableCell .SetText (strings .Replace (cell , "&" , "" , 1 ))
197
+ tableCell .SetStyle (table .GetItalicStyle ())
198
+ tableCell .SetReference (cell )
199
+ }
200
+
193
201
tableCell .SetSelectable (i > 0 )
194
202
tableCell .SetExpansion (1 )
195
203
196
- tableCell .SetTextColor (tview .Styles .PrimaryTextColor )
197
-
198
204
table .SetCell (i , j , tableCell )
199
205
}
200
206
}
@@ -228,7 +234,7 @@ func (table *ResultsTable) AddInsertedRows() {
228
234
tableCell .SetExpansion (1 )
229
235
tableCell .SetReference (inserts [i ].PrimaryKeyValue )
230
236
231
- tableCell .SetTextColor (tcell . ColorWhite . TrueColor () )
237
+ tableCell .SetTextColor (tview . Styles . PrimaryTextColor )
232
238
tableCell .SetBackgroundColor (InsertColor )
233
239
234
240
table .SetCell (rowIndex , j , tableCell )
@@ -242,7 +248,7 @@ func (table *ResultsTable) AppendNewRow(cells []models.CellValue, index int, UUI
242
248
tableCell .SetExpansion (1 )
243
249
tableCell .SetReference (UUID )
244
250
tableCell .SetTextColor (tview .Styles .PrimaryTextColor )
245
- tableCell .SetBackgroundColor (tcell . ColorDarkGreen )
251
+ tableCell .SetBackgroundColor (InsertColor )
246
252
247
253
switch cell .Type {
248
254
case models .Null :
@@ -346,7 +352,7 @@ func (table *ResultsTable) tableInputCapture(event *tcell.EventKey) *tcell.Event
346
352
for i , insertedRow := range * table .state .listOfDbChanges {
347
353
cellReference := table .GetCell (selectedRowIndex , 0 ).GetReference ()
348
354
349
- if cellReference != nil && insertedRow .PrimaryKeyValue == cellReference .( string ) {
355
+ if cellReference != nil && insertedRow .PrimaryKeyValue == cellReference {
350
356
isAnInsertedRow = true
351
357
indexOfInsertedRow = i
352
358
}
@@ -377,7 +383,13 @@ func (table *ResultsTable) tableInputCapture(event *tcell.EventKey) *tcell.Event
377
383
list := NewSetValueList ()
378
384
list .SetRect (x , y , width , 7 )
379
385
380
- list .OnFinish (table .FinishSettingValue )
386
+ list .OnFinish (func (selection models.CellValueType , value string ) {
387
+ table .FinishSettingValue ()
388
+
389
+ if selection >= 0 {
390
+ table .AppendNewChange (models .DmlUpdateType , table .Tree .GetSelectedDatabase (), table .Tree .GetSelectedTable (), selectedRowIndex , selectedColumnIndex , models.CellValue {Type : selection , Value : value , Column : table .GetColumnNameByIndex (selectedColumnIndex )})
391
+ }
392
+ })
381
393
382
394
list .Show (x , y , width )
383
395
}
@@ -424,7 +436,13 @@ func (table *ResultsTable) UpdateRowsColor(headerColor tcell.Color, rowColor tce
424
436
if i == 0 && headerColor != 0 {
425
437
cell .SetTextColor (headerColor )
426
438
} else {
427
- cell .SetTextColor (rowColor )
439
+ cellReference := cell .GetReference ()
440
+
441
+ if cellReference != nil && cellReference == "EMPTY&" || cellReference == "NULL&" || cellReference == "DEFAULT&" {
442
+ cell .SetStyle (table .GetItalicStyle ())
443
+ } else {
444
+ cell .SetTextColor (rowColor )
445
+ }
428
446
}
429
447
}
430
448
}
@@ -516,6 +534,7 @@ func (table *ResultsTable) subscribeToEditorChanges() {
516
534
if strings .Contains (queryLower , "select" ) {
517
535
table .SetLoading (true )
518
536
App .Draw ()
537
+
519
538
rows , err := table .DBDriver .ExecuteQuery (query )
520
539
table .Pagination .SetTotalRecords (len (rows ))
521
540
table .Pagination .SetLimit (len (rows ))
@@ -927,7 +946,7 @@ func (table *ResultsTable) AppendNewChange(changeType models.DmlType, databaseNa
927
946
tableCell := table .GetCell (rowIndex , colIndex )
928
947
tableCellReference := tableCell .GetReference ()
929
948
930
- isAnInsertedRow := tableCellReference != nil
949
+ isAnInsertedRow := tableCellReference != nil && tableCellReference .( string ) != "NULL&" && tableCellReference .( string ) != "EMPTY&" && tableCellReference .( string ) != "DEFAULT&"
931
950
932
951
if isAnInsertedRow {
933
952
table .MutateInsertedRowCell (tableCellReference .(string ), value )
@@ -936,6 +955,15 @@ func (table *ResultsTable) AppendNewChange(changeType models.DmlType, databaseNa
936
955
937
956
primaryKeyValue , primaryKeyColumnName := table .GetPrimaryKeyValue (rowIndex )
938
957
958
+ if changeType == models .DmlUpdateType {
959
+ switch value .Type {
960
+ case models .Null , models .Empty , models .Default :
961
+ tableCell .SetText (value .Value .(string ))
962
+ tableCell .SetStyle (tcell .StyleDefault .Italic (true ))
963
+ tableCell .SetReference (value .Value .(string ) + "&" )
964
+ }
965
+ }
966
+
939
967
for i , dmlChange := range * table .state .listOfDbChanges {
940
968
if dmlChange .Table == tableName && dmlChange .Type == changeType && dmlChange .PrimaryKeyValue == primaryKeyValue {
941
969
dmlChangeAlreadyExists = true
@@ -984,6 +1012,7 @@ func (table *ResultsTable) AppendNewChange(changeType models.DmlType, databaseNa
984
1012
case models .DmlDeleteType :
985
1013
table .SetRowColor (rowIndex , DeleteColor )
986
1014
case models .DmlUpdateType :
1015
+ tableCell .SetStyle (tcell .StyleDefault .Background (ChangeColor ))
987
1016
table .SetCellColor (rowIndex , colIndex , ChangeColor )
988
1017
}
989
1018
@@ -1243,3 +1272,7 @@ func (table *ResultsTable) FinishSettingValue() {
1243
1272
table .SetInputCapture (table .tableInputCapture )
1244
1273
App .SetFocus (table )
1245
1274
}
1275
+
1276
+ func (table * ResultsTable ) GetItalicStyle () tcell.Style {
1277
+ return tcell .StyleDefault .Foreground (tview .Styles .InverseTextColor ).Italic (true )
1278
+ }
0 commit comments