Set the policy for a specific constraint kind within a collection.
(
&mut self,
collection: &str,
kind: &crate::constraint::ConstraintKind,
policy: ConflictPolicy,
)
| 173 | |
| 174 | /// Set the policy for a specific constraint kind within a collection. |
| 175 | pub fn set_for_kind( |
| 176 | &mut self, |
| 177 | collection: &str, |
| 178 | kind: &crate::constraint::ConstraintKind, |
| 179 | policy: ConflictPolicy, |
| 180 | ) { |
| 181 | let mut coll_policy = self.get_owned(collection); |
| 182 | match kind { |
| 183 | crate::constraint::ConstraintKind::Unique => coll_policy.unique = policy, |
| 184 | crate::constraint::ConstraintKind::ForeignKey { .. } |
| 185 | | crate::constraint::ConstraintKind::BiTemporalFK { .. } => { |
| 186 | coll_policy.foreign_key = policy |
| 187 | } |
| 188 | crate::constraint::ConstraintKind::NotNull => coll_policy.not_null = policy, |
| 189 | crate::constraint::ConstraintKind::Check { .. } => coll_policy.check = policy, |
| 190 | } |
| 191 | self.set(collection, coll_policy); |
| 192 | } |
| 193 | |
| 194 | /// Retrieve the policy for a collection as an owned value. |
| 195 | /// Returns the registered policy if found, otherwise returns the default (ephemeral). |