This commit is contained in:
Lunny Xiao 2021-08-08 17:20:03 +08:00
parent f1f1b1d92f
commit f8c4a42dc8
2 changed files with 4 additions and 4 deletions

View File

@ -574,7 +574,7 @@ func (db *dameng) SQLType(c *schemas.Column) string {
switch t := c.SQLType.Name; t { switch t := c.SQLType.Name; t {
case schemas.TinyInt, "BYTE": case schemas.TinyInt, "BYTE":
return "TINYINT" return "TINYINT"
case schemas.SmallInt, schemas.MediumInt, schemas.Int, schemas.Integer: case schemas.SmallInt, schemas.MediumInt, schemas.Int, schemas.Integer, schemas.UnsignedTinyInt:
return "INTEGER" return "INTEGER"
case schemas.BigInt, case schemas.BigInt,
schemas.UnsignedBigInt, schemas.UnsignedBit, schemas.UnsignedInt, schemas.UnsignedBigInt, schemas.UnsignedBit, schemas.UnsignedInt,
@ -663,7 +663,7 @@ func (db *dameng) DropTableSQL(tableName string) (string, bool) {
// ModifyColumnSQL returns a SQL to modify SQL // ModifyColumnSQL returns a SQL to modify SQL
func (db *dameng) ModifyColumnSQL(tableName string, col *schemas.Column) string { func (db *dameng) ModifyColumnSQL(tableName string, col *schemas.Column) string {
s, _ := ColumnString(db.dialect, col, false) s, _ := ColumnString(db.dialect, col, false)
return fmt.Sprintf("ALTER TABLE %s MODIFY %s", tableName, s) return fmt.Sprintf("ALTER TABLE %s MODIFY %s", db.quoter.Quote(tableName), s)
} }
func (db *dameng) CreateTableSQL(ctx context.Context, queryer core.Queryer, table *schemas.Table, tableName string) (string, bool, error) { func (db *dameng) CreateTableSQL(ctx context.Context, queryer core.Queryer, table *schemas.Table, tableName string) (string, bool, error) {

View File

@ -507,7 +507,7 @@ func TestUnsignedTinyInt(t *testing.T) {
assert.EqualValues(t, 1, len(tables[0].Columns())) assert.EqualValues(t, 1, len(tables[0].Columns()))
switch testEngine.Dialect().URI().DBType { switch testEngine.Dialect().URI().DBType {
case schemas.SQLITE: case schemas.SQLITE, schemas.DAMENG:
assert.EqualValues(t, "INTEGER", tables[0].Columns()[0].SQLType.Name) assert.EqualValues(t, "INTEGER", tables[0].Columns()[0].SQLType.Name)
case schemas.MYSQL: case schemas.MYSQL:
assert.EqualValues(t, "UNSIGNED TINYINT", tables[0].Columns()[0].SQLType.Name) assert.EqualValues(t, "UNSIGNED TINYINT", tables[0].Columns()[0].SQLType.Name)
@ -516,7 +516,7 @@ func TestUnsignedTinyInt(t *testing.T) {
case schemas.MSSQL: case schemas.MSSQL:
assert.EqualValues(t, "INT", tables[0].Columns()[0].SQLType.Name) assert.EqualValues(t, "INT", tables[0].Columns()[0].SQLType.Name)
default: default:
assert.False(t, true, "Unsigned is not implemented") assert.False(t, true, fmt.Sprintf("Unsigned is not implemented, returned %s", tables[0].Columns()[0].SQLType.Name))
} }
cnt, err := testEngine.Insert(&MyUnsignedTinyIntStruct{ cnt, err := testEngine.Insert(&MyUnsignedTinyIntStruct{