Hi.
We’re migrating from forest-express-sequelize
to @forestadmin/agent
.
We have a Sequelize model with a field defined as follows:
showCrew: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: true,
field: 'show_crew',
},
With the previous agent filed this used to be translated in the .forestadmin-schema.json
file as:
{
"field": "showCrew",
"type": "Boolean",
"defaultValue": true,
"enums": null,
"integration": null,
"isFilterable": true,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": true, <<<<<<<<<<
"isSortable": true,
"isVirtual": false,
"reference": null,
"inverseOf": null,
"validations": [{ <<<<<<<<<<
"message": null,
"type": "is present",
"value": null
}]
}
With the new agent, this is what we see in the .forestadmin-schema.json
file for the very same field:
{
"defaultValue": true,
"enums": [],
"field": "showCrew",
"integration": null,
"inverseOf": null,
"isFilterable": true,
"isPrimaryKey": false,
"isReadOnly": false,
"isRequired": false, <<<<<<<<<<
"isSortable": true,
"isVirtual": false,
"reference": null,
"type": "Boolean",
"validations": [] <<<<<<<<<<
},
The problem here is that with the new agent the “not null” validation is lost (see the lines highlighted by arrows in the above code fragments).
As far as I can tell, with the new agent, whenever we have a field which is not null with a default value in our models, this problem arises.
We’re not sure, but maybe this is due to this code in the agent:
NB: this used to work correctly, instead, with the previous agent version.
May you please have a check?
Thank you.
Matteo