adminjs icon indicating copy to clipboard operation
adminjs copied to clipboard

[Bug]: [Postgres/sequelize] Error on updating a record when using identity "id"

Open Paroca72 opened this issue 6 months ago • 0 comments

Contact Details

No response

What happened?

When try to update a record from the adminjs admin panel I got this error "SequelizeDatabaseError: column "id" can only be updated to DEFAULT"

This happen with all the table than has an "id" column as identity: Image

It seems adminjs create a wrong update sql SQL:

UPDATE "company_offers" 
SET "id"=$1,"updated_date"=$2,"updated_by"=$3,"created_date"=$4,"created_by"=$5 
WHERE "id" = $6"

Params: [ 2, "2025-01-21 14:03:13.107 +07:00", 16, "2024-07-09 09:06:11.537 +07:00", 2, 2,]

As you can see the update include the "id" column even if the value is not changed. Furthermore as you can see as follow the "id" column is declared as auto-increment and should not be included inside the update code.

id: {
    field: "id",
    type: DataTypes.BIGINT,
    autoIncrement: true,
    // autoIncrementIdentity: true, ALSO NOT WORK
    primaryKey: true,
},

Thanks for your help

Bug prevalence

Always

AdminJS dependencies version

Adminjs 7.8.15 @adminjs/sequelize ^4.1.1 @adminjs/express ^6.1.1

What browsers do you see the problem on?

No response

Relevant log output

"SequelizeDatabaseError: column "id" can only be updated to DEFAULT"

Relevant code that's giving you issues


Paroca72 avatar Aug 20 '25 09:08 Paroca72