Open jayvdb opened 1 year ago
Due to https://github.com/Electron100/butane/pull/158 , postgres now catches this, resulting in
called `Result::unwrap()` on an `Err` value: Postgres(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E23503), message: "insert or update on table \"bar\" violates foreign key constraint \"bar_foo_fkey\"", detail: Some("Key (foo)=(1) is not present in table \"foo\"."), hint: None, position: None, where_: None, schema: Some("public"), table: Some("bar"), column: None, datatype: None, constraint: Some("bar_foo_fkey"), file: Some("ri_triggers.c"), line: Some(2608), routine: Some("ri_ReportViolation") }) })
sqlite ignores it.
If we remove the
tag.save(..)
at https://github.com/Electron100/butane/blob/master/butane/tests/common/blog.rs#L81 , themany.rs
tests fail, but only fail at the assertions on the number of tags after the posts are re-loaded from the database.Likewise removing the
blog.save(..)
at https://github.com/Electron100/butane/blob/35ef9d0/butane/tests/common/blog.rs#L91 , thequery.rs
testfkey_match
fails, but it fails trying to fetch the blog, not during the storing of thepost
in the db.The
Post.save(..)
should detect that the related tags are not saved, and either save them, or error. IMO doing the save is the most desirable, and isnt a breaking change as anyone who had code that triggers the related save's had broken code.