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.

Error when editing entities.

See original GitHub issue

Describe the bug It’s a simple KOA server with TypeORM entities. When I edit any resource, an insert command instead of an update runs a give an error:

Installed libraries and their versions

“admin-bro”: “^3.3.1”, “@admin-bro/koa”: “^1.1.1”, “@admin-bro/typeorm”: “^1.4.0”,

To Reproduce Steps to reproduce the behavior:

  1. Go to any edit and change any data
  2. Click on save
  3. See error and on terminal de wrong SQL that has run.

Expected behavior Edit ends with success

Terminal 19:05:44 DEBUG koa Request POST /admin/api/resources/Organization/records/1/edit query failed: INSERT INTO organization(id, version, created_at, created_by, updated_by, updated_at, deleted_at, deleted_by, type, name) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) – PARAMETERS: [“1”,1,“2020-12-15T22:04:05.617Z”,1,0,“2020-12-15T22:04:05.617Z”,null,0,“sponsor”,“Samsung1”] error: Error: Duplicate entry ‘1’ for key ‘PRIMARY’ at Packet.asError (/Users/wagner-lagoasoft/dev/mmw/monorepo/node_modules/mysql2/lib/packets/packet.js:712:17) at Query.execute (/Users/wagner-lagoasoft/dev/mmw/monorepo/node_modules/mysql2/lib/commands/command.js:28:26) at PoolConnection.handlePacket (/Users/wagner-lagoasoft/dev/mmw/monorepo/node_modules/mysql2/lib/connection.js:425:32) at PacketParser.onPacket (/Users/wagner-lagoasoft/dev/mmw/monorepo/node_modules/mysql2/lib/connection.js:75:12) at PacketParser.executeStart (/Users/wagner-lagoasoft/dev/mmw/monorepo/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket.<anonymous> (/Users/wagner-lagoasoft/dev/mmw/monorepo/node_modules/mysql2/lib/connection.js:82:25) at Socket.emit (events.js:315:20) at addChunk (_stream_readable.js:295:12) at readableAddChunk (_stream_readable.js:271:9) at Socket.Readable.push (_stream_readable.js:212:10) at TCP.onStreamRead (internal/stream_base_commons.js:186:23) { code: ‘ER_DUP_ENTRY’, errno: 1062, sqlState: ‘23000’, sqlMessage: “Duplicate entry ‘1’ for key ‘PRIMARY’” } AdminBroOptions with schema

branding: { companyName: ‘Company’, },

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
TigerWestcommented, Mar 21, 2021

i have same issue… but i think that this is not admin-bro issue

If you are using the primary column as a bigint, you should apply the correct transformer.

https://github.com/typeorm/typeorm/issues/2400

export const bigint: ValueTransformer = {
  to: (entityValue: number) => entityValue,
  from: (databaseValue: string): number => parseInt(databaseValue, 10)
}

@Entity()
export class User extends BaseEntity {
  @Generated('increment')
  @PrimaryColumn('bigint', { transformer: [bigint] })
  id: number;

}
0reactions
jeybeecommented, Feb 26, 2022

This is still an issue today. Can’t save an edit for any entity with a bigint.

A sequelize column specified as this will produce a validation error on trying to save an edit:

@AllowNull(false)
@Column(DataType.BIGINT)
public_id!: bigint;```
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when editing entities. · Issue #716 - GitHub
It's a simple KOA server with TypeORM entities. When I edit any resource, an insert command instead of an update runs a give...
Read more >
Entity Framework 6 Add/Update - Error while edit and try to ...
What is my goal ? Get entity by id, Edit it, Change its primary key Id value, and add it as a new...
Read more >
Error when editing Activity entity [#2886907] | Drupal.org
Not able to edit the Activity Entities. Drupal returns the error: The website encountered an unexpected error. Please try again later.
Read more >
Error message when trying to edit with entity form pop-up
Hi, I'm having an issue with editing from a subgrid. When the pop-up opens I receive the message: The record you are looking...
Read more >
error when editing entity - Rukovoditel Support Forum
I've just been editing the records of an entity, when i save this error has started showing. All ive done it for example...
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