-
-
Notifications
You must be signed in to change notification settings - Fork 44
Expose on_delete and on_update for ForeignKey fields #540
Copy link
Copy link
Open
Labels
C-libCrate: cot (main library crate)Crate: cot (main library crate)enhancementNew feature or requestNew feature or request
Description
We currently have these policies defined
Lines 143 to 154 in 4620c6a
| #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Default)] | |
| pub enum ForeignKeyOnDeletePolicy { | |
| /// Don't do any additional actions on delete. | |
| NoAction, | |
| /// Prevent the delete if this model instance is referenced by another row. | |
| #[default] | |
| Restrict, | |
| /// Remove the referencing row if the referenced row is deleted. | |
| Cascade, | |
| /// Set the foreign key in the referencing row to [`None`]. | |
| SetNone, | |
| } |
Lines 175 to 187 in 4620c6a
| #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Default)] | |
| pub enum ForeignKeyOnUpdatePolicy { | |
| /// Don't do any additional actions on update. | |
| NoAction, | |
| /// Prevent the update if this model instance is referenced by another row. | |
| Restrict, | |
| /// Update the foreign key in the referencing row if the referenced row is | |
| /// updated. | |
| #[default] | |
| Cascade, | |
| /// Set the foreign key in the referencing row to [`None`]. | |
| SetNone, | |
| } |
However, we need to be able to expose them. Perhaps to use them like this:
#[model]
struct Foo {
#[model(on_delete="cascade", on_update="set_none")]
bar: ForeignKey<Bar>
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-libCrate: cot (main library crate)Crate: cot (main library crate)enhancementNew feature or requestNew feature or request