Sequelize.INTEGER field value passed (from Forest) as a string

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 :innocent:

Hi @Matteo,

Thank you for sharing your issue with the ForestAdmin community!

I’ve been able to reproduce your issue and I’ll dig this up to found the reason of it.

1 Like

Hi @anon37102731
Thank you in advance! :slight_smile:

Matteo

Hi @Matteo,

A fix should have been released this morning!

Feel free to reach out if you find any other other issues.

1 Like

Hi @anon37102731.
Now everithing looks fine and the very same check returns the expected type. The log now says this is the value type: number.

Yesterday a also noticed that there was a problem with frontend validations: if I entered a string in an INTEGER field, the html input became red-bordered, but the form submitted without errors. As far as Ii can see, now the expected behavior is restored.

Screenshot 2020-06-10 at 10.06.24

:+1:

Thank you!