(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestParseMysqlSQL(t *testing.T) { |
| 14 | sql := `CREATE TABLE orders ( |
| 15 | order_id bigint NOT NULL AUTO_INCREMENT COMMENT 'order id', |
| 16 | user_id bigint NOT NULL COMMENT 'user id', |
| 17 | total_amount decimal(10,2) NOT NULL COMMENT 'total amount', |
| 18 | order_remark json NOT NULL COMMENT 'order remark', |
| 19 | order_status ENUM('Pending Payment', 'Paid', 'Shipped', 'Completed', 'Cancelled') NOT NULL DEFAULT 'active' COMMENT 'order status', |
| 20 | pay_type SET('Alipay', 'WeChat Pay', 'Bank Card') NOT NULL DEFAULT '' COMMENT 'pay type', |
| 21 | is_deleted bit(1) NOT NULL DEFAULT b'0' COMMENT '0-no,1-yes', |
| 22 | created_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'created time' |
| 23 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='orders table';` |
| 24 | |
| 25 | codes, err := ParseSQL(sql, WithJSONTag(1), WithDBDriver(DBDriverMysql)) |
| 26 | assert.Nil(t, err) |
| 27 | assert.NotEmpty(t, codes) |
| 28 | printCode(codes) |
| 29 | } |
| 30 | |
| 31 | func TestParseSQL(t *testing.T) { |
| 32 | sqls := []string{`create table user ( |
nothing calls this directly
no test coverage detected
searching dependent graphs…