onUpdate option in association not working #16963
Labels
pending-approval
Bug reports that have not been verified yet, or feature requests that have not been accepted yet
type: bug
v6
Issue Creation Checklist
Bug Description
I have a relatively simple SQL DB schema with just 4 entity types. I am able to build my code and update properties of the schema of my DB entities like field type/length etc. I have defined some simple associations. However, after reading documentation, source code, issues and examples, I am unable to set the onUpdate or onDelete properties of my foreign key association.
Reproducible Example
The code below creates a relationship between Users and Suppliers, but a foreignKey relationship gets created, the onUpdate field is not being set instead its value is 'No Action' when checked via Azure Data Studio. Trying to set onDelete does not work either.
User.belongsTo(Supplier, { foreignKey: 'supplierId', targetKey: 'id', onUpdate: 'CASCADE' });
After reading source code, I also tried setting the constraints and foreignKeyConstraint options to true, but this didn't make a difference.
User.belongsTo(Supplier, { foreignKey: 'supplierId', targetKey: 'id', constraints:true, foreignKeyConstraint: true, onUpdate: 'CASCADE' });
What do you expect to happen?
When the foreign key is created it should have an On update action set to 'Cascade'
What is actually happening?
The onUpdate is not being set. The logs of the DB updates (while the package builds) show that my onUpdate option is not being taken into account at all.
Environment
Would you be willing to resolve this issue by submitting a Pull Request?
Indicate your interest in the resolution of this issue by adding the 👍 reaction. Comments such as "+1" will be removed.
The text was updated successfully, but these errors were encountered: