From c7d75625051e94c42295023d84c7902a49e7138f Mon Sep 17 00:00:00 2001 From: thinkgo Date: Wed, 27 Dec 2023 18:02:49 +0800 Subject: [PATCH] fix: fix seaql bug --- internal/protoseaql/seaql.go | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/internal/protoseaql/seaql.go b/internal/protoseaql/seaql.go index 576a51c..a3463db 100644 --- a/internal/protoseaql/seaql.go +++ b/internal/protoseaql/seaql.go @@ -89,22 +89,23 @@ func IntoTable(protoMessages []*protogen.Message) ([]Table, error) { var foreignKey []string annotates, remainComments := protoutil.NewCommentLines(pe.Comments.Leading).FindAnnotation(annotation_Path) - if len(annotates) > 0 { - for _, v := range annotates { - switch v.Key { - case annotation_Key_Name: - tableName = v.Value - case annotation_Key_Engine: - engine = v.Value - case annotation_Key_Charset: - charset = v.Value - case annotation_Key_Collate: - collate = v.Value - case annotation_Key_Index: - indexes = append(indexes, v.Value) - case annotation_Key_ForeignKey: - foreignKey = append(foreignKey, v.Value) - } + if len(annotates) == 0 { + continue + } + for _, v := range annotates { + switch v.Key { + case annotation_Key_Name: + tableName = v.Value + case annotation_Key_Engine: + engine = v.Value + case annotation_Key_Charset: + charset = v.Value + case annotation_Key_Collate: + collate = v.Value + case annotation_Key_Index: + indexes = append(indexes, v.Value) + case annotation_Key_ForeignKey: + foreignKey = append(foreignKey, v.Value) } } comment := strings.TrimSpace(strings.TrimPrefix(remainComments.LineString(), rawTableName))