Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions release_note_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <table>` 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

Expand Down
1 change: 1 addition & 0 deletions release_note_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

### 仕様変更

Expand Down