keystonejs/keystone-classic

4.0.0-beta5: Export json/csv is broken

Open

#4229 opened on Apr 21, 2017

View on GitHub
 (0 comments) (2 reactions) (0 assignees)JavaScript (14,656 stars) (2,288 forks)batch import
bughelp wanted

Description

Expected behavior

Exception is thrown:

web_1    | Mongoose model 'error' event fired on 'Post' with error:
web_1    |  List.getData: fields must be undefined, a string, or an array. Error: List.getData: fields must be undefined, a string, or an array.
web_1    |     at keystone.List.getData (/opt/app/node_modules/keystone/lib/list/getData.js:23:10)
....

Steps to reproduce the actual/current behavior

  1. Go to a list in admin ui
  2. chose export
  3. select a few fields

Suggested fix

The admin UI sends the query param select with the fields to export as a comma separated string, while /lib/list/getData.js expects fields to be an array. This leaves to options to fix the issue:

  1. Patch admin UI, modify /admin/client/utils/List.js#getDownloadURL stringify the query so that it gets parsed by the express servers querystring parser correctly.
  2. Split fields into an array if its a string in /lib/list/getData.js

What's your preference? Are you using comma separated query strings elsewhere?

Contributor guide