Expected behavior
I’m embedding Forest Admin into my existing project, based upon Express and Sequelize.
I have a Sequelize model.
The sequelize model has some fields.
One of the fields is declared as an INTEGER
Sequelize type.
When I create a new record for this model in Forest Admin and I input a nember (eg: 0
) in the form field related to the INTEGER
field, the typeof
of the value is supposed to be number
.
Actual behavior
The typeof
of the value is string
.
Failure Logs
This is the relevant part of my model:
// ...
testField: {
type: DataTypes.INTEGER,
field: 'test_field',
allowNull: false,
defaultValue: 0,
validate: {
justTest(value) {
console.log('this is the value type:', typeof value)
},
},
},
// ...
In our integration test we do:
// ...
await TestModel.create({
// ...
testField: 100,
// ...
})
// ...
And this is what we see in the logs:
this is the value type: number
But when I create the new record from Forest Admin, this is what I see in my logs:
this is the value type: string
Context
Package versions quoted from my package.json
:
- Package Version:
"forest-express-sequelize": "^6.1.4"
- Express Version:
"express": "~4.17.1"
- Sequelize Version:
"sequelize": "^5.21.9"
- Database Dialect: Sequelize
- Database Version:
postgres (PostgreSQL) 12.2
- Project Name: Sailsquare
EDIT
I updated the dependency versions list to correct a copy’n’paste typo in Sequelize version