Primary key type UUID and default value UUIDV1 results in ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
See original GitHub issueWhat you are doing?
I am trying to define a table with a primary key. I have tried the following code below with both Sequelize.UUIDV1
and Sequelize.UUIDV4
.
const Sequelize = require('sequelize')
let sequelize = new Sequelize(env.mysqlConn, {})
let Foo = seq.define('Foo', {
LCID: {
type: Sequelize.UUID,
primaryKey: true,
defaultValue: Sequelize.UUIDV1
},
// more properties below
}, {})
What do you expect to happen?
I wanted Foo to have a column LCID that is a primary key as described in the datatypes documentation
sequelize.define('model', {
uuid: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV1,
primaryKey: true
}
})
What is actually happening?
Unhandled rejection SequelizeDatabaseError: ER_TRUNCATED_WRONG_VALUE_FOR_FIELD: Incorrect integer value: 'bf595154-903a-49f9-b324-91d22bf8e777' for column 'LCID' at row 1
Dialect: mysql Database version: mysql Ver 14.14 Distrib 5.7.13, for osx10.11 (x86_64) Sequelize version: 3.23.6
Thought I was following the documentation well. Any suggestions?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Sequelize UUID with mySQL: Unable to set default value
By adding defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'), to your createdAt and updatedAt in your migration file defaults the value to ...
Read more >Migrate Primary Keys to UUIDs - Sequelize/Node
This step meant to go into each model and update each primary key and foreign ... UUID, - autoIncrement: true, + defaultValue: Sequelize....
Read more >Default value for UUID column in Postgres
Defined by specification as a Version 3 UUID, namespace-based UUID. Based on randomly-generated data for 121-122 of the 128 bits. Six or seven ......
Read more >Sequelize - using UUID for primary key column in your table ...
Sequelize provides UUIDV1 and UUIDV4 as the default value for UUID type columns that you can use when defining the model.
Read more >MySQL & UUIDs - lefred blog
Additionally, if we keep the VARCHCAR datatype for our uuid, the primary key could take 146 bytes per row (some utf8 characters can...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It works in
master
andv3
SSCCE Test
Output
But I haven’t started using the
MySQL 5.7
yet, May be that is the issue. Travis also only test against5.6
. Can you please post the SQL queries generated@SkamDart Thanks, but it seems we really have some issues with
MySQL 5.7
, We are tracking them here #6345