-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explicit headings in CSV export #23140
Conversation
🦋 Changeset detectedLatest commit: 22f71f5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed and tested and seems to working as expected ✅
Scope
Currently when exporting a collection to CSV, the headings of the file were deducted from the first batch of the query result. In case the user choose to include relational data in the export and the first batch of items did not include any relational data, the headings did not exist and therefore the
json2scv
library put the values in the wrong 'column'.In this PR, the field names which should be exported and hence the headings of the csv file, are determined beforehand instead of deducting those from the first batch.
An example
EXPORT_BATCH_SIZE
of 10Before
For the first batch, the author is always null. When deducting the headings this way, no
first_name
column is present in the export. For the second batch though, this value existed in the database response and was added in the CSV file in the wrong place. within the author column there should be the ID, and "Jan" should be in a column which doesn't exit.After
With the fields specified explicitly, the columns of the export did not rely on the first batch result anymore. This way the shifting could be eliminated.
NOTE: I could not test it with the dataset provided in the linked issue, since this is a dump from v10.
Fixes #22298