add comment for mysql dialect (#579)
This commit is contained in:
parent
d52a762fba
commit
65b517242f
|
@ -299,7 +299,7 @@ func (db *mysql) TableCheckSql(tableName string) (string, []interface{}) {
|
||||||
func (db *mysql) GetColumns(tableName string) ([]string, map[string]*core.Column, error) {
|
func (db *mysql) GetColumns(tableName string) ([]string, map[string]*core.Column, error) {
|
||||||
args := []interface{}{db.DbName, tableName}
|
args := []interface{}{db.DbName, tableName}
|
||||||
s := "SELECT `COLUMN_NAME`, `IS_NULLABLE`, `COLUMN_DEFAULT`, `COLUMN_TYPE`," +
|
s := "SELECT `COLUMN_NAME`, `IS_NULLABLE`, `COLUMN_DEFAULT`, `COLUMN_TYPE`," +
|
||||||
" `COLUMN_KEY`, `EXTRA` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?"
|
" `COLUMN_KEY`, `EXTRA`,`COLUMN_COMMENT` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?"
|
||||||
db.LogSQL(s, args)
|
db.LogSQL(s, args)
|
||||||
|
|
||||||
rows, err := db.DB().Query(s, args...)
|
rows, err := db.DB().Query(s, args...)
|
||||||
|
@ -314,13 +314,14 @@ func (db *mysql) GetColumns(tableName string) ([]string, map[string]*core.Column
|
||||||
col := new(core.Column)
|
col := new(core.Column)
|
||||||
col.Indexes = make(map[string]int)
|
col.Indexes = make(map[string]int)
|
||||||
|
|
||||||
var columnName, isNullable, colType, colKey, extra string
|
var columnName, isNullable, colType, colKey, extra, comment string
|
||||||
var colDefault *string
|
var colDefault *string
|
||||||
err = rows.Scan(&columnName, &isNullable, &colDefault, &colType, &colKey, &extra)
|
err = rows.Scan(&columnName, &isNullable, &colDefault, &colType, &colKey, &extra, &comment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
col.Name = strings.Trim(columnName, "` ")
|
col.Name = strings.Trim(columnName, "` ")
|
||||||
|
col.Comment = comment
|
||||||
if "YES" == isNullable {
|
if "YES" == isNullable {
|
||||||
col.Nullable = true
|
col.Nullable = true
|
||||||
}
|
}
|
||||||
|
@ -407,7 +408,7 @@ func (db *mysql) GetColumns(tableName string) ([]string, map[string]*core.Column
|
||||||
|
|
||||||
func (db *mysql) GetTables() ([]*core.Table, error) {
|
func (db *mysql) GetTables() ([]*core.Table, error) {
|
||||||
args := []interface{}{db.DbName}
|
args := []interface{}{db.DbName}
|
||||||
s := "SELECT `TABLE_NAME`, `ENGINE`, `TABLE_ROWS`, `AUTO_INCREMENT` from " +
|
s := "SELECT `TABLE_NAME`, `ENGINE`, `TABLE_ROWS`, `AUTO_INCREMENT`, `TABLE_COMMENT` from " +
|
||||||
"`INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_SCHEMA`=? AND (`ENGINE`='MyISAM' OR `ENGINE` = 'InnoDB' OR `ENGINE` = 'TokuDB')"
|
"`INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_SCHEMA`=? AND (`ENGINE`='MyISAM' OR `ENGINE` = 'InnoDB' OR `ENGINE` = 'TokuDB')"
|
||||||
db.LogSQL(s, args)
|
db.LogSQL(s, args)
|
||||||
|
|
||||||
|
@ -420,14 +421,15 @@ func (db *mysql) GetTables() ([]*core.Table, error) {
|
||||||
tables := make([]*core.Table, 0)
|
tables := make([]*core.Table, 0)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
table := core.NewEmptyTable()
|
table := core.NewEmptyTable()
|
||||||
var name, engine, tableRows string
|
var name, engine, tableRows, comment string
|
||||||
var autoIncr *string
|
var autoIncr *string
|
||||||
err = rows.Scan(&name, &engine, &tableRows, &autoIncr)
|
err = rows.Scan(&name, &engine, &tableRows, &autoIncr, &comment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
table.Name = name
|
table.Name = name
|
||||||
|
table.Comment = comment
|
||||||
table.StoreEngine = engine
|
table.StoreEngine = engine
|
||||||
tables = append(tables, table)
|
tables = append(tables, table)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue