-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
fix: pass ManyToMany
onUpdate
option to foreign key metadata
#5714
Conversation
d062baf
to
d471187
Compare
Based on your comments what I understood is that we need to set @ManyToMany(
() => Book,
book => book.authors
)
@JoinTable({
name: "author_to_books",
joinColumn: {
name: "author_id",
referencedColumnName: "id",
onDelete: "CASCADE",
onUpdate: "CASCADE"
},
inverseJoinColumn: {
name: "book_id",
referencedColumnName: "id",
onDelete: "CASCADE",
onUpdate: "CASCADE"
},
}) Also, before any change will be merged we need to be sure nothing will be broken for exist users and ORM wont generate any new queries for those who update the version. I'm a bit scary to merge such kind of things. |
I just want to say that when I write class Author {
@ManyToMany(type => Book, {
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
})
books: Book[];
}
class Book {
@JoinTable()
@ManyToMany(type => Author, {
onUpdate: 'NO ACTION',
onDelete: 'NO ACTION',
})
authors: Author[];
} I expect that I can update id's of books and get fk updated accordingly, but cannot update author's id's, like when you use ManyToOne and OneToOne, you apply those decorators inside referencing table and onDelete/onUpdate options are applied to links to REFERENCED table. But in case of ManyToMany when I set What about affecting current users, I just added missing property handling code for |
Is it related issue? #3505 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense. Can you rebase and get the new test suite kicking off?
Why isn't this merged... 1 year later :|? |
@fan-tom up for rebasing for a merge as suggested by @imnotjames? |
rebased |
thank you for contribution! |
Closes: #4980
I'm not sure if onDelete/onUpdate options are handled properly, it seems to me that they must be applied to foreign keys pointing to OPPOSITE entity, not to entity they are used in, but such changes break existing tests, so I considered to fix this issue not breaking them.