keystonejs/keystone-classic

4.0.0-beta5: Export json/csv is broken

Open

#4 229 ouverte le 21 avr. 2017

Voir sur GitHub
 (0 commentaires) (2 réactions) (0 assignés)JavaScript (2 288 forks)batch import
bughelp wanted

Métriques du dépôt

Stars
 (14 656 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

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?

Guide contributeur