Skip to content

Commit e3e6d6c

Browse files
Fix export for non-string array values (#360)
1 parent 5755265 commit e3e6d6c

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

.secrets.baseline

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": null,
44
"lines": null
55
},
6-
"generated_at": "2021-08-19T20:25:38Z",
6+
"generated_at": "2021-11-01T21:39:46Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -166,7 +166,7 @@
166166
{
167167
"hashed_secret": "78b4db9b2aec0f0f2d3e38f9278be42b861c9dc3",
168168
"is_verified": false,
169-
"line_number": 1424,
169+
"line_number": 1473,
170170
"type": "Hex High Entropy String"
171171
}
172172
],

sheepdog/utils/transforms/graph_to_doc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def list_to_comma_string(val, file_format):
157157
Handle array fields by converting them to a comma-separated string.
158158
159159
Example:
160-
['1','2','3'] -> 1,2,3
160+
['1','2','3'] -> '1,2,3'
161161
"""
162162

163163
if val is None:
@@ -167,7 +167,7 @@ def list_to_comma_string(val, file_format):
167167
return ""
168168

169169
if isinstance(val, list):
170-
val = ",".join(val)
170+
val = ",".join((str(x) for x in val))
171171
return val
172172

173173

tests/integration/datadict/submission/test_endpoints.py

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from sheepdog.transactions.upload import UploadTransaction
2222
from sheepdog.utils import get_external_proxies
2323
from sheepdog.utils.transforms import TSVToJSONConverter
24+
from sheepdog.utils.transforms.graph_to_doc import list_to_comma_string
2425
from tests.integration.datadict.submission.utils import (
2526
data_fnames,
2627
extended_data_fnames,
@@ -819,6 +820,10 @@ def test_export_all_node_types(
819820
do_test_export(client, pg_driver, submitter, "experimental_metadata", "tsv")
820821

821822

823+
def test_export_non_string_array_values():
824+
assert list_to_comma_string(["string", 1, 0.5, True], "tsv") == "string,1,0.5,True"
825+
826+
822827
def test_export_all_node_types_and_resubmit_json(
823828
client, pg_driver, cgci_blgsp, submitter, require_index_exists_off
824829
):

0 commit comments

Comments
 (0)