moocunsw / ontask3_UNSW

A platform offering teachers and educational designers the capacity to use data to personalise the experience for the learners.
https://ontasklearning.org
6 stars 6 forks source link

No exception handling when adding a datasource primary key not contained in the fields #153

Closed NgoniChoga closed 4 years ago

NgoniChoga commented 5 years ago

As shown in the screenshot below, it is possible to add a primary key that is not one of the fields selected in the table. This leads to a blank screen when attempting to view the table (See error below from the console).

Uncaught (in promise) TypeError: Cannot read property 'details' of undefined
    at t.<anonymous> (Visualisation.js:46)
    at t.type (memoize-one.esm.js:28)
    at t.value (Visualisation.js:429)
    at Pi (react-dom.production.min.js:3785)
    at Ti (react-dom.production.min.js:3776)
    at Li (react-dom.production.min.js:3960)
    at qa (react-dom.production.min.js:5514)
    at Ya (react-dom.production.min.js:5536)
    at Ps (react-dom.production.min.js:5958)
    at Es (react-dom.production.min.js:5925)

Steps to reproduce:

  1. Upload a datasource with more than one column.
  2. Create a datalab, choose a primary key and choose fields, but do not include the primary key as a field.
  3. Save and you get the blank screen. (The datalab was still saved when you navigate back to the dashboard. One can still go into the datalab's settings to fix it by adding the primary key to the fields).

Possible solutions:

  1. Add the primary key as a field automatically. (As soon as a primary key is selected, it becomes a field too).
  2. Add a check before the saving event and throw an exception on the UI if primary key is not part of the fields.

Screen Shot 2019-06-26 at 13 03 47

moocunsw commented 4 years ago

this is also a problem when new datasources are based on another datalab