(
state: &SharedState,
identity: &AuthenticatedIdentity,
tenant_id: TenantId,
info: &DmlWriteInfo,
old_row: &Option<HashMap<String, nodedb_types::Value>>,
cascade_depth: u32,
)
| 39 | /// the caller should abort the write. |
| 40 | #[allow(clippy::too_many_arguments)] |
| 41 | pub async fn fire_pre_dispatch_triggers( |
| 42 | state: &SharedState, |
| 43 | identity: &AuthenticatedIdentity, |
| 44 | tenant_id: TenantId, |
| 45 | info: &DmlWriteInfo, |
| 46 | old_row: &Option<HashMap<String, nodedb_types::Value>>, |
| 47 | cascade_depth: u32, |
| 48 | ) -> crate::Result<PreDispatchResult> { |
| 49 | // Check INSTEAD OF first — if it handles the write, skip everything else. |
| 50 | match info.event { |
| 51 | DmlEvent::Insert => { |
| 52 | if let Some(ref new_fields) = info.new_fields { |
| 53 | match super::fire_instead::fire_instead_of_insert( |
| 54 | state, |
| 55 | identity, |
| 56 | tenant_id, |
| 57 | &info.collection, |
| 58 | new_fields, |
| 59 | cascade_depth, |
| 60 | ) |
| 61 | .await? |
| 62 | { |
| 63 | InsteadOfResult::Handled => return Ok(PreDispatchResult::Handled), |
| 64 | InsteadOfResult::NoTrigger => {} |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | DmlEvent::Update => { |
| 69 | let empty = HashMap::new(); |
| 70 | let old_fields = old_row.as_ref().unwrap_or(&empty); |
| 71 | let new_fields = info.new_fields.as_ref().unwrap_or(&empty); |
| 72 | match super::fire_instead::fire_instead_of_update( |
| 73 | state, |
| 74 | identity, |
| 75 | tenant_id, |
| 76 | &info.collection, |
| 77 | old_fields, |
| 78 | new_fields, |
| 79 | cascade_depth, |
| 80 | ) |
| 81 | .await? |
| 82 | { |
| 83 | InsteadOfResult::Handled => return Ok(PreDispatchResult::Handled), |
| 84 | InsteadOfResult::NoTrigger => {} |
| 85 | } |
| 86 | } |
| 87 | DmlEvent::Delete => { |
| 88 | let empty = HashMap::new(); |
| 89 | let old_fields = old_row.as_ref().unwrap_or(&empty); |
| 90 | match super::fire_instead::fire_instead_of_delete( |
| 91 | state, |
| 92 | identity, |
| 93 | tenant_id, |
| 94 | &info.collection, |
| 95 | old_fields, |
| 96 | cascade_depth, |
| 97 | ) |
| 98 | .await? |
no test coverage detected