Skip to content
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

foreign key on_delete/on_update action #166

Open
jayvdb opened this issue Nov 13, 2023 · 2 comments
Open

foreign key on_delete/on_update action #166

jayvdb opened this issue Nov 13, 2023 · 2 comments

Comments

@jayvdb
Copy link
Collaborator

jayvdb commented Nov 13, 2023

Now that we have db constraints on fkey and many due to #158, the next step is to add a cascade setting.

afaik, there are two options.

  1. a #[cascade(delete)] type macro
  2. Put the cascade setting as a part of the initialiser, such as ForeignKey(<field>, <optional cascade>)

The first seems easier to added in a non-breaking way.
I've not thought more about it than that.

@jayvdb
Copy link
Collaborator Author

jayvdb commented Jan 22, 2024

sqlite does have "on update" support as well as "on delete" so that should be added to the design of this feature to get the design right the first time, so any breaking changes occur once.

@jayvdb
Copy link
Collaborator Author

jayvdb commented Jan 22, 2024

sqlite , mysql, postgres all support

  • NO ACTION
  • RESTRICT
  • SET NULL
  • SET DEFAULT
  • CASCADE
    I am pretty confident that Oracle does also.

Django has the following options for on_delete which they implement in Python, not using database constraints.

  • CASCADE
  • DO_NOTHING
  • PROTECT
  • RESTRICT
  • SET
  • SET_DEFAULT
  • SET_NULL

@jayvdb jayvdb changed the title Cascade setting foreign key on_delete/on_update action Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant