-
Notifications
You must be signed in to change notification settings - Fork 46
Description
Hello,
We've encountered an issue where editing any record in AdminBro doesn't update the existing record, but actually inserts a new record in the database. So when we edit an item, we duplicate it with the same data (and a new generated ID primary key) instead of editing the existing item. This happens on any of our TypeORM entities, and it still occurs even with the simplified version I've posted below.
Here is a video demonstrating the issue: https://share.getcloudapp.com/kpuYod9O
No error is printed in the console, and AdminBro displays success in saving the record. I'm using a forked version of admin-bro-typeorm to avoid the problem in issue #5.
To rule out any issue with our versions of AdminBro or our configuration, I set up a basic Sequelize model for this same table and used the AdminBro Sequelize adapter. The issue does not happen there and is only specific to the TypeORM adapter.
Versions Used
admin-bro: 1.6.6admin-bro-expressjs: 0.4.0admin-bro-typeorm: Forked version of 1.6-alpha.8 (https://github.com/headwayio/admin-bro-typeorm)typeorm: 0.2.22
We're running on Postgres 10 in Docker.
AdminBro Options
import { Database, Resource } from 'admin-bro-typeorm';
AdminBro.registerAdapter({ Database, Resource });
const adminBro = new AdminBro({
resources: [{ resource: TaxNexusRegion }],
rootPath: '/admin',
});
TaxNexusRegion TypeORM Entity
import {
Column,
Entity,
JoinColumn,
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
BaseEntity,
} from 'typeorm';
@Entity('tax_nexus_region')
export class TaxNexusRegion extends BaseEntity {
@PrimaryGeneratedColumn({
type: 'bigint',
name: 'id',
})
id: string;
@Column('character varying', {
nullable: false,
name: 'region',
})
region: string;
@Column('character varying', {
nullable: false,
name: 'region_code',
})
region_code: string;
@Column('character varying', {
nullable: false,
name: 'country',
})
country: string;
@Column('character varying', {
nullable: false,
name: 'country_code',
})
country_code: string;
@Column('timestamp with time zone', {
nullable: false,
default: () => 'CURRENT_TIMESTAMP',
name: 'created',
})
created: Date;
@Column('timestamp with time zone', {
nullable: false,
default: () => 'CURRENT_TIMESTAMP',
name: 'updated',
})
updated: Date;
}