Theodo-UK / nestjs-admin

A generic administration interface for TypeORM entities
https://nestjs-admin.com
MIT License
536 stars 60 forks source link

Cannot update entry due to identity column #152

Open Flusinerd opened 4 years ago

Flusinerd commented 4 years ago

Hello, I cannot update my todo entry due to the following error: Error: Cannot update identity column 'id'

The entity definition:

/** todo.entity.ts **/
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from "typeorm";
import { Note } from "src/note/note.entity";

@Entity()
export class Todo {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  title: string;

  @Column()
  text: string;

  @Column({default: false})
  done: boolean;

  @Column({nullable: true})
  noteId: number;

  @ManyToOne(type => Note, note => note.todos)
  note: Note;
}

Full error log from console:

QueryFailedError: Error: Cannot update identity column 'id'.
    at new QueryFailedError (C:\Users\Jan\Documents\Web\nestjs\backend\node_modules\typeorm\error\QueryFailedError.js:11:28)
    at C:\Users\Jan\Documents\Web\nestjs\backend\node_modules\typeorm\driver\sqlserver\SqlServerQueryRunner.js:232:61
    at _query (C:\Users\Jan\Documents\Web\nestjs\backend\node_modules\mssql\lib\base\request.js:409:25)
    at Request.tds.Request.err [as userCallback] (C:\Users\Jan\Documents\Web\nestjs\backend\node_modules\mssql\lib\tedious\request.js:471:15)
    at Request.callback (C:\Users\Jan\Documents\Web\nestjs\backend\node_modules\tedious\lib\request.js:56:14)
    at Connection.endOfMessageMarkerReceived (C:\Users\Jan\Documents\Web\nestjs\backend\node_modules\tedious\lib\connection.js:2407:20)
    at Connection.dispatchEvent (C:\Users\Jan\Documents\Web\nestjs\backend\node_modules\tedious\lib\connection.js:1279:15)
    at Parser.tokenStreamParser.on (C:\Users\Jan\Documents\Web\nestjs\backend\node_modules\tedious\lib\connection.js:1072:14)
    at Parser.emit (events.js:189:13)
    at Parser.parser.on.token (C:\Users\Jan\Documents\Web\nestjs\backend\node_modules\tedious\lib\token\token-stream-parser.js:37:14)

Steps to reproduce: Create project with this entity, go to admin page, create one and then try to update the record.

Sincerly, Jan

williamdclt commented 4 years ago

I see you use SQL server, which we do not test for (this isn't documented I don't think, it should). I would have hoped it works but...

I'll have to test your reproduction example on other databases to see if it's specific to SQL server or if it's a more widespread bug, thank you for the report!

jcwatson11 commented 2 years ago

Just wanted to bump this issue. I'm having the same problem with MS SQL Server. Has there been any progress?