Skip to content

Commit 38360a3

Browse files
authored
Merge pull request #17 from hymkor/push-qmwzrvpsvpwl
`desc` → `r` failed on MySQL
2 parents 017f489 + 57e84c6 commit 38360a3

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

commands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func doDescTables(ctx context.Context, ss *session, commandIn commandIn) error {
139139
rc, err := handler(e)
140140
if err == nil && rc.Quit && name != "" {
141141
action = func() error {
142-
return doEdit(ctx, ss, `edit "`+name+`"`, commandIn)
142+
return doEdit(ctx, ss, "edit "+ss.Dialect.EncloseIdentifier(name), commandIn)
143143
}
144144
}
145145
return rc, err

dialect/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@ type Entry struct {
5353

5454
// IsQuerySQL reports whether the given SQL statement is a query (e.g., SELECT) or not.
5555
IsQuerySQL func(sql string) bool
56+
57+
// IdentifierEncloser encloses an identifier with dialect-specific quotes.
58+
IdentifierEncloser func(name string) string
59+
}
60+
61+
// EncloseIdentifier returns the given name enclosed with
62+
// dialect-specific quotes. If IdentifierEncloser is nil,
63+
// it defaults to using double quotes.
64+
func (D *Entry) EncloseIdentifier(name string) string {
65+
if f := D.IdentifierEncloser; f != nil {
66+
return f(name)
67+
}
68+
return `"` + name + `"`
5669
}
5770

5871
func (D *Entry) LookupConverter(typeName string) func(string) (any, error) {

dialect/mysql/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ var mySqlSpec = &dialect.Entry{
9292
DSNFilter: mySQLDSNFilter,
9393
TableNameField: "TABLE_NAME",
9494
ColumnNameField: "NAME",
95+
96+
IdentifierEncloser: func(s string) string {
97+
return "`" + s + "`"
98+
},
9599
}
96100

97101
func init() {

release_note_en.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- 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))
66
- 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)
7+
- 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)
78

89
### Specification changes
910

release_note_ja.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- 補完で、現在の単語が空の場合にカーソルが前の単語の先頭に移動してしまう不具合を修正 (#15,[go-readline-ny v1.12.3 #17](https://github.com/nyaosorg/go-readline-ny/pull/17))
66
- SQLite3 以外のデータベースで、引数なしのdesc コマンド(テーブル一覧)の中から `Enter` を押下して、該当行のテーブルのカラム一覧を表示できなかった不具合を修正 (#16)
7+
- MySQL で、テーブル一覧表示から、r を押下した時、テーブル名を囲むべき引用符が他のDBと違って `` ` `` だったため、`edit テーブル` コマンドが起動できなかった不具合を修正 (#17)
78

89
### 仕様変更
910

0 commit comments

Comments
 (0)