question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default UUID value not working

See original GitHub issue

What 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:closed
  • Created 4 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
knoxcardcommented, May 3, 2019

@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.

1reaction
SimonSchickcommented, May 1, 2019

Can you please provide a minimal repro and tell us if this is also happening in v4?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found