(
state: &SharedState,
identity: &AuthenticatedIdentity,
tenant_id: TenantId,
collection: &str,
old_fields: &HashMap<String, nodedb_types::Value>,
new_fields: &HashMap<String,
| 78 | /// Check for and fire INSTEAD OF triggers for an UPDATE operation. |
| 79 | #[allow(clippy::too_many_arguments)] |
| 80 | pub async fn fire_instead_of_update( |
| 81 | state: &SharedState, |
| 82 | identity: &AuthenticatedIdentity, |
| 83 | tenant_id: TenantId, |
| 84 | collection: &str, |
| 85 | old_fields: &HashMap<String, nodedb_types::Value>, |
| 86 | new_fields: &HashMap<String, nodedb_types::Value>, |
| 87 | cascade_depth: u32, |
| 88 | ) -> crate::Result<InsteadOfResult> { |
| 89 | let triggers = |
| 90 | state |
| 91 | .trigger_registry |
| 92 | .get_matching(tenant_id.as_u64(), collection, DmlEvent::Update); |
| 93 | |
| 94 | let instead_triggers: Vec<_> = triggers |
| 95 | .into_iter() |
| 96 | .filter(|t| t.timing == TriggerTiming::InsteadOf) |
| 97 | .collect(); |
| 98 | |
| 99 | if instead_triggers.is_empty() { |
| 100 | return Ok(InsteadOfResult::NoTrigger); |
| 101 | } |
| 102 | |
| 103 | check_cascade_depth(cascade_depth, collection)?; |
| 104 | |
| 105 | let bindings = RowBindings::before_update(collection, old_fields.clone(), new_fields.clone()); |
| 106 | |
| 107 | fire_triggers( |
| 108 | state, |
| 109 | identity, |
| 110 | tenant_id, |
| 111 | collection, |
| 112 | &instead_triggers, |
| 113 | &bindings, |
| 114 | cascade_depth, |
| 115 | ) |
| 116 | .await?; |
| 117 | |
| 118 | Ok(InsteadOfResult::Handled) |
| 119 | } |
| 120 | |
| 121 | /// Check for and fire INSTEAD OF triggers for a DELETE operation. |
| 122 | pub async fn fire_instead_of_delete( |
no test coverage detected