diff --git a/src/doc/empty.rs b/src/doc/empty.rs new file mode 100644 index 00000000..e7ef4c72 --- /dev/null +++ b/src/doc/empty.rs @@ -0,0 +1,22 @@ +use crate::dbs::Executor; +use crate::dbs::Options; +use crate::dbs::Runtime; +use crate::dbs::Statement; +use crate::doc::Document; +use crate::err::Error; +use crate::sql::value::Value; + +impl Document { + pub async fn empty( + &self, + _ctx: &Runtime, + _opt: &Options, + _exe: &Executor<'_>, + _stm: &Statement<'_>, + ) -> Result<(), Error> { + match self.id.is_some() && self.current == Value::None { + true => Err(Error::IgnoreError), + false => Ok(()), + } + } +} diff --git a/src/doc/mod.rs b/src/doc/mod.rs index 6e9d6435..dc7289b7 100644 --- a/src/doc/mod.rs +++ b/src/doc/mod.rs @@ -7,6 +7,7 @@ mod compute; mod create; mod delete; mod document; +mod empty; mod erase; mod event; mod grant; diff --git a/src/doc/select.rs b/src/doc/select.rs index f6087b8a..eec7bd05 100644 --- a/src/doc/select.rs +++ b/src/doc/select.rs @@ -14,6 +14,8 @@ impl Document { exe: &Executor<'_>, stm: &Statement<'_>, ) -> Result { + // Check if record exists + self.empty(ctx, opt, exe, stm).await?; // Check where clause self.check(ctx, opt, exe, stm).await?; // Check if allowed