#[repr(u8)]pub enum ReferentialAction {
Cascade = 1,
Restrict = 2,
NoAction = 4,
SetNull = 8,
SetDefault = 16,
}
Expand description
An action describing the way referential integrity is managed in the system.
An action is triggered when a relation constraint gets violated in a way that would make the the data inconsistent, e.g. deleting or updating a referencing record that leaves related records into a wrong state.
@relation(fields: [a], references: [b], onDelete: NoAction, onUpdate: Cascade)
^^^^^^^^ ^^^^^^^
Variants§
Cascade = 1
Deletes record if dependent record is deleted. Updates relation scalar fields if referenced scalar fields of the dependent record are updated.
Prevents operation (both updates and deletes) from succeeding if any records are connected.
Restrict = 2
Prevents operation (both updates and deletes) from succeeding if any records are connected. This behavior will always result in a runtime error for required relations.
NoAction = 4
Behavior is database specific. Either defers throwing an integrity check error until the end of the transaction or errors immediately. If deferred, this makes it possible to temporarily violate integrity in a transaction while making sure that subsequent operations in the transaction restore integrity.
When using relationMode = “prisma”, NoAction becomes an alias of the emulated Restrict (when supported).
SetNull = 8
Sets relation scalar fields to null if the relation is deleted or updated. This will always result in a runtime error if one or more of the relation scalar fields are required.
SetDefault = 16
Sets relation scalar fields to their default values on update or delete of relation. Will always result in a runtime error if no defaults are provided for any relation scalar fields.
Implementations§
source§impl ReferentialAction
impl ReferentialAction
sourcepub fn triggers_modification(self) -> bool
pub fn triggers_modification(self) -> bool
True if the action modifies the related items.
sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
The string representation of the referential action in the schema.
sourcepub fn documentation(&self) -> &'static str
pub fn documentation(&self) -> &'static str
The documentation string to display in autocompletion / editor hints.
Trait Implementations§
source§impl AsRef<str> for ReferentialAction
impl AsRef<str> for ReferentialAction
source§impl BitAnd for ReferentialAction
impl BitAnd for ReferentialAction
source§impl BitFlag for ReferentialAction
impl BitFlag for ReferentialAction
source§impl BitOr for ReferentialAction
impl BitOr for ReferentialAction
source§impl BitXor for ReferentialAction
impl BitXor for ReferentialAction
source§impl Clone for ReferentialAction
impl Clone for ReferentialAction
source§fn clone(&self) -> ReferentialAction
fn clone(&self) -> ReferentialAction
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ReferentialAction
impl Debug for ReferentialAction
source§impl Display for ReferentialAction
impl Display for ReferentialAction
source§impl Not for ReferentialAction
impl Not for ReferentialAction
source§impl PartialEq for ReferentialAction
impl PartialEq for ReferentialAction
source§fn eq(&self, other: &ReferentialAction) -> bool
fn eq(&self, other: &ReferentialAction) -> bool
self
and other
values to be equal, and is used
by ==
.