SoftwareBrothers / adminjs-sequelizejs

Sequelizejs adapter for AdminBro
MIT License
27 stars 34 forks source link

Postgres JSONB column is defaulted to an odd value in "new" action #43

Closed dziraf closed 4 years ago

dziraf commented 4 years ago

Describe the bug After updating admin-bro from 2.4.1 to 2.8.0 and admin-bro-sequelize from 0.4.0 to 0.5.1 there is an issue with JSONB fields when adding new resources via "new" action.

The default value described in Sequelize model id a JSON: { ".": "." }, but the record that's inserted into the database is set to [["."]] which causes issues when frontend expects an actual object.

Installed libraries and their versions

To Reproduce Steps to reproduce the behavior:

  1. Create a Sequelize model with a JSONB field having a default value i. e. as described above ({ ".": "." }) and add the resource to AdminBro.
  2. Navigate to the resource in admin, press "New" and fill in required fields (note: the JSONB field is not a part of the form)
  3. Submit the form.
  4. Check what's actually inserted into the database, the value for JSONB field will be [["."]]

Expected behavior The default value from Sequelize model is inserted, or an empty JSON object.

wojtek-krysiak commented 4 years ago

@dziraf I think this is fixed in the latest admin-bro (core package): v3.2.3