Make simple value fetching functions synchronous
This commit is contained in:
parent
2f033aa996
commit
9f7527c01a
6 changed files with 13 additions and 46 deletions
|
@ -238,15 +238,14 @@ impl Iterator {
|
||||||
match v {
|
match v {
|
||||||
Value::Function(f) if f.is_aggregate() => {
|
Value::Function(f) if f.is_aggregate() => {
|
||||||
let x = vals
|
let x = vals
|
||||||
.all(ctx, opt, txn)
|
.all()
|
||||||
.await?
|
|
||||||
.get(ctx, opt, txn, v.to_idiom().as_ref())
|
.get(ctx, opt, txn, v.to_idiom().as_ref())
|
||||||
.await?;
|
.await?;
|
||||||
let x = f.aggregate(x).compute(ctx, opt, txn, None).await?;
|
let x = f.aggregate(x).compute(ctx, opt, txn, None).await?;
|
||||||
obj.set(ctx, opt, txn, v.to_idiom().as_ref(), x).await?;
|
obj.set(ctx, opt, txn, v.to_idiom().as_ref(), x).await?;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let x = vals.first(ctx, opt, txn).await?;
|
let x = vals.first();
|
||||||
let x = v.compute(ctx, opt, txn, Some(&x)).await?;
|
let x = v.compute(ctx, opt, txn, Some(&x)).await?;
|
||||||
obj.set(ctx, opt, txn, v.to_idiom().as_ref(), x).await?;
|
obj.set(ctx, opt, txn, v.to_idiom().as_ref(), x).await?;
|
||||||
}
|
}
|
||||||
|
@ -256,16 +255,12 @@ impl Iterator {
|
||||||
if let Field::Alias(v, i) = field {
|
if let Field::Alias(v, i) = field {
|
||||||
match v {
|
match v {
|
||||||
Value::Function(f) if f.is_aggregate() => {
|
Value::Function(f) if f.is_aggregate() => {
|
||||||
let x = vals
|
let x = vals.all().get(ctx, opt, txn, i).await?;
|
||||||
.all(ctx, opt, txn)
|
|
||||||
.await?
|
|
||||||
.get(ctx, opt, txn, i)
|
|
||||||
.await?;
|
|
||||||
let x = f.aggregate(x).compute(ctx, opt, txn, None).await?;
|
let x = f.aggregate(x).compute(ctx, opt, txn, None).await?;
|
||||||
obj.set(ctx, opt, txn, i, x).await?;
|
obj.set(ctx, opt, txn, i, x).await?;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let x = vals.first(ctx, opt, txn).await?;
|
let x = vals.first();
|
||||||
let x = v.compute(ctx, opt, txn, Some(&x)).await?;
|
let x = v.compute(ctx, opt, txn, Some(&x)).await?;
|
||||||
obj.set(ctx, opt, txn, i, x).await?;
|
obj.set(ctx, opt, txn, i, x).await?;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,8 @@ impl Subquery {
|
||||||
// Process result
|
// Process result
|
||||||
match v.limit() {
|
match v.limit() {
|
||||||
1 => match v.expr.single() {
|
1 => match v.expr.single() {
|
||||||
Some(v) => res.first(&ctx, &opt, txn).await?.get(&ctx, &opt, txn, &v).await,
|
Some(v) => res.first().get(&ctx, &opt, txn, &v).await,
|
||||||
None => res.first(&ctx, &opt, txn).await,
|
None => res.first().ok(),
|
||||||
},
|
},
|
||||||
_ => match v.expr.single() {
|
_ => match v.expr.single() {
|
||||||
Some(v) => res.get(&ctx, &opt, txn, &v).await,
|
Some(v) => res.get(&ctx, &opt, txn, &v).await,
|
||||||
|
|
|
@ -1,17 +1,8 @@
|
||||||
use crate::dbs::Options;
|
|
||||||
use crate::dbs::Runtime;
|
|
||||||
use crate::dbs::Transaction;
|
|
||||||
use crate::err::Error;
|
|
||||||
use crate::sql::part::Part;
|
use crate::sql::part::Part;
|
||||||
use crate::sql::value::Value;
|
use crate::sql::value::Value;
|
||||||
|
|
||||||
impl Value {
|
impl Value {
|
||||||
pub async fn all(
|
pub fn all(&self) -> Self {
|
||||||
&self,
|
self.pick(&[Part::All])
|
||||||
ctx: &Runtime,
|
|
||||||
opt: &Options,
|
|
||||||
txn: &Transaction,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
self.get(ctx, opt, txn, &[Part::All]).await
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,8 @@
|
||||||
use crate::dbs::Options;
|
|
||||||
use crate::dbs::Runtime;
|
|
||||||
use crate::dbs::Transaction;
|
|
||||||
use crate::err::Error;
|
|
||||||
use crate::sql::part::Part;
|
use crate::sql::part::Part;
|
||||||
use crate::sql::value::Value;
|
use crate::sql::value::Value;
|
||||||
|
|
||||||
impl Value {
|
impl Value {
|
||||||
pub async fn first(
|
pub fn first(&self) -> Self {
|
||||||
&self,
|
self.pick(&[Part::First])
|
||||||
ctx: &Runtime,
|
|
||||||
opt: &Options,
|
|
||||||
txn: &Transaction,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
self.get(ctx, opt, txn, &[Part::First]).await
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,7 @@ impl Value {
|
||||||
Arc::new(stm)
|
Arc::new(stm)
|
||||||
.compute(ctx, opt, txn, None)
|
.compute(ctx, opt, txn, None)
|
||||||
.await?
|
.await?
|
||||||
.first(ctx, opt, txn)
|
.first()
|
||||||
.await?
|
|
||||||
.get(ctx, opt, txn, path)
|
.get(ctx, opt, txn, path)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,8 @@
|
||||||
use crate::dbs::Options;
|
|
||||||
use crate::dbs::Runtime;
|
|
||||||
use crate::dbs::Transaction;
|
|
||||||
use crate::err::Error;
|
|
||||||
use crate::sql::part::Part;
|
use crate::sql::part::Part;
|
||||||
use crate::sql::value::Value;
|
use crate::sql::value::Value;
|
||||||
|
|
||||||
impl Value {
|
impl Value {
|
||||||
pub async fn last(
|
pub fn last(&self) -> Self {
|
||||||
&self,
|
self.pick(&[Part::Last])
|
||||||
ctx: &Runtime,
|
|
||||||
opt: &Options,
|
|
||||||
txn: &Transaction,
|
|
||||||
) -> Result<Self, Error> {
|
|
||||||
self.get(ctx, opt, txn, &[Part::Last]).await
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue