From 50c35542427662e1a7c6737449b5f26fbd00e884 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sun, 16 Apr 2023 18:17:44 +0100 Subject: [PATCH] Ensure edge record deletes do not cascade to related records Closes #1817 --- lib/src/doc/clean.rs | 1 + lib/src/sql/idiom.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/src/doc/clean.rs b/lib/src/doc/clean.rs index 306071a1..69a30ed5 100644 --- a/lib/src/doc/clean.rs +++ b/lib/src/doc/clean.rs @@ -45,6 +45,7 @@ impl<'a> Document<'a> { fd if fd.is_id() => continue, fd if fd.is_in() => continue, fd if fd.is_out() => continue, + fd if fd.is_meta() => continue, fd => self.current.to_mut().del(ctx, opt, txn, fd).await?, } } diff --git a/lib/src/sql/idiom.rs b/lib/src/sql/idiom.rs index 3ee77fe9..3df52be9 100644 --- a/lib/src/sql/idiom.rs +++ b/lib/src/sql/idiom.rs @@ -7,7 +7,7 @@ use crate::sql::error::IResult; use crate::sql::fmt::{fmt_separated_by, Fmt}; use crate::sql::part::Next; use crate::sql::part::{all, field, first, graph, index, last, part, value, Part}; -use crate::sql::paths::{ID, IN, OUT}; +use crate::sql::paths::{ID, IN, META, OUT}; use crate::sql::serde::is_internal_serialization; use crate::sql::value::Value; use md5::Digest; @@ -108,6 +108,10 @@ impl Idiom { pub(crate) fn is_out(&self) -> bool { self.0.len() == 1 && self.0[0].eq(&OUT[0]) } + /// Check if this expression is an 'out' field + pub(crate) fn is_meta(&self) -> bool { + self.0.len() == 1 && self.0[0].eq(&META[0]) + } /// Check if this is an expression with multiple yields pub(crate) fn is_multi_yield(&self) -> bool { self.iter().any(Self::split_multi_yield)