keystonejs/keystone-classic

4.0.0-beta5: Export json/csv is broken

Open

#4229 aperta il 21 apr 2017

Vedi su GitHub
 (0 commenti) (2 reazioni) (0 assegnatari)JavaScript (2288 fork)batch import
bughelp wanted

Metriche repository

Star
 (14.656 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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?

Guida contributor