Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean values not parsed properly to integer fields for MySQL #10633

Closed
nicolaspfernandes opened this issue Mar 27, 2019 · 7 comments
Closed
Labels

Comments

@nicolaspfernandes
Copy link

nicolaspfernandes commented Mar 27, 2019

What are you doing?

isPublic: {type: DataTypes.BOOLEAN, allowNull: false, defaultValue: false}

// ---------
// Later on...

Model.create({key1: 'value1', key2: 'value2'})
//or...
Model.create({key1: 'value1', key2: 'value2', isPublic: true})

What do you expect to happen?

Record being created into the database with a proper converted default value to 0 or 1, since MySQL uses TINYINT(1) as the column type for boolean fields.

What is actually happening?

SequelizeDatabaseError: Incorrect integer value: 'false' for column 'isPublic' at row 1
SequelizeDatabaseError: Incorrect integer value: 'true' for column 'isPublic' at row 1

Dialect: mysql
Dialect version: 2.6.0
Database version: 8.0.15
Sequelize version: 5.2.1
Tested with latest release: Yes

@gabegorelick
Copy link
Contributor

See #10600

@sushantdhiman
Copy link
Contributor

🎉 This issue has been resolved in version 5.2.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nicolasgramlich
Copy link

Note if this helps anyone. I was still getting that error after upgrading from from 4.42.0 to 5.6.0. It resolved itself after also upgrading mysql2 from 1.4.2 to 1.6.5 and a fresh node modules nuke+install.

@jabowery
Copy link

Note if this helps anyone. I was still getting that error after upgrading from from 4.42.0 to 5.6.0. It resolved itself after also upgrading mysql2 from 1.4.2 to 1.6.5 and a fresh node modules nuke+install.

I'm still getting:

SequelizeDatabaseError: Incorrect integer value: 'false' for columnvocascan.roles.adminRightsat row 1
(trying to get vocascan running as a server) despite having done:

$ npm install sequelize@v6.6.5
$ npm install mysql2@v2.3.0

Perhaps that's because I don't have a clue as to what you meant by "fresh node modules nuke+install".

@rajathongal
Copy link

This issue still persists

@fzn0x
Copy link
Member

fzn0x commented Oct 25, 2022

This issue still persists

What is the Sequelize version Sequelize and mysql2 version you are using? can you give a reproducible example with Sequelize SSCCE?

@WikiRik
Copy link
Member

WikiRik commented Oct 25, 2022

This should be resolved in v7 with #14505

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants