Skip to content

Commit

Permalink
fix desc table not compatibile with mysql (#10022)
Browse files Browse the repository at this point in the history
  • Loading branch information
b41sh authored and ngaut committed Apr 4, 2019
1 parent 7f91a1c commit 62b209c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions executor/seqtest/seq_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,11 @@ func (s *seqTestSuite) TestShow(c *C) {
row = result.Rows()[0]
expectedRow = []interface{}{
"t1", "CREATE TABLE `t1` (\n" +
" `c1` tinyint(3) UNSIGNED DEFAULT NULL,\n" +
" `c2` smallint(5) UNSIGNED DEFAULT NULL,\n" +
" `c3` mediumint(8) UNSIGNED DEFAULT NULL,\n" +
" `c4` int(10) UNSIGNED DEFAULT NULL,\n" +
" `c5` bigint(20) UNSIGNED DEFAULT NULL\n" +
" `c1` tinyint(3) unsigned DEFAULT NULL,\n" +
" `c2` smallint(5) unsigned DEFAULT NULL,\n" +
" `c3` mediumint(8) unsigned DEFAULT NULL,\n" +
" `c4` int(10) unsigned DEFAULT NULL,\n" +
" `c5` bigint(20) unsigned DEFAULT NULL\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"}
for i, r := range row {
c.Check(r, Equals, expectedRow[i])
Expand Down Expand Up @@ -557,7 +557,7 @@ func (s *seqTestSuite) TestShow(c *C) {
tk.MustQuery(`show create table t`).Check(testutil.RowsWithSep("|",
"t CREATE TABLE `t` (\n"+
" `id` int(11) NOT NULL,\n"+
" `val` tinyint(10) UNSIGNED ZEROFILL DEFAULT NULL,\n"+
" `val` tinyint(10) unsigned zerofill DEFAULT NULL,\n"+
" PRIMARY KEY (`id`)\n"+
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin"))

Expand Down
4 changes: 2 additions & 2 deletions table/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ const defaultPrivileges = "select,insert,update,references"
func (c *Column) GetTypeDesc() string {
desc := c.FieldType.CompactStr()
if mysql.HasUnsignedFlag(c.Flag) && c.Tp != mysql.TypeBit && c.Tp != mysql.TypeYear {
desc += " UNSIGNED"
desc += " unsigned"
}
if mysql.HasZerofillFlag(c.Flag) && c.Tp != mysql.TypeYear {
desc += " ZEROFILL"
desc += " zerofill"
}
return desc
}
Expand Down
2 changes: 1 addition & 1 deletion table/column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (t *testTableSuite) TestString(c *C) {
col.Collate = mysql.DefaultCollationName
col.Flag |= mysql.ZerofillFlag | mysql.UnsignedFlag | mysql.BinaryFlag | mysql.AutoIncrementFlag | mysql.NotNullFlag

c.Assert(col.GetTypeDesc(), Equals, "tinyint(2) UNSIGNED ZEROFILL")
c.Assert(col.GetTypeDesc(), Equals, "tinyint(2) unsigned zerofill")
col.ToInfo()
tbInfo := &model.TableInfo{}
c.Assert(col.IsPKHandleColumn(tbInfo), Equals, false)
Expand Down

0 comments on commit 62b209c

Please sign in to comment.