Skip to content

Commit

Permalink
[add]: support ignore unnamed filed(for table inherit)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxyzl committed Jul 3, 2024
1 parent 56f05af commit 4c2cf2a
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 20 deletions.
4 changes: 2 additions & 2 deletions example/bson/example_bson.model.bson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/bson/example_bson.model.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/common/common.model.bson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/common/common.model.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/nest/example_nest.model.bson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/nest/example_nest.model.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/setter/example_setter.model.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/with_ignore/with_ignore.model.bson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/with_ignore/with_ignore.model.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion gsgen_tools/internal/gen_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"time"
)

const ignoreNameTag = "`in:\"-\"`" //means ignore name, means inherit
const bsonIgnoreTag = "`bson:\"-\"`"
const maxFieldCount = 63

Expand Down Expand Up @@ -223,7 +224,10 @@ func checkStructFieldBase(structName string, structType *ast.StructType, needDir
for _, field := range structType.Fields.List {
if len(field.Names) > 1 { //每行只能定义1个
panic(fmt.Sprintf("类型:%v,每行只能声明1个filed", structName))
} else if len(field.Names) == 0 { //匿名类型必须只能是gsmodel.DirtyModel
} else if len(field.Names) == 0 { //匿名类型必须配置ignoreNameTag或gsmodel.DirtyModel类型
if field.Tag.Value == ignoreNameTag {
continue
}
if !needDirty {
panic(fmt.Sprintf("类型:%v, 非dirty模式下不能有匿名类(dirty模式下则匿名字段必须为gsmodel.DirtyModel类型)", structName))
}
Expand Down
2 changes: 1 addition & 1 deletion gsgen_tools/internal/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package internal

const Version = "1.1.8"
const Version = "1.1.9"

0 comments on commit 4c2cf2a

Please sign in to comment.