Revert "Bugfix: Compute futures in query conditions" (#3476)

This commit is contained in:
Rushmore Mushambi 2024-02-11 18:48:22 +02:00 committed by GitHub
parent 7d49521c70
commit da94438e06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 2 additions and 36 deletions

View file

@ -15,11 +15,7 @@ impl<'a> Document<'a> {
// Check where condition
if let Some(cond) = stm.conds() {
// Check if the expression is truthy
if !cond
.compute(ctx, &opt.new_with_futures(true), txn, Some(&self.current))
.await?
.is_truthy()
{
if !cond.compute(ctx, opt, txn, Some(&self.current)).await?.is_truthy() {
// Ignore this document
return Err(Error::Ignore);
}

View file

@ -167,8 +167,7 @@ impl<'a> Document<'a> {
// Check where condition
if let Some(cond) = stm.conds() {
// Check if the expression is truthy
if !cond.compute(ctx, &opt.new_with_futures(true), txn, Some(doc)).await?.is_truthy() {
if !cond.compute(ctx, opt, txn, Some(doc)).await?.is_truthy() {
// Ignore this document
return Err(Error::Ignore);
}

View file

@ -1074,32 +1074,3 @@ async fn select_only() -> Result<(), Error> {
//
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(())
}