From 6d1da1fbd844d7e421d384301f35c2066f31f4b4 Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 18 Dec 2024 16:04:19 +0800 Subject: [PATCH 1/8] feat: support SHOW query results --- components/results_table.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/results_table.go b/components/results_table.go index ffa11bd..330f166 100644 --- a/components/results_table.go +++ b/components/results_table.go @@ -603,13 +603,13 @@ func (table *ResultsTable) subscribeToEditorChanges() { case eventSQLEditorQuery: query := stateChange.Value.(string) if query != "" { - queryLower := strings.ToLower(query) - - if strings.Contains(queryLower, "select") { + queryLower := strings.ToLower(strings.TrimSpace(query)) + if strings.Contains(queryLower, "select") || strings.Contains(queryLower, "show") { table.SetLoading(true) App.Draw() rows, err := table.DBDriver.ExecuteQuery(query) + table.Pagination.SetTotalRecords(len(rows)) table.Pagination.SetLimit(len(rows)) From 36a2934980514dd22abd1f650b470cd88f05cea1 Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 18 Dec 2024 16:10:32 +0800 Subject: [PATCH 2/8] feat: add Y key to copy entire row --- app/keymap.go | 3 ++- commands/commands.go | 5 +++++ components/results_table.go | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/keymap.go b/app/keymap.go index 71859f9..d3f1c5e 100644 --- a/app/keymap.go +++ b/app/keymap.go @@ -96,7 +96,8 @@ var Keymaps = KeymapSystem{ Bind{Key: Key{Char: 'b'}, Cmd: cmd.GotoPrev, Description: "Go to previous cell"}, Bind{Key: Key{Char: '$'}, Cmd: cmd.GotoEnd, Description: "Go to last cell"}, Bind{Key: Key{Char: '0'}, Cmd: cmd.GotoStart, Description: "Go to first cell"}, - Bind{Key: Key{Char: 'y'}, Cmd: cmd.Copy, Description: "Copy cell value to clipboard"}, + Bind{Key: Key{Char: 'y'}, Cmd: cmd.Copy, Description: "Copy cell value"}, + Bind{Key: Key{Char: 'Y'}, Cmd: cmd.CopyRow, Description: "Copy entire row"}, Bind{Key: Key{Char: 'o'}, Cmd: cmd.AppendNewRow, Description: "Append new row"}, Bind{Key: Key{Char: 'J'}, Cmd: cmd.SortDesc, Description: "Sort descending"}, Bind{Key: Key{Char: 'R'}, Cmd: cmd.Refresh, Description: "Refresh the current table"}, diff --git a/commands/commands.go b/commands/commands.go index 4a4cf45..246037a 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -74,6 +74,9 @@ const ( TestConnection EditConnection DeleteConnection + + // CopyRow Command + CopyRow ) func (c Command) String() string { @@ -200,6 +203,8 @@ func (c Command) String() string { return "CommitEdit" case DiscardEdit: return "DiscardEdit" + case CopyRow: + return "CopyRow" } return "Unknown" diff --git a/components/results_table.go b/components/results_table.go index 330f166..2933842 100644 --- a/components/results_table.go +++ b/components/results_table.go @@ -466,6 +466,22 @@ func (table *ResultsTable) tableInputCapture(event *tcell.EventKey) *tcell.Event if table.GetShowSidebar() { App.SetFocus(table.Sidebar) } + } else if command == commands.CopyRow { + row, _ := table.GetSelection() + var rowData []string + + // 获取所有列的数据 + for col := 0; col < table.GetColumnCount(); col++ { + cell := table.GetCell(row, col) + rowData = append(rowData, cell.Text) + } + + // 用制表符连接数据 + clipboard := strings.Join(rowData, "\t") + err := lib.NewClipboard().Write(clipboard) + if err != nil { + table.SetError(err.Error(), nil) + } } if len(table.GetRecords()) > 0 { From 203f4e059eddf35225f8bca5ac6de36cc37e81bd Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 18 Dec 2024 16:26:33 +0800 Subject: [PATCH 3/8] feat: add Ctrl+s to copy as SELECT WHERE, add Ctrl+u to copy as UPDATE, add Ctrl+i to copy as INSERT Signed-off-by: bob --- app/keymap.go | 3 ++ commands/commands.go | 9 +++++ components/results_table.go | 65 +++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) diff --git a/app/keymap.go b/app/keymap.go index d3f1c5e..74a76d8 100644 --- a/app/keymap.go +++ b/app/keymap.go @@ -120,6 +120,9 @@ var Keymaps = KeymapSystem{ // Sidebar Bind{Key: Key{Char: 'S'}, Cmd: cmd.ToggleSidebar, Description: "Toggle sidebar"}, Bind{Key: Key{Char: 's'}, Cmd: cmd.FocusSidebar, Description: "Focus sidebar"}, + Bind{Key: Key{Code: tcell.KeyCtrlI}, Cmd: cmd.CopyRowAsInsert, Description: "Copy as INSERT VALUES"}, + Bind{Key: Key{Code: tcell.KeyCtrlU}, Cmd: cmd.CopyRowAsUpdate, Description: "Copy as UPDATE SET"}, + Bind{Key: Key{Code: tcell.KeyCtrlS}, Cmd: cmd.CopyRowAsSelect, Description: "Copy as SELECT WHERE"}, }, EditorGroup: { Bind{Key: Key{Code: tcell.KeyCtrlR}, Cmd: cmd.Execute, Description: "Execute query"}, diff --git a/commands/commands.go b/commands/commands.go index 246037a..ae00c39 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -77,6 +77,9 @@ const ( // CopyRow Command CopyRow + CopyRowAsInsert + CopyRowAsUpdate + CopyRowAsSelect ) func (c Command) String() string { @@ -205,6 +208,12 @@ func (c Command) String() string { return "DiscardEdit" case CopyRow: return "CopyRow" + case CopyRowAsInsert: + return "CopyRowAsInsert" + case CopyRowAsUpdate: + return "CopyRowAsUpdate" + case CopyRowAsSelect: + return "CopyRowAsSelect" } return "Unknown" diff --git a/components/results_table.go b/components/results_table.go index 2933842..0eb9a43 100644 --- a/components/results_table.go +++ b/components/results_table.go @@ -482,6 +482,18 @@ func (table *ResultsTable) tableInputCapture(event *tcell.EventKey) *tcell.Event if err != nil { table.SetError(err.Error(), nil) } + } else if command == commands.CopyRowAsInsert { + if err := table.copyRowAsSQL("INSERT"); err != nil { + table.SetError(err.Error(), nil) + } + } else if command == commands.CopyRowAsUpdate { + if err := table.copyRowAsSQL("UPDATE"); err != nil { + table.SetError(err.Error(), nil) + } + } else if command == commands.CopyRowAsSelect { + if err := table.copyRowAsSQL("SELECT"); err != nil { + table.SetError(err.Error(), nil) + } } if len(table.GetRecords()) > 0 { @@ -1385,3 +1397,56 @@ func (table *ResultsTable) UpdateSidebar() { } } + +func (table *ResultsTable) copyRowAsSQL(format string) error { + row, _ := table.GetSelection() + var values []string + var columns []string + var whereConditions []string + + // 获取列名和值 + for col := 0; col < table.GetColumnCount(); col++ { + header := table.GetCell(0, col).Text + cell := table.GetCell(row, col) + columns = append(columns, header) + + // 处理值的格式 + value := cell.Text + if value == "NULL" { + values = append(values, "NULL") + whereConditions = append(whereConditions, fmt.Sprintf("`%s` IS NULL", header)) + } else { + values = append(values, fmt.Sprintf("'%s'", value)) + whereConditions = append(whereConditions, fmt.Sprintf("`%s` = '%s'", header, value)) + } + } + + var sql string + switch format { + case "INSERT": + sql = fmt.Sprintf("INSERT INTO %s (%s) VALUES (%s);", + table.GetTitle(), + strings.Join(columns, ", "), + strings.Join(values, ", ")) + + case "UPDATE": + var sets []string + for i := range columns { + sets = append(sets, fmt.Sprintf("%s = %s", columns[i], values[i])) + } + // 假设第一列是主键 + sql = fmt.Sprintf("UPDATE %s SET %s WHERE %s = %s;", + table.GetTitle(), + strings.Join(sets, ", "), + columns[0], + values[0]) + + case "SELECT": + sql = fmt.Sprintf("SELECT * FROM %s WHERE %s;", + table.GetTitle(), + strings.Join(whereConditions, " AND ")) + } + + clipboard := lib.NewClipboard() + return clipboard.Write(sql) +} From 09aa01a690354db439898423e83a600e19759947 Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 18 Dec 2024 16:56:13 +0800 Subject: [PATCH 4/8] feat: add Ctrl+Y to copy SQL editor text --- app/keymap.go | 1 + components/constants.go | 1 + components/sql_editor.go | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/app/keymap.go b/app/keymap.go index 74a76d8..7aa6e6d 100644 --- a/app/keymap.go +++ b/app/keymap.go @@ -128,6 +128,7 @@ var Keymaps = KeymapSystem{ Bind{Key: Key{Code: tcell.KeyCtrlR}, Cmd: cmd.Execute, Description: "Execute query"}, Bind{Key: Key{Code: tcell.KeyEscape}, Cmd: cmd.UnfocusEditor, Description: "Unfocus editor"}, Bind{Key: Key{Code: tcell.KeyCtrlSpace}, Cmd: cmd.OpenInExternalEditor, Description: "Open in external editor"}, + Bind{Key: Key{Code: tcell.KeyCtrlY}, Cmd: cmd.Copy, Description: "Copy editor text"}, }, SidebarGroup: { Bind{Key: Key{Char: 's'}, Cmd: cmd.UnfocusSidebar, Description: "Focus table"}, diff --git a/components/constants.go b/components/constants.go index b520adb..4f24f58 100644 --- a/components/constants.go +++ b/components/constants.go @@ -49,6 +49,7 @@ const ( eventSQLEditorQuery string = "Query" eventSQLEditorEscape string = "Escape" + eventSQLEditorError string = "Error" eventResultsTableFiltering string = "FilteringResultsTable" diff --git a/components/sql_editor.go b/components/sql_editor.go index f80867f..ea16be8 100644 --- a/components/sql_editor.go +++ b/components/sql_editor.go @@ -10,6 +10,7 @@ import ( "github.com/jorgerojas26/lazysql/app" "github.com/jorgerojas26/lazysql/commands" + "github.com/jorgerojas26/lazysql/lib" "github.com/jorgerojas26/lazysql/models" ) @@ -51,6 +52,14 @@ func NewSQLEditor() *SQLEditor { text := openExternalEditor(sqlEditor) sqlEditor.SetText(text, true) } + + case commands.Copy: + text := sqlEditor.GetText() + clipboard := lib.NewClipboard() + if err := clipboard.Write(text); err != nil { + sqlEditor.Publish(eventSQLEditorError, err.Error()) + } + return nil } return event From 49af0112b1f9c6fadf321e7557ccee0f502ce1d9 Mon Sep 17 00:00:00 2001 From: bob Date: Wed, 18 Dec 2024 16:58:57 +0800 Subject: [PATCH 5/8] temp add feat: add y key to copy tree node name --- app/keymap.go | 1 + components/tree.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/app/keymap.go b/app/keymap.go index 7aa6e6d..21e3ef9 100644 --- a/app/keymap.go +++ b/app/keymap.go @@ -83,6 +83,7 @@ var Keymaps = KeymapSystem{ Bind{Key: Key{Char: 'c'}, Cmd: cmd.TreeCollapseAll, Description: "Collapse all"}, Bind{Key: Key{Char: 'e'}, Cmd: cmd.ExpandAll, Description: "Expand all"}, Bind{Key: Key{Char: 'R'}, Cmd: cmd.Refresh, Description: "Refresh tree"}, + Bind{Key: Key{Char: 'y'}, Cmd: cmd.Copy, Description: "Copy node name"}, }, TreeFilterGroup: { Bind{Key: Key{Code: tcell.KeyEscape}, Cmd: cmd.UnfocusTreeFilter, Description: "Unfocus tree filter"}, diff --git a/components/tree.go b/components/tree.go index 71609fd..a506982 100644 --- a/components/tree.go +++ b/components/tree.go @@ -14,6 +14,7 @@ import ( "github.com/jorgerojas26/lazysql/commands" "github.com/jorgerojas26/lazysql/drivers" "github.com/jorgerojas26/lazysql/helpers/logger" + "github.com/jorgerojas26/lazysql/lib" "github.com/jorgerojas26/lazysql/models" ) @@ -176,6 +177,19 @@ func NewTree(dbName string, dbdriver drivers.Driver) *Tree { tree.ExpandAll() case commands.Refresh: tree.Refresh(dbName) + case commands.Copy: + node := tree.GetCurrentNode() + if node == nil { + return event + } + + nodeRef := node.GetReference().(string) + clipboard := lib.NewClipboard() + if err := clipboard.Write(nodeRef); err != nil { + // 处理错误 + return event + } + return nil } return nil }) From 3f2996f60032c5b909de9bb90ea58f9239731e94 Mon Sep 17 00:00:00 2001 From: bob Date: Mon, 23 Dec 2024 11:14:14 +0800 Subject: [PATCH 6/8] feat: add copyas --- app/keymap.go | 8 +++++ commands/commands.go | 5 +++ components/constants.go | 3 ++ components/copy_as_list.go | 71 +++++++++++++++++++++++++++++++++++++ components/results_table.go | 21 +++++++++++ 5 files changed, 108 insertions(+) create mode 100644 components/copy_as_list.go diff --git a/app/keymap.go b/app/keymap.go index 21e3ef9..ad6c1e7 100644 --- a/app/keymap.go +++ b/app/keymap.go @@ -45,6 +45,7 @@ const ( EditorGroup = "editor" ConnectionGroup = "connection" SidebarGroup = "sidebar" + CopyAsMenuGroup = "copyas" ) // Define a global KeymapSystem object with default keybinds @@ -124,6 +125,7 @@ var Keymaps = KeymapSystem{ Bind{Key: Key{Code: tcell.KeyCtrlI}, Cmd: cmd.CopyRowAsInsert, Description: "Copy as INSERT VALUES"}, Bind{Key: Key{Code: tcell.KeyCtrlU}, Cmd: cmd.CopyRowAsUpdate, Description: "Copy as UPDATE SET"}, Bind{Key: Key{Code: tcell.KeyCtrlS}, Cmd: cmd.CopyRowAsSelect, Description: "Copy as SELECT WHERE"}, + Bind{Key: Key{Code: tcell.KeyCtrlY}, Cmd: cmd.CopyAsMenu, Description: "Copy as menu"}, }, EditorGroup: { Bind{Key: Key{Code: tcell.KeyCtrlR}, Cmd: cmd.Execute, Description: "Execute query"}, @@ -144,5 +146,11 @@ var Keymaps = KeymapSystem{ Bind{Key: Key{Char: 'C'}, Cmd: cmd.SetValue, Description: "Toggle value menu to put values like NULL, EMPTY or DEFAULT"}, Bind{Key: Key{Char: 'y'}, Cmd: cmd.Copy, Description: "Copy value to clipboard"}, }, + CopyAsMenuGroup: { + Bind{Key: Key{Char: 'i'}, Cmd: cmd.CopyRowAsInsert, Description: "Copy as INSERT"}, + Bind{Key: Key{Char: 'u'}, Cmd: cmd.CopyRowAsUpdate, Description: "Copy as UPDATE"}, + Bind{Key: Key{Char: 's'}, Cmd: cmd.CopyRowAsSelect, Description: "Copy as SELECT"}, + Bind{Key: Key{Code: tcell.KeyEscape}, Cmd: cmd.Quit, Description: "Close menu"}, + }, }, } diff --git a/commands/commands.go b/commands/commands.go index ae00c39..12d2d9e 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -80,6 +80,9 @@ const ( CopyRowAsInsert CopyRowAsUpdate CopyRowAsSelect + + // CopyAsMenu Command + CopyAsMenu ) func (c Command) String() string { @@ -214,6 +217,8 @@ func (c Command) String() string { return "CopyRowAsUpdate" case CopyRowAsSelect: return "CopyRowAsSelect" + case CopyAsMenu: + return "CopyAsMenu" } return "Unknown" diff --git a/components/constants.go b/components/constants.go index 4f24f58..cd1019e 100644 --- a/components/constants.go +++ b/components/constants.go @@ -32,6 +32,9 @@ const ( // SetValueList pageNameSetValue string = "SetValue" + + // CopyAs + pageNameCopyAs = "copyAs" ) // Tabs diff --git a/components/copy_as_list.go b/components/copy_as_list.go new file mode 100644 index 0000000..2e15be8 --- /dev/null +++ b/components/copy_as_list.go @@ -0,0 +1,71 @@ +package components + +import ( + "github.com/gdamore/tcell/v2" + "github.com/jorgerojas26/lazysql/app" + "github.com/jorgerojas26/lazysql/commands" + "github.com/rivo/tview" +) + +type CopyAsList struct { + *tview.List + table *ResultsTable +} + +func NewCopyAsList(table *ResultsTable) *CopyAsList { + list := &CopyAsList{ + List: tview.NewList(), + table: table, + } + + list.SetBorder(true) + list.SetTitle("Copy as...") + list.SetTitleColor(app.Styles.PrimaryTextColor) + list.SetBackgroundColor(app.Styles.PrimitiveBackgroundColor) + + // Add options + list.AddItem("Copy as INSERT", "", 'i', nil) + list.AddItem("Copy as UPDATE", "", 'u', nil) + list.AddItem("Copy as SELECT", "", 's', nil) + + list.SetSelectedFunc(func(index int, _ string, _ string, _ rune) { + list.Hide() + switch index { + case 0: + if err := table.copyRowAsSQL("INSERT"); err != nil { + table.SetError(err.Error(), nil) + } + case 1: + if err := table.copyRowAsSQL("UPDATE"); err != nil { + table.SetError(err.Error(), nil) + } + case 2: + if err := table.copyRowAsSQL("SELECT"); err != nil { + table.SetError(err.Error(), nil) + } + } + }) + + // Add shortcut key support + list.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { + command := app.Keymaps.Group(app.CopyAsMenuGroup).Resolve(event) + if command == commands.Quit { + list.Hide() + return nil + } + return event + }) + + return list +} + +func (list *CopyAsList) Show(x, y, width int) { + list.SetRect(x, y, width, 8) // Adjust height based on number of options + MainPages.AddPage(pageNameCopyAs, list, false, true) + App.SetFocus(list) +} + +func (list *CopyAsList) Hide() { + MainPages.RemovePage(pageNameCopyAs) + App.SetFocus(list.table) +} diff --git a/components/results_table.go b/components/results_table.go index 0eb9a43..a3696c9 100644 --- a/components/results_table.go +++ b/components/results_table.go @@ -494,6 +494,14 @@ func (table *ResultsTable) tableInputCapture(event *tcell.EventKey) *tcell.Event if err := table.copyRowAsSQL("SELECT"); err != nil { table.SetError(err.Error(), nil) } + } else if command == commands.CopyAsMenu { + // Get current selected cell position + row, col := table.GetSelection() + x, y, _, _ := table.GetRect() + + // Show copy menu + copyAsList := NewCopyAsList(table) + copyAsList.Show(x+col*10, y+row, 30) // Adjust position and width } if len(table.GetRecords()) > 0 { @@ -1450,3 +1458,16 @@ func (table *ResultsTable) copyRowAsSQL(format string) error { clipboard := lib.NewClipboard() return clipboard.Write(sql) } + +func (table *ResultsTable) HandleCommand(command commands.Command) { + switch command { + case commands.CopyAsMenu: + // Get current selected cell position + row, col := table.GetSelection() + x, y, _, _ := table.GetRect() + + // Show copy menu + copyAsList := NewCopyAsList(table) + copyAsList.Show(x+col*10, y+row, 30) // Adjust position and width + } +} From 7d259d50dc6cdb2404dc8405a6c7bb13ced4d67d Mon Sep 17 00:00:00 2001 From: bob Date: Mon, 23 Dec 2024 11:21:19 +0800 Subject: [PATCH 7/8] git revert feat: add Ctrl+s to copy as SELECT WHERE, add Ctrl+u to copy as UPDATE --- app/keymap.go | 3 --- components/results_table.go | 13 ------------- 2 files changed, 16 deletions(-) diff --git a/app/keymap.go b/app/keymap.go index ad6c1e7..830f85b 100644 --- a/app/keymap.go +++ b/app/keymap.go @@ -122,9 +122,6 @@ var Keymaps = KeymapSystem{ // Sidebar Bind{Key: Key{Char: 'S'}, Cmd: cmd.ToggleSidebar, Description: "Toggle sidebar"}, Bind{Key: Key{Char: 's'}, Cmd: cmd.FocusSidebar, Description: "Focus sidebar"}, - Bind{Key: Key{Code: tcell.KeyCtrlI}, Cmd: cmd.CopyRowAsInsert, Description: "Copy as INSERT VALUES"}, - Bind{Key: Key{Code: tcell.KeyCtrlU}, Cmd: cmd.CopyRowAsUpdate, Description: "Copy as UPDATE SET"}, - Bind{Key: Key{Code: tcell.KeyCtrlS}, Cmd: cmd.CopyRowAsSelect, Description: "Copy as SELECT WHERE"}, Bind{Key: Key{Code: tcell.KeyCtrlY}, Cmd: cmd.CopyAsMenu, Description: "Copy as menu"}, }, EditorGroup: { diff --git a/components/results_table.go b/components/results_table.go index a3696c9..cf6530b 100644 --- a/components/results_table.go +++ b/components/results_table.go @@ -482,18 +482,6 @@ func (table *ResultsTable) tableInputCapture(event *tcell.EventKey) *tcell.Event if err != nil { table.SetError(err.Error(), nil) } - } else if command == commands.CopyRowAsInsert { - if err := table.copyRowAsSQL("INSERT"); err != nil { - table.SetError(err.Error(), nil) - } - } else if command == commands.CopyRowAsUpdate { - if err := table.copyRowAsSQL("UPDATE"); err != nil { - table.SetError(err.Error(), nil) - } - } else if command == commands.CopyRowAsSelect { - if err := table.copyRowAsSQL("SELECT"); err != nil { - table.SetError(err.Error(), nil) - } } else if command == commands.CopyAsMenu { // Get current selected cell position row, col := table.GetSelection() @@ -1458,7 +1446,6 @@ func (table *ResultsTable) copyRowAsSQL(format string) error { clipboard := lib.NewClipboard() return clipboard.Write(sql) } - func (table *ResultsTable) HandleCommand(command commands.Command) { switch command { case commands.CopyAsMenu: From d151c7ebdca1221def45b3e9f9fc1ca6b24c24ee Mon Sep 17 00:00:00 2001 From: bob Date: Mon, 23 Dec 2024 11:37:51 +0800 Subject: [PATCH 8/8] translate chinese to english --- components/results_table.go | 11 +++++------ components/tree.go | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/components/results_table.go b/components/results_table.go index cf6530b..b190449 100644 --- a/components/results_table.go +++ b/components/results_table.go @@ -469,14 +469,13 @@ func (table *ResultsTable) tableInputCapture(event *tcell.EventKey) *tcell.Event } else if command == commands.CopyRow { row, _ := table.GetSelection() var rowData []string - - // 获取所有列的数据 + // Get data from all columns for col := 0; col < table.GetColumnCount(); col++ { cell := table.GetCell(row, col) rowData = append(rowData, cell.Text) } - // 用制表符连接数据 + // Join data with tab character clipboard := strings.Join(rowData, "\t") err := lib.NewClipboard().Write(clipboard) if err != nil { @@ -1400,13 +1399,13 @@ func (table *ResultsTable) copyRowAsSQL(format string) error { var columns []string var whereConditions []string - // 获取列名和值 + // Get column names and values for col := 0; col < table.GetColumnCount(); col++ { header := table.GetCell(0, col).Text cell := table.GetCell(row, col) columns = append(columns, header) - // 处理值的格式 + // Handle value formatting value := cell.Text if value == "NULL" { values = append(values, "NULL") @@ -1430,7 +1429,7 @@ func (table *ResultsTable) copyRowAsSQL(format string) error { for i := range columns { sets = append(sets, fmt.Sprintf("%s = %s", columns[i], values[i])) } - // 假设第一列是主键 + // Assume first column is primary key sql = fmt.Sprintf("UPDATE %s SET %s WHERE %s = %s;", table.GetTitle(), strings.Join(sets, ", "), diff --git a/components/tree.go b/components/tree.go index a506982..ca48be1 100644 --- a/components/tree.go +++ b/components/tree.go @@ -186,7 +186,7 @@ func NewTree(dbName string, dbdriver drivers.Driver) *Tree { nodeRef := node.GetReference().(string) clipboard := lib.NewClipboard() if err := clipboard.Write(nodeRef); err != nil { - // 处理错误 + // handle error return event } return nil