Describe the bug
As of right now, the prisma export command produces invalid data when it comes to json(list) fields resulting in an error when trying to import that data somewhere else.
To Reproduce
Steps to reproduce the behavior:
prisma exportprisma importprisma import --data export-2018-09-21T09:00:40.144Z.zip
Unzipping 31ms
Uncaught exception, cleaning up: Error: Value "{\"prop\":\"whatever\",\"label\":\"Label\"}" for field personalDownloads is not a valid Json
Validating data ✖
Expected behavior
The import should work without any hiccups
Versions (please complete the following information):
OS X Mojave& Linux 4.18.8 prisma CLI: prisma/1.16.4 x64 node-v10.11.01.16.0Additional context
Extracting the zip, removing the list contents from the lists folder and compressing everything again fixes the problem.
Quick update, just did some further testing, it looks like the problem lies within the fact that the export creates escaped json strings instead of objects. Removing all the backslashes and superflous quotation marks from the list before zipping everything up again works as expected, with the data being where it belongs.
Current:
{
"valueType": "lists",
"values": [
{
"_typeName": "TName",
"id": "myid",
"field": [
"{\"prop\":\"test_1\",\"label\":\"Test 1\"}",
"{\"prop\":\"test_2\",\"label\":\"Test 2\"}"
]
}
]
}
Working:
{
"valueType": "lists",
"values": [
{
"_typeName": "TName",
"id": "myid",
"field": [
{
"prop": "test_1",
"label": "Test 1"
},
{
"prop": "test_2",
"label": "Test 2"
}
]
}
]
}
Thanks for the follow up. It is my current understanding that this is a mismatch between the output format for JSON values by the backend, and the JSON validation done by the CLI.
Both components should agree on the exact parsing behaviour. I am not sure which is per the spec, and which is not.
The quotes are generated from backend for legacy reasons.
Bringing import/export in sync would be a breaking change but it is important and NDF compliant as NDF does not mention escape quoting for anything.
Thanks for reporting this @luhagel , we just released 1.17.2 which fixes the issue by not stringifying the output anymore.
Most helpful comment
The quotes are generated from backend for legacy reasons.
Bringing import/export in sync would be a breaking change but it is important and NDF compliant as NDF does not mention escape quoting for anything.