Skip to content

Commit

Permalink
fix: do not check package name in func parseFieldOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
wenchy committed Mar 13, 2024
1 parent 74ea52c commit 7fb5ed5
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 9 deletions.
6 changes: 0 additions & 6 deletions internal/confgen/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/tableauio/tableau/internal/importer/book"
"github.com/tableauio/tableau/internal/types"
"github.com/tableauio/tableau/internal/xproto"
"github.com/tableauio/tableau/log"
"github.com/tableauio/tableau/options"
"github.com/tableauio/tableau/proto/tableaupb"
"github.com/tableauio/tableau/xerrors"
Expand Down Expand Up @@ -341,13 +340,8 @@ func (sp *sheetParser) Parse(protomsg proto.Message, sheet *book.Sheet) error {
// parseFieldOptions is aimed to parse the options of all the fields of a protobuf message.
func (sp *sheetParser) parseFieldOptions(msg protoreflect.Message, rc *book.RowCells, prefix string) (present bool, err error) {
md := msg.Descriptor()
pkg := md.ParentFile().Package()
for i := 0; i < md.Fields().Len(); i++ {
fd := md.Fields().Get(i)
if string(pkg) != sp.ProtoPackage && pkg != "google.protobuf" {
log.Debugf("no need to process package: %v", pkg)
return false, nil
}
err := func() error {
field := parseFieldDescriptor(fd, sp.opts.Sep, sp.opts.Subsep)
defer field.release()
Expand Down
28 changes: 28 additions & 0 deletions test/functest/conf/PredefinedCrossCellStruct.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"itemMap": {
"1": {
"id": 1,
"prop": {
"id": 1,
"name": "Apple",
"desc": "A kind of delicious fruit."
}
},
"2": {
"id": 2,
"prop": {
"id": 2,
"name": "Orange",
"desc": ""
}
},
"3": {
"id": 3,
"prop": {
"id": 3,
"name": "",
"desc": ""
}
}
}
}
10 changes: 10 additions & 0 deletions test/functest/proto/excel__struct__struct.proto
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ message InCellStruct {
}
}

message PredefinedCrossCellStruct {
option (tableau.worksheet) = {name:"PredefinedCrossCellStruct" namerow:1 typerow:2 noterow:3 datarow:4};

map<uint32, Item> item_map = 1 [(tableau.field) = {key:"ID" layout:LAYOUT_VERTICAL}];
message Item {
uint32 id = 1 [(tableau.field) = {name:"ID"}];
base.Property prop = 2 [(tableau.field) = {name:"Prop"}];
}
}

message PredefinedInCellStruct {
option (tableau.worksheet) = {name:"PredefinedInCellStruct" namerow:1 typerow:2 noterow:3 datarow:4};

Expand Down
6 changes: 3 additions & 3 deletions test/functest/testdata/excel/metasheet/BookAlias#@TABLEAU.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Sheet,Alias
#,AliasedWorkbook
Scalar,AliasedSheetScalar,
Sheet,Alias
#,AliasedWorkbook
Scalar,AliasedSheetScalar
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ID,PropID,PropName,PropDesc
"map<uint32, Item>",{base.Property}int32,string,string
Item's ID,Property ID,Property name,Property desc
1,1,Apple,A kind of delicious fruit.
2,2,Orange,
3,3,,

0 comments on commit 7fb5ed5

Please sign in to comment.