From 1b603bfd93ae08b36e2fe3eb6977ab9c0f92d685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 14 Jan 2022 18:34:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE=E9=9D=9Edd?= =?UTF-8?q?l=20sql,=20panixc=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tool/sql2go/parser.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tool/sql2go/parser.go b/tool/sql2go/parser.go index 6cbb3a0..8c0b203 100644 --- a/tool/sql2go/parser.go +++ b/tool/sql2go/parser.go @@ -8,6 +8,7 @@ package sql2go import ( + "errors" "strings" "git.zhangdeman.cn/zhangdeman/gopkg/util" @@ -54,7 +55,10 @@ func ParseCreateTableSql(sql string) (string, *BasicTableInfo, error) { return "", nil, err } - r := stmt.(*sqlparser.DDL) + r, ok := stmt.(*sqlparser.DDL) + if !ok { + return "", nil, errors.New("input sql is not ddl") + } basic.TableName = sqlparser.String(r.NewName) basic.ModelStruct = util.SnakeCaseToCamel(basic.TableName) structResult := "type " + basic.ModelStruct + " struct { \n"