Skip to main content

is_fk_violation

Function is_fk_violation 

Source
pub fn is_fk_violation(err: &Error) -> bool
Expand description

Returns true when the given sqlx error wraps a SQLite foreign-key constraint violation. SQLite reports these as either extended code 787 (SQLITE_CONSTRAINT_FOREIGNKEY) or, for deferred / trigger-mediated failures, 1811 (SQLITE_CONSTRAINT_TRIGGER). To be robust across both we also fall back to a substring check of the error message.