Repository: tableauio/tableau
Pull request #153 (2024-09-30 09:02:32)

xml: fix an error where field options don't work on incell scalar lists

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/tableauio/tableau/pull/153?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tableauio) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 64.80%. Comparing base [(`92484b7`)](https://app.codecov.io/gh/tableauio/tableau/commit/92484b73a3d77b21acdba845a947bca1ed774e14?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tableauio) to head [(`ce4b149`)](https://app.codecov.io/gh/tableauio/tableau/commit/ce4b149d05aa2e7cfac156160fae0215319c22bd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tableauio).

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master     #153   +/-   ##
=======================================
  Coverage   64.80%   64.80%           
=======================================
  Files          69       69           
  Lines        7597     7597           
=======================================
  Hits         4923     4923           
  Misses       2100     2100           
  Partials      574      574           
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/tableauio/tableau/pull/153?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tableauio).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tableauio).


Patch:
diff --git a/internal/importer/xml.go b/internal/importer/xml.go
index 2cca61d..88d1e55 100644
--- a/internal/importer/xml.go
+++ b/internal/importer/xml.go
@@ -485,7 +485,7 @@ func parseXMLAttribute(bnode *book.Node, attrName, attrValue string, isFirstAttr
 						Children: []*book.Node{
 							{
 								Name:  book.KeywordType,
-								Value: fmt.Sprintf("[%s]", desc.ColumnType),
+								Value: attrValue,
 							},
 							{
 								Name:  book.KeywordVariable,


Test patch:
diff --git a/test/functest/conf/base/XmlPatchConf.json b/test/functest/conf/base/XmlPatchConf.json
index c48d573..51afdbf 100644
--- a/test/functest/conf/base/XmlPatchConf.json
+++ b/test/functest/conf/base/XmlPatchConf.json
@@ -11,6 +11,11 @@
         2,
         3
     ],
+    "incellScalarListList": [
+        4,
+        5,
+        6
+    ],
     "structListList": [
         {
             "id": 1,
diff --git a/test/functest/conf/test/XmlPatchConf.json b/test/functest/conf/test/XmlPatchConf.json
index 62422d3..e3346ad 100644
--- a/test/functest/conf/test/XmlPatchConf.json
+++ b/test/functest/conf/test/XmlPatchConf.json
@@ -5,6 +5,11 @@
         20,
         30
     ],
+    "incellScalarListList": [
+        40,
+        50,
+        60
+    ],
     "structListList": [
         {
             "id": 10,
diff --git a/test/functest/proto/xml__patch__base__env.proto b/test/functest/proto/xml__patch__base__env.proto
index aa4cfa7..16cb157 100644
--- a/test/functest/proto/xml__patch__base__env.proto
+++ b/test/functest/proto/xml__patch__base__env.proto
@@ -24,13 +24,14 @@ message XmlPatchConf {
     google.protobuf.Duration expiry = 4 [(tableau.field) = {name:"Expiry"}];
   }
   repeated int32 scalar_list_list = 3 [(tableau.field) = {name:"ScalarList" prop:{patch:PATCH_REPLACE}}];
-  repeated Animal struct_list_list = 4 [(tableau.field) = {name:"StructList"}];
+  repeated int32 incell_scalar_list_list = 4 [(tableau.field) = {name:"IncellScalarList" layout:LAYOUT_INCELL prop:{patch:PATCH_REPLACE}}];
+  repeated Animal struct_list_list = 5 [(tableau.field) = {name:"StructList"}];
   message Animal {
     uint32 id = 1 [(tableau.field) = {name:"ID"}];
     string name = 2 [(tableau.field) = {name:"Name"}];
   }
-  map<uint32, string> scalar_map_map = 5 [(tableau.field) = {name:"ScalarMap" layout:LAYOUT_INCELL prop:{patch:PATCH_REPLACE}}];
-  map<uint32, Item> struct_map_map = 6 [(tableau.field) = {name:"StructMap" key:"key"}];
+  map<uint32, string> scalar_map_map = 6 [(tableau.field) = {name:"ScalarMap" layout:LAYOUT_INCELL prop:{patch:PATCH_REPLACE}}];
+  map<uint32, Item> struct_map_map = 7 [(tableau.field) = {name:"StructMap" key:"key"}];
   message Item {
     uint32 key = 1 [(tableau.field) = {name:"key"}];
     string name = 2 [(tableau.field) = {name:"Name"}];
diff --git a/test/functest/testdata/xml/patch/base/Env.xml b/test/functest/testdata/xml/patch/base/Env.xml
index 5517b50..378d3cb 100644
--- a/test/functest/testdata/xml/patch/base/Env.xml
+++ b/test/functest/testdata/xml/patch/base/Env.xml
@@ -7,6 +7,7 @@
   <Env>string</Env>
   <StrictStruct ID="{Fruit}uint32" Name="string" Start="datetime" Expiry="duration" />
   <ScalarList>[int32]|{patch:PATCH_REPLACE}</ScalarList>
+  <IncellScalarList>[]int32|{patch:PATCH_REPLACE}</IncellScalarList>
   <StructList ID="[Animal]uint32" Name="string" />
   <ScalarMap>map<uint32, string>|{patch:PATCH_REPLACE}</ScalarMap>
   <StructMap key="map<uint32, Item>" Name="string" Num="int32" />
@@ -19,6 +20,7 @@
   <ScalarList>1</ScalarList>
   <ScalarList>2</ScalarList>
   <ScalarList>3</ScalarList>
+  <IncellScalarList>4,5,6</IncellScalarList>
   <StructList ID="1" Name="dog" />
   <StructList ID="2" Name="bird" />
   <ScalarMap>1:dog,2:bird,3:cat</ScalarMap>
diff --git a/test/functest/testdata/xml/patch/overlays/test/Env.xml b/test/functest/testdata/xml/patch/overlays/test/Env.xml
index aa939c3..1e8f972 100644
--- a/test/functest/testdata/xml/patch/overlays/test/Env.xml
+++ b/test/functest/testdata/xml/patch/overlays/test/Env.xml
@@ -4,6 +4,7 @@
   <ScalarList>10</ScalarList>
   <ScalarList>20</ScalarList>
   <ScalarList>30</ScalarList>
+  <IncellScalarList>40,50,60</IncellScalarList>
   <StructList ID="10" Name="snake" />
   <StructList ID="20" Name="python" />
 </XmlPatchConf>