Comments (6)
I was talking about similar behavior in #43.
The solution is to create unique index on your foreign keys and create @PrimaryGeneratedColumn()
in PostCategoryRelation
@Table()
@Index((relation: PostCategoryRelation) => [relation.post, relation.category], { unique: true })
export class PostCategoryRelation {
@PrimaryGeneratedColumn()
public readonly id: number;
@ManyToOne(type => Post, post => post.categories)
post: Post;
@ManyToOne(type => PostCategory, category => category.posts)
category: PostCategory;
@Column()
addedByAdmin: boolean;
@Column()
addedByUser: boolean;
}
The simplest solution with @ManyToOne(_type => Post, { primary: true })
isn't implemented yet.
from typeorm.
@19majkel94 yes, it does
from typeorm.
quite complicated, I need to try try this sample by myself to figure out what is going on. Lets mark it as a bug for now, I'll return back to it later
from typeorm.
Yes it might look a bit complicated. But for now I go with the solution to add an explicit primary key to all this "RelationEntities"
from typeorm.
fixed on my separate branch (you can try it if you want by npm i typeorm@next
)
from typeorm.
Does this fix also fixes #43?
from typeorm.
Related Issues (20)
- Entity instance is not correctly initialized inside .save() method
- Updating a parent of a record with children to a new parent closure table
- Repository.prototype.save results for geography types are not consistent with find methods
- typeorm query spesific selecion HOT 1
- typeorm TypeError: Cannot read properties of undefined (reading 'type')
- TypeORM Migration Bug: Duplicate Index Names in Generated Migration
- The getPendingMigrations creates migrations table
- Bug: ORDER BY NULLS (FIRST | LAST) for SQLServer
- Issues with migrations after upgrading typeorm from 0.2.31 to 0.3.20
- Similar tests with identical titles
- prettier should be enforced in circleci
- Instead of experimental decorators use the full version of decorators introduced in TS 5.0 HOT 1
- Postgres geometry column is always being altered to type geometry in every migration despite already being type geometry
- QueryFailedError: read ECONNRESET HOT 7
- Using transactions in tests w/ NestJS & TypeORM
- QueryBuilder looks up the wrong joinAttr when entities have identical property names
- Simple SQL statement generation with Repository object
- SSL AMAZON RDS HOT 2
- typeorm Not Compatible with Latest Version of Mongo HOT 1
- Can not generate migrations with capacitor driver: "Cannot use import statement outside a module"d HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typeorm.