Default UUID value not working
See original GitHub issueWhat are you doing?
I am trying to define model which has a uuid column which gets automatically generated upon insert.
This is my model:
export default class PasswordGroupModel extends Model {
}
PasswordGroupModel.init({
uuid: {
type: DataTypes.UUID,
allowNull: false,
defaultValue: DataTypes.UUIDV1
},
name: {
type: DataTypes.STRING,
allowNull: false
}
}, {
sequelize
});
What do you expect to happen?
After creating new entry I would expect the uuid column to contain a generated uuid.
What is actually happening?
Instead of an actual uuid the column contains literally the string “UUIDV1”. Same result when trying to use UUIDV4
Environment
Dialect: sqlite 4.0.6 Sequelize version: 5.3.1 OS: WIN10 TypeScript version: 3.4.5 Tested with latest release version: 5.8.2
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (9 by maintainers)
Top Results From Across the Web
Default value for UUID column in Postgres
Call DEFAULT when defining a column to invoke one of the OSSP uuid functions. The Postgres server will automatically invoke the function every ......
Read more >MySQL 8.0.13: Default Value as uuid not working
I am trying to set the Default value as UUID() in MySQL version 8.0.13. But upon successful execution, the default value resets to...
Read more >Default UUID not working for my-sql #12055 - prisma ... - GitHub
I've checked the migration sql file and there is no default clause for the column uuid. How to reproduce. prisma migrate dev --name...
Read more >Generate a UUID as PostgreSQL default value | by Shawn OY
Generate a UUID as PostgreSQL default value · CREATE EXTENSION IF NOT EXISTS "pgcrypto"; · SELECT gen_random_uuid(); · id UUID NOT NULL DEFAULT...
Read more >UUID | CockroachDB Docs
The UUID (Universally Unique Identifier) data type stores a 128-bit value that is unique across both space and time. Tip: To auto-generate unique...
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
@SimonSchick - lol, i am not the original poster of this issue, that would be @Swaglis. I am helping to solve the issue by suggesting alternative methods.
Can you please provide a minimal repro and tell us if this is also happening in v4?