Skip to content

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

Closed

Description

@nicolaspfernandes

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

Activity

  1. gabegorelick commented on Mar 28, 2019

    @gabegorelick
    Contributor

    See #10600

  2. sushantdhiman commented on Mar 29, 2019

    @sushantdhiman
    Contributor

    🎉 This issue has been resolved in version 5.2.4 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  3. nicolasgramlich commented on Apr 16, 2019

    @nicolasgramlich

    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.

  4. jabowery commented on Sep 13, 2021

    @jabowery

    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 [email protected]
    $ npm install [email protected]
    

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

  5. rajathongal commented on Oct 25, 2022

    @rajathongal

    This issue still persists

  6. fzn0x commented on Oct 25, 2022

    @fzn0x
    Member

    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?

  7. WikiRik commented on Oct 25, 2022

    @WikiRik
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions