MissingPrimaryColumnError when primary defined in relation
See original GitHub issueI have an entity described that:
import { Test } from "./test";
import { Product } from "./product";
import { Table, Column, ManyToOne } from "typeorm";
@Table()
export class Result {
@ManyToOne(type => Test, { primary: true, nullable: false })
public test: Test;
@ManyToOne(type => Product, { primary: true, nullable: false })
public product: Product;
@Column()
public primaryValue: number;
@Column()
public secondaryValue: number;
}
And I have an error on launch:
Error! { MissingPrimaryColumnError: Entity "Result" does not have a primary column. Primary column is required to have in all your entities. Use @PrimaryColumn decorator to add a primary column to your entity.
Does the primary
in relations option doesn’t work yet or it’s just a bug in checking if primary is defined?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
It's possible, create a table without primary key in TypeOrm?
Ciao, no you can't because its required for entities to have a primary column in terms of ORM because most of ORM operations...
Read more >TypeORM - Entity - Tutorialspoint
PrimaryGeneratedColumn() decorator class is used to represent that the id column is the primary key column of the Student entity.
Read more >MissingPrimaryColumnError - typeorm
Inherited from Error.message. Defined in /Users/lesha/trunk/sandbox/typeorm/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts:886 ...
Read more >Entities - typeorm - GitBook
Basic entities consist of columns and relations. Each entity MUST have a primary column (or ObjectId column if are using MongoDB).
Read more >0.3.7 (2022-06-29) | TypeORM Docs
Define relation columns, and order by them instead. ... If related entity has multiple primary keys, and you want to point to multiple...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Excuse me, How indices can help with this error? I added
@Index()
to both keys and nothing solved(Your link is no longer valid)
Yes, thanks! It works great now 😄 Sorry for asking this kind of question but the docs is empty and website documentation was updated today and I haven’t checked it yet 😉