SoftwareBrothers / adminjs-sequelizejs

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

fix: remove check for auto increment on isId/isEditable #64

Closed leibowitz closed 2 years ago

leibowitz commented 3 years ago

Currently if a table has a primary key (ID) without the auto-increment attribute, AdminBro – and this sequelize adapter – will not allow to edit that field.

Trying to show the attribute in the creation and edit form will fail, as all primary keys are currently marked as non editable.

This PR changes the behaviour, but keep backward compatibility for any primary key with auto-increment set.

If instead the auto-increment is not set on the primary key, then the field will automatically appear and become editable. Which is what anyone would expect AFAIK, as otherwise trying to insert a record (without being able to specify the value of the field) will throw an error.

Fix https://github.com/SoftwareBrothers/admin-bro/issues/544

ludovicraymond commented 2 years ago

Hello.

Any news about that ?

dziraf commented 2 years ago

All of our adapters make primary key fields not editable by default. You should be able to override this behaviour by explicitly making the field visible in resource options. If you need to set a value for primary key which is not autogenerated, you can use a combination of before hook and i. e. a uuid library.