2022-01-20 23:00:57 +00:00
|
|
|
use crate::dbs::Options;
|
|
|
|
use crate::dbs::Runtime;
|
2022-02-15 01:00:30 +00:00
|
|
|
use crate::dbs::Transaction;
|
2022-01-20 23:00:57 +00:00
|
|
|
use crate::err::Error;
|
2022-02-22 19:05:58 +00:00
|
|
|
use crate::sql::part::Part;
|
2022-01-20 23:00:57 +00:00
|
|
|
use crate::sql::value::Value;
|
|
|
|
|
|
|
|
impl Value {
|
|
|
|
pub async fn merge(
|
|
|
|
&mut self,
|
|
|
|
ctx: &Runtime,
|
2022-02-06 21:06:52 +00:00
|
|
|
opt: &Options,
|
2022-02-15 03:33:16 +00:00
|
|
|
txn: &Transaction,
|
2022-02-13 23:39:10 +00:00
|
|
|
val: &Value,
|
2022-01-20 23:00:57 +00:00
|
|
|
) -> Result<(), Error> {
|
2022-02-15 01:00:30 +00:00
|
|
|
match val.compute(ctx, opt, txn, Some(self)).await? {
|
2022-01-20 23:00:57 +00:00
|
|
|
Value::Object(v) => {
|
|
|
|
for (k, v) in v.value.into_iter() {
|
2022-02-22 19:05:58 +00:00
|
|
|
self.set(ctx, opt, txn, &[Part::from(k)], v).await?;
|
2022-01-20 23:00:57 +00:00
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
2022-02-13 23:39:10 +00:00
|
|
|
_ => Ok(()),
|
2022-01-20 23:00:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|