diff --git a/edit.go b/edit.go index 947fc87..759c006 100644 --- a/edit.go +++ b/edit.go @@ -10,6 +10,7 @@ import ( "github.com/nyaosorg/go-box/v3" + "github.com/hymkor/sqlbless/dialect" "github.com/hymkor/sqlbless/spread" "github.com/hymkor/sqlbless/internal/misc" @@ -59,7 +60,7 @@ func newViewer(ss *session) *spread.Viewer { var rxNonQuote = regexp.MustCompile(`^\w+$`) -func chooseTable(ctx context.Context, tables []string, ttyout io.Writer) (string, error) { +func chooseTable(ctx context.Context, tables []string, d *dialect.Entry, ttyout io.Writer) (string, error) { fmt.Fprintln(ttyout, "Select a table:") table, err := box.SelectString(tables, false, ttyout) fmt.Println() @@ -71,7 +72,7 @@ func chooseTable(ctx context.Context, tables []string, ttyout io.Writer) (string } targetTable := table[0] if !rxNonQuote.MatchString(targetTable) { - targetTable = `"` + table[0] + `"` + targetTable = d.EncloseIdentifier(table[0]) } return targetTable, nil } @@ -101,7 +102,7 @@ func doEdit(ctx context.Context, ss *session, command string, pilot commandIn) e if err != nil { return err } - tableAndWhere, err = chooseTable(ctx, tables, ss.termOut) + tableAndWhere, err = chooseTable(ctx, tables, ss.Dialect, ss.termOut) if err != nil || tableAndWhere == "" { return err } diff --git a/release_note_en.md b/release_note_en.md index 82207a4..29f22da 100644 --- a/release_note_en.md +++ b/release_note_en.md @@ -5,6 +5,7 @@ - Fix: completion — cursor moved to the start of the previous word when the current word was empty (#15, [go-readline-ny #17](https://github.com/nyaosorg/go-readline-ny/pull/17)) - Fix: an issue where pressing `Enter` on the result of the `desc` command (table list) did not show the column (`desc TABLE`) for the selected table on databases other than SQLite3. (#16) - Fix: In MySQL, pressing `r` on the table list failed to launch the `edit ` command because the table name was enclosed with a different type of quotation marks (`` ` ``) than other databases. (#17) +- Fix: In MySQL, `edit` not launching for tables with spaces. Correct handling of table names with spaces when selecting via arrow keys in `edit` without arguments (#18) ### Specification changes diff --git a/release_note_ja.md b/release_note_ja.md index a07a144..2451ee5 100644 --- a/release_note_ja.md +++ b/release_note_ja.md @@ -5,6 +5,7 @@ - 補完で、現在の単語が空の場合にカーソルが前の単語の先頭に移動してしまう不具合を修正 (#15,[go-readline-ny v1.12.3 #17](https://github.com/nyaosorg/go-readline-ny/pull/17)) - SQLite3 以外のデータベースで、引数なしのdesc コマンド(テーブル一覧)の中から `Enter` を押下して、該当行のテーブルのカラム一覧を表示できなかった不具合を修正 (#16) - MySQL で、テーブル一覧表示から、r を押下した時、テーブル名を囲むべき引用符が他のDBと違って `` ` `` だったため、`edit テーブル` コマンドが起動できなかった不具合を修正 (#17) +- Fix: MySQL で `edit` コマンド起動時、矢印キーで選択した空白を含むテーブル名が正しく処理されない問題を修正 (#18) ### 仕様変更