Check if record actually exists when selecting
This commit is contained in:
parent
9d957849b0
commit
6d622badc3
3 changed files with 25 additions and 0 deletions
22
src/doc/empty.rs
Normal file
22
src/doc/empty.rs
Normal file
|
@ -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(()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ mod compute;
|
||||||
mod create;
|
mod create;
|
||||||
mod delete;
|
mod delete;
|
||||||
mod document;
|
mod document;
|
||||||
|
mod empty;
|
||||||
mod erase;
|
mod erase;
|
||||||
mod event;
|
mod event;
|
||||||
mod grant;
|
mod grant;
|
||||||
|
|
|
@ -14,6 +14,8 @@ impl Document {
|
||||||
exe: &Executor<'_>,
|
exe: &Executor<'_>,
|
||||||
stm: &Statement<'_>,
|
stm: &Statement<'_>,
|
||||||
) -> Result<Value, Error> {
|
) -> Result<Value, Error> {
|
||||||
|
// Check if record exists
|
||||||
|
self.empty(ctx, opt, exe, stm).await?;
|
||||||
// Check where clause
|
// Check where clause
|
||||||
self.check(ctx, opt, exe, stm).await?;
|
self.check(ctx, opt, exe, stm).await?;
|
||||||
// Check if allowed
|
// Check if allowed
|
||||||
|
|
Loading…
Reference in a new issue