Skip to content

Commit

Permalink
Merge pull request #2112 from actiontech/issue2104
Browse files Browse the repository at this point in the history
ci: remove `` in sql because outer layer has added
  • Loading branch information
taolx0 authored Dec 1, 2023
2 parents 5414ee9 + 9a7be16 commit 688a2a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions sqle/driver/mysql/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,9 @@ func Ping(entry *logrus.Entry, instance *driverV2.DSN) error {

// When using keywords as table names, you need to pay attention to wrapping them in quotation marks
func (c *Executor) ShowCreateTable(schema, tableName string) (string, error) {
query := fmt.Sprintf("show create table `%s`", tableName)
query := fmt.Sprintf("show create table %s", tableName)
if schema != "" {
query = fmt.Sprintf("show create table `%s`.`%s`", schema, tableName)
query = fmt.Sprintf("show create table %s.%s", schema, tableName)
}
result, err := c.Db.Query(query)
if err != nil {
Expand Down Expand Up @@ -451,7 +451,7 @@ func (c *Executor) ShowSchemaViews(schema string) ([]string, error) {

// When using keywords as view names, you need to pay attention to wrapping them in quotation marks
func (c *Executor) ShowCreateView(tableName string) (string, error) {
result, err := c.Db.Query(fmt.Sprintf("show create view `%s`", tableName))
result, err := c.Db.Query(fmt.Sprintf("show create view %s", tableName))
if err != nil {
return "", err
}
Expand Down Expand Up @@ -677,8 +677,9 @@ type TableIndexesInfo struct {
Comment string
}

// When using keywords as view names, you need to pay attention to wrapping them in quotation marks
func (c *Executor) GetTableIndexesInfo(schema, tableName string) ([]*TableIndexesInfo, error) {
records, err := c.Db.Query(fmt.Sprintf("SHOW INDEX FROM `%s`.`%s`", schema, tableName))
records, err := c.Db.Query(fmt.Sprintf("SHOW INDEX FROM %s.%s", schema, tableName))
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion sqle/driver/mysql/session/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -1119,5 +1119,5 @@ func (c *Context) GetExecutor() *executor.Executor {
}

func (c *Context) GetTableIndexesInfo(schema, tableName string) ([]*executor.TableIndexesInfo, error) {
return c.e.GetTableIndexesInfo(schema, tableName)
return c.e.GetTableIndexesInfo(utils.SupplementalQuotationMarks(schema), utils.SupplementalQuotationMarks(tableName))
}

0 comments on commit 688a2a6

Please sign in to comment.