Electron100 / butane

An ORM for Rust with a focus on simplicity and on writing Rust, not SQL
Apache License 2.0
94 stars 13 forks source link

foreign key on_delete/on_update action #166

Open jayvdb opened 10 months ago

jayvdb commented 10 months ago

Now that we have db constraints on fkey and many due to https://github.com/Electron100/butane/pull/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 commented 8 months ago

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 commented 8 months ago

sqlite , mysql, postgres all support

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