MCPcopy Index your code
hub / github.com/go-dev-frame/sponge / TestParseMysqlSQL

Function TestParseMysqlSQL

pkg/sql2code/parser/parser_test.go:13–29  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func 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
31func TestParseSQL(t *testing.T) {
32 sqls := []string{`create table user (

Callers

nothing calls this directly

Calls 4

ParseSQLFunction · 0.85
WithJSONTagFunction · 0.85
WithDBDriverFunction · 0.85
printCodeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…