Check for and fire INSTEAD OF triggers for a DELETE operation.
(
state: &SharedState,
identity: &AuthenticatedIdentity,
tenant_id: TenantId,
collection: &str,
old_fields: &HashMap<String, nodedb_types::Value>,
cascade_depth: u32,
)
| 120 | |
| 121 | /// Check for and fire INSTEAD OF triggers for a DELETE operation. |
| 122 | pub async fn fire_instead_of_delete( |
| 123 | state: &SharedState, |
| 124 | identity: &AuthenticatedIdentity, |
| 125 | tenant_id: TenantId, |
| 126 | collection: &str, |
| 127 | old_fields: &HashMap<String, nodedb_types::Value>, |
| 128 | cascade_depth: u32, |
| 129 | ) -> crate::Result<InsteadOfResult> { |
| 130 | let triggers = |
| 131 | state |
| 132 | .trigger_registry |
| 133 | .get_matching(tenant_id.as_u64(), collection, DmlEvent::Delete); |
| 134 | |
| 135 | let instead_triggers: Vec<_> = triggers |
| 136 | .into_iter() |
| 137 | .filter(|t| t.timing == TriggerTiming::InsteadOf) |
| 138 | .collect(); |
| 139 | |
| 140 | if instead_triggers.is_empty() { |
| 141 | return Ok(InsteadOfResult::NoTrigger); |
| 142 | } |
| 143 | |
| 144 | check_cascade_depth(cascade_depth, collection)?; |
| 145 | |
| 146 | let bindings = RowBindings::before_delete(collection, old_fields.clone()); |
| 147 | |
| 148 | fire_triggers( |
| 149 | state, |
| 150 | identity, |
| 151 | tenant_id, |
| 152 | collection, |
| 153 | &instead_triggers, |
| 154 | &bindings, |
| 155 | cascade_depth, |
| 156 | ) |
| 157 | .await?; |
| 158 | |
| 159 | Ok(InsteadOfResult::Handled) |
| 160 | } |
no test coverage detected