Skip to content

MySQL - JSON column should not have a DEFAULT value when creating table #8814

Closed

Description

@njLT

What are you doing?

Assigning a default value to a JSON field.

  permissions: {
    type: Sequelize.JSON,
    defaultValue: [],
  }

What do you expect to happen?

work as expected

What is actually happening?

error on creating table - invalid syntax

Output, either JSON or SQL
CREATE TABLE IF NOT EXISTS ... permissions JSON DEFAULT , ... ENGINE=InnoDB;

SequelizeDatabaseError: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' password_hash VARCHAR(255), password_salt VARCHAR(255), created_at DATETI' at line 1

Dialect: mysql
Dialect version: 1.5.1
Database version: 5.7
Sequelize version: 4.26.0
Tested with latest release: 4.28.6 (If yes, specify that version)

Note : Your issue may be ignored OR closed by maintainers if it's not tested against latest version OR does not follow issue template.

JSON columns do not support a default value in MySQL. This should include JSON and GEOMETRY as well so as not to assign a default value.

Activity

  1. added
    type: bug
    dialect: mysql
    on Jan 3, 2018
  2. mccabemj commented on Jan 4, 2018

    @mccabemj
    Contributor

    I have added a pull request for this issue, stopping the SQL adding the default values if provided for all non-allowed data types #8839

  3. sushantdhiman commented on Jan 5, 2018

    @sushantdhiman
    Contributor

    Fixed 74d2b5f

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

    dialect: mysqltype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions