beego / bee

Bee is a tool for helping develop with beego app framework.
Apache License 2.0
1.45k stars 922 forks source link

fix issues #730 bee generate appcode [index out of range [2] with length 0] #743

Closed 1920853199 closed 3 years ago

1920853199 commented 3 years ago
SELECT column_name, data_type, column_type, is_nullable, column_default, extra, column_comment FROM information_schema.columns WHERE table_schema = database() AND table_name = ?;

The results of mysql 8.0

mysql> SELECT column_name, data_type, column_type, is_nullable, column_default, extra, column_comment FROM information_schema.columns WHERE table_schema = database() AND table_name = 'article';
+-------------+-----------+--------------+-------------+----------------+----------------+----------------------------------------+
| COLUMN_NAME | DATA_TYPE | COLUMN_TYPE  | IS_NULLABLE | COLUMN_DEFAULT | EXTRA          | COLUMN_COMMENT                         |
+-------------+-----------+--------------+-------------+----------------+----------------+----------------------------------------+
| id          | int       | int          | NO          | NULL           | auto_increment | ID                                     |
| user_id     | int       | int          | YES         | 0              |                | 用户ID                                 |
| title       | varchar   | varchar(255) | NO          |                |                | 标题                                   |
| category_id | int       | int          | NO          | NULL           |                | 分类ID                                 |
| tag         | varchar   | varchar(255) | NO          |                |                | Tag                                    |
| remark      | varchar   | varchar(500) | NO          |                |                | 摘要                                   |
| desc        | longtext  | longtext     | NO          | NULL           |                | 详情                                   |
| html        | longtext  | longtext     | NO          | NULL           |                | html                                   |
| pv          | int       | int          | YES         | 0              |                | px                                     |
| created     | datetime  | datetime     | YES         | NULL           |                | 创建时间                               |
| updated     | datetime  | datetime     | YES         | NULL           |                | 更新时间                               |
| status      | int       | int          | YES         | 1              |                | 1可用,2禁用,3删除                    |
| review      | int       | int          | YES         | 0              |                | 评论                                   |
| recommend   | int       | int          | NO          | 0              |                | 是否顶置,0否;1是,默认否             |
| like        | int       | int          | NO          | 0              |                | 点赞数量                               |
| cover       | varchar   | varchar(255) | YES         | NULL           |                |                                        |
| url         | varchar   | varchar(255) | YES         | NULL           |                |                                        |
| other       | longtext  | longtext     | YES         | NULL           |                |                                        |
+-------------+-----------+--------------+-------------+----------------+----------------+----------------------------------------+

The results of mysql 5.7

mysql> SELECT column_name, data_type, column_type, is_nullable, column_default, extra, column_comment FROM information_schema.columns WHERE table_schema = database() AND table_name = 'article';
+-------------+-----------+--------------+-------------+----------------+----------------+----------------------------------------+
| column_name | data_type | column_type  | is_nullable | column_default | extra          | column_comment                         |
+-------------+-----------+--------------+-------------+----------------+----------------+----------------------------------------+
| id          | int       | int(11)      | NO          | NULL           | auto_increment | ID                                     |
| user_id     | int       | int(11)      | YES         | 0              |                | 用户ID                                 |
| title       | varchar   | varchar(255) | NO          |                |                | 标题                                   |
| category_id | int       | int(11)      | NO          | NULL           |                | 分类ID                                 |
| tag         | varchar   | varchar(255) | NO          |                |                | Tag                                    |
| remark      | varchar   | varchar(500) | NO          |                |                | 摘要                                   |
| desc        | longtext  | longtext     | NO          | NULL           |                | 详情                                   |
| html        | longtext  | longtext     | YES         | NULL           |                | html                                   |
| pv          | int       | int(255)     | YES         | 0              |                | px                                     |
| created     | datetime  | datetime     | YES         | NULL           |                | 创建时间                               |
| updated     | datetime  | datetime     | YES         | NULL           |                | 更新时间                               |
| status      | int       | int(11)      | YES         | 1              |                | 1可用,2禁用,3删除                    |
| review      | int       | int(11)      | YES         | 0              |                | 评论                                   |
| recommend   | int       | int(4)       | NO          | 0              |                | 是否顶置,0否;1是,默认否             |
| like        | int       | int(11)      | NO          | 0              |                | 点赞数量                               |
+-------------+-----------+--------------+-------------+----------------+----------------+----------------------------------------+
15 rows in set (0.00 sec)

If the 'column' is of type 'int', 'column_type' returns a different form in 5. and 8.