Revert "Bugfix: Compute futures in query conditions" (#3476)
This commit is contained in:
parent
7d49521c70
commit
da94438e06
3 changed files with 2 additions and 36 deletions
|
@ -15,11 +15,7 @@ impl<'a> Document<'a> {
|
||||||
// Check where condition
|
// Check where condition
|
||||||
if let Some(cond) = stm.conds() {
|
if let Some(cond) = stm.conds() {
|
||||||
// Check if the expression is truthy
|
// Check if the expression is truthy
|
||||||
if !cond
|
if !cond.compute(ctx, opt, txn, Some(&self.current)).await?.is_truthy() {
|
||||||
.compute(ctx, &opt.new_with_futures(true), txn, Some(&self.current))
|
|
||||||
.await?
|
|
||||||
.is_truthy()
|
|
||||||
{
|
|
||||||
// Ignore this document
|
// Ignore this document
|
||||||
return Err(Error::Ignore);
|
return Err(Error::Ignore);
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,8 +167,7 @@ impl<'a> Document<'a> {
|
||||||
// Check where condition
|
// Check where condition
|
||||||
if let Some(cond) = stm.conds() {
|
if let Some(cond) = stm.conds() {
|
||||||
// Check if the expression is truthy
|
// Check if the expression is truthy
|
||||||
|
if !cond.compute(ctx, opt, txn, Some(doc)).await?.is_truthy() {
|
||||||
if !cond.compute(ctx, &opt.new_with_futures(true), txn, Some(doc)).await?.is_truthy() {
|
|
||||||
// Ignore this document
|
// Ignore this document
|
||||||
return Err(Error::Ignore);
|
return Err(Error::Ignore);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1074,32 +1074,3 @@ async fn select_only() -> Result<(), Error> {
|
||||||
//
|
//
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn select_on_future() -> Result<(), Error> {
|
|
||||||
let insert_query = "
|
|
||||||
CREATE person SET name = \"Hana\", age = 10, can_drive = <future>{ age > 17 };
|
|
||||||
CREATE person SET name = \"Hendrick\", age = 18, can_drive = <future>{ age > 17 };
|
|
||||||
";
|
|
||||||
let dbs = new_ds().await?;
|
|
||||||
let ses = Session::owner().with_ns("test").with_db("test");
|
|
||||||
dbs.execute(insert_query, &ses, None).await?;
|
|
||||||
|
|
||||||
let select_query_true = "
|
|
||||||
SELECT name FROM person WHERE can_drive
|
|
||||||
";
|
|
||||||
let mut res = dbs.execute(select_query_true, &ses, None).await?;
|
|
||||||
let tmp = res.remove(0).result?;
|
|
||||||
let val = Value::parse("[{ name: \"Hendrick\" }]");
|
|
||||||
assert_eq!(tmp, val);
|
|
||||||
|
|
||||||
let select_query_false = "
|
|
||||||
SELECT name FROM person WHERE !can_drive
|
|
||||||
";
|
|
||||||
let mut res = dbs.execute(select_query_false, &ses, None).await?;
|
|
||||||
let tmp = res.remove(0).result?;
|
|
||||||
let val = Value::parse("[{ name: \"Hana\" }]");
|
|
||||||
assert_eq!(tmp, val);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue