diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-06-16 04:46:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-15 16:46:01 -0400 |
commit | cdef92b3ffc7dcbc0f4ee26f7f973ca2b28fea61 (patch) | |
tree | 0bf6d1d054affe3dd04daaa92e35fa1e50d8ade1 /vendor/xorm.io/xorm/dialects/mysql.go | |
parent | 492b7d63576cc18c5de70cb0fa061b97d67bf227 (diff) | |
download | gitea-cdef92b3ffc7dcbc0f4ee26f7f973ca2b28fea61.tar.gz gitea-cdef92b3ffc7dcbc0f4ee26f7f973ca2b28fea61.zip |
Upgrade xorm to v1.0.2 (#11900)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'vendor/xorm.io/xorm/dialects/mysql.go')
-rw-r--r-- | vendor/xorm.io/xorm/dialects/mysql.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/vendor/xorm.io/xorm/dialects/mysql.go b/vendor/xorm.io/xorm/dialects/mysql.go index 289e0ec7e8..f9a2e9434d 100644 --- a/vendor/xorm.io/xorm/dialects/mysql.go +++ b/vendor/xorm.io/xorm/dialects/mysql.go @@ -162,7 +162,11 @@ var ( "ZEROFILL": true, } - mysqlQuoter = schemas.Quoter{'`', '`', schemas.AlwaysReserve} + mysqlQuoter = schemas.Quoter{ + Prefix: '`', + Suffix: '`', + IsReserved: schemas.AlwaysReserve, + } ) type mysql struct { @@ -293,8 +297,8 @@ func (db *mysql) IsTableExist(queryer core.Queryer, ctx context.Context, tableNa func (db *mysql) AddColumnSQL(tableName string, col *schemas.Column) string { quoter := db.dialect.Quoter() - sql := fmt.Sprintf("ALTER TABLE %v ADD %v", quoter.Quote(tableName), - db.String(col)) + s, _ := ColumnString(db, col, true) + sql := fmt.Sprintf("ALTER TABLE %v ADD %v", quoter.Quote(tableName), s) if len(col.Comment) > 0 { sql += " COMMENT '" + col.Comment + "'" } @@ -304,7 +308,8 @@ func (db *mysql) AddColumnSQL(tableName string, col *schemas.Column) string { func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName string) ([]string, map[string]*schemas.Column, error) { args := []interface{}{db.uri.DBName, tableName} s := "SELECT `COLUMN_NAME`, `IS_NULLABLE`, `COLUMN_DEFAULT`, `COLUMN_TYPE`," + - " `COLUMN_KEY`, `EXTRA`,`COLUMN_COMMENT` 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` = ?" + + " ORDER BY `INFORMATION_SCHEMA`.`COLUMNS`.ORDINAL_POSITION" rows, err := queryer.QueryContext(ctx, s, args...) if err != nil { @@ -525,11 +530,8 @@ func (db *mysql) CreateTableSQL(table *schemas.Table, tableName string) ([]strin for _, colName := range table.ColumnsSeq() { col := table.GetColumn(colName) - if col.IsPrimaryKey && len(pkList) == 1 { - sql += db.String(col) - } else { - sql += db.StringNoPk(col) - } + s, _ := ColumnString(db, col, col.IsPrimaryKey && len(pkList) == 1) + sql += s sql = strings.TrimSpace(sql) if len(col.Comment) > 0 { sql += " COMMENT '" + col.Comment + "'" |