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

Primary Key not being named "id" #33

Open
maievsm opened this issue Feb 18, 2021 · 2 comments
Open

Primary Key not being named "id" #33

maievsm opened this issue Feb 18, 2021 · 2 comments

Comments

@maievsm
Copy link

maievsm commented Feb 18, 2021

Describe the bug
I'm using TypeORM, and there's a weird behavior when using an entity with a primary key not named "id". Adding a resource that has a relation to this entity will result in a success, but the resource wont be added at all.

Installed libraries and their versions
admin-bro: 3.4.0
admin-bro/express: 3.1.0
admin-bro/nestjs: 1.0.0
admin-bro/typeorm: 1.4.0
typeorm: 0.2.30

Schema

@Entity()
export class Profile extends BaseEntity {
  @PrimaryColumn()
  user_id: string;

  @OneToMany(() => Photo, (photo) => photo.profile)
  photos: Photo[];
}

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

  @ManyToOne(() => Profile, (profile) => profile.photos)
  profile: Profile;
}

When adding a Profile, everything works properly. But when adding a Photo, you'll receive a success despite it not being added.

@francofadini
Copy link

I guess you want to say "When adding a Photo, everything works properly. But when adding a Profile, you'll receive a success despite it not being added."

As is Profile the entity with primary key different from "id".

Same problem here. Editing those entities is throwing an error 'duplicate key value violates unique constraint 'table_pkey''

@dziraf dziraf transferred this issue from SoftwareBrothers/adminjs Dec 28, 2021
@dziraf
Copy link

dziraf commented Feb 24, 2022

Does the problem still persist in the latest version of the adapter?

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