Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First Example gives me Error id too long #5

Open
ilyago opened this issue Jan 10, 2020 · 2 comments
Open

First Example gives me Error id too long #5

ilyago opened this issue Jan 10, 2020 · 2 comments

Comments

@ilyago
Copy link

ilyago commented Jan 10, 2020

UnhandledPromiseRejectionWarning: SequelizeDatabaseError: Data too long for column 'id' at row 1

@HyperCharlie
Copy link

Still getting this!

@rootelement
Copy link

DISCLAIMER - I got this working before i used this sequelize-binary-uuid plugin. But I did get that Data too long error and this worked for me. I'm now trying this plugin and will let you know if I have problems.

When I do the alter (i'm using DBeaver), I had to do a binary with a length which DBeaver wouldn't let me do out of the box:

ALTER TABLE tablename MODIFY COLUMN id binary(36) NOT NULL;

Then in the model, I did:

return sequelize.define(
    'tablename',
    {
      id: {
        type: DataTypes.UUIDV4,
        allowNull: false,
        defaultValue: Sequelize.UUIDV4,
        unique: 'uuid',
        primaryKey: true,
        get() {
          let value = this.getDataValue('id');
          if (Buffer.isBuffer(value)) {
            value = value.toString('utf8');
          }

          return value;
        },
      },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants