Skip to content

Commit

Permalink
Fix export for non-string array values (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulineribeyre authored Nov 2, 2021
1 parent 5755265 commit e3e6d6c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": null,
"lines": null
},
"generated_at": "2021-08-19T20:25:38Z",
"generated_at": "2021-11-01T21:39:46Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -166,7 +166,7 @@
{
"hashed_secret": "78b4db9b2aec0f0f2d3e38f9278be42b861c9dc3",
"is_verified": false,
"line_number": 1424,
"line_number": 1473,
"type": "Hex High Entropy String"
}
],
Expand Down
4 changes: 2 additions & 2 deletions sheepdog/utils/transforms/graph_to_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def list_to_comma_string(val, file_format):
Handle array fields by converting them to a comma-separated string.
Example:
['1','2','3'] -> 1,2,3
['1','2','3'] -> '1,2,3'
"""

if val is None:
Expand All @@ -167,7 +167,7 @@ def list_to_comma_string(val, file_format):
return ""

if isinstance(val, list):
val = ",".join(val)
val = ",".join((str(x) for x in val))
return val


Expand Down
5 changes: 5 additions & 0 deletions tests/integration/datadict/submission/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from sheepdog.transactions.upload import UploadTransaction
from sheepdog.utils import get_external_proxies
from sheepdog.utils.transforms import TSVToJSONConverter
from sheepdog.utils.transforms.graph_to_doc import list_to_comma_string
from tests.integration.datadict.submission.utils import (
data_fnames,
extended_data_fnames,
Expand Down Expand Up @@ -819,6 +820,10 @@ def test_export_all_node_types(
do_test_export(client, pg_driver, submitter, "experimental_metadata", "tsv")


def test_export_non_string_array_values():
assert list_to_comma_string(["string", 1, 0.5, True], "tsv") == "string,1,0.5,True"


def test_export_all_node_types_and_resubmit_json(
client, pg_driver, cgci_blgsp, submitter, require_index_exists_off
):
Expand Down

0 comments on commit e3e6d6c

Please sign in to comment.