diff --git a/lib/src/sql/idiom.rs b/lib/src/sql/idiom.rs index 10ca8575..466c603e 100644 --- a/lib/src/sql/idiom.rs +++ b/lib/src/sql/idiom.rs @@ -73,7 +73,7 @@ impl From> for Idiom { } impl Idiom { - pub fn add(mut self, n: Part) -> Idiom { + pub fn push(mut self, n: Part) -> Idiom { self.parts.push(n); self } diff --git a/lib/src/sql/value/diff.rs b/lib/src/sql/value/diff.rs index 32ab73ad..65c0806b 100644 --- a/lib/src/sql/value/diff.rs +++ b/lib/src/sql/value/diff.rs @@ -13,7 +13,7 @@ impl Value { if !b.value.contains_key(key) { ops.push(Operation { op: Op::Remove, - path: path.clone().add(key.clone().into()), + path: path.clone().push(key.clone().into()), value: Value::Null, }) } @@ -23,11 +23,11 @@ impl Value { match a.value.get(key) { None => ops.push(Operation { op: Op::Add, - path: path.clone().add(key.clone().into()), + path: path.clone().push(key.clone().into()), value: val.clone(), }), Some(old) => { - let path = path.clone().add(key.clone().into()); + let path = path.clone().push(key.clone().into()); ops.append(&mut old.diff(val, path)) } } @@ -36,7 +36,7 @@ impl Value { (Value::Array(a), Value::Array(b)) if a != b => { let mut n = 0; while n < min(a.len(), b.len()) { - let path = path.clone().add(n.into()); + let path = path.clone().push(n.into()); ops.append(&mut a.value[n].diff(&b.value[n], path)); n += 1; } @@ -44,7 +44,7 @@ impl Value { if n >= a.len() { ops.push(Operation { op: Op::Add, - path: path.clone().add(n.into()), + path: path.clone().push(n.into()), value: b.value[n].clone(), }) } @@ -54,7 +54,7 @@ impl Value { if n >= b.len() { ops.push(Operation { op: Op::Remove, - path: path.clone().add(n.into()), + path: path.clone().push(n.into()), value: Value::Null, }) } diff --git a/lib/src/sql/value/each.rs b/lib/src/sql/value/each.rs index 9834e4f4..64b0c13b 100644 --- a/lib/src/sql/value/each.rs +++ b/lib/src/sql/value/each.rs @@ -14,10 +14,10 @@ impl Value { // Current path part is an object Value::Object(v) => match p { Part::Field(f) => match v.value.get(&f.name) { - Some(v) => v._each(path.next(), prev.add(p.clone())), + Some(v) => v._each(path.next(), prev.push(p.clone())), None => vec![], }, - Part::All => self._each(path.next(), prev.add(p.clone())), + Part::All => self._each(path.next(), prev.push(p.clone())), _ => vec![], }, // Current path part is an array @@ -26,25 +26,25 @@ impl Value { .value .iter() .enumerate() - .flat_map(|(i, v)| v._each(path.next(), prev.clone().add(Part::from(i)))) + .flat_map(|(i, v)| v._each(path.next(), prev.clone().push(Part::from(i)))) .collect::>(), Part::First => match v.value.first() { - Some(v) => v._each(path.next(), prev.add(p.clone())), + Some(v) => v._each(path.next(), prev.push(p.clone())), None => vec![], }, Part::Last => match v.value.last() { - Some(v) => v._each(path.next(), prev.add(p.clone())), + Some(v) => v._each(path.next(), prev.push(p.clone())), None => vec![], }, Part::Index(i) => match v.value.get(i.to_usize()) { - Some(v) => v._each(path.next(), prev.add(p.clone())), + Some(v) => v._each(path.next(), prev.push(p.clone())), None => vec![], }, _ => v .value .iter() .enumerate() - .flat_map(|(i, v)| v._each(path.next(), prev.clone().add(Part::from(i)))) + .flat_map(|(i, v)| v._each(path.next(), prev.clone().push(Part::from(i)))) .collect::>(), }, // Ignore everything else diff --git a/lib/src/sql/value/every.rs b/lib/src/sql/value/every.rs index 7f77f6de..7db80bd4 100644 --- a/lib/src/sql/value/every.rs +++ b/lib/src/sql/value/every.rs @@ -12,14 +12,14 @@ impl Value { Value::Object(v) => v .value .iter() - .flat_map(|(k, v)| v._every(prev.clone().add(Part::from(k)))) + .flat_map(|(k, v)| v._every(prev.clone().push(Part::from(k)))) .collect::>(), // Current path part is an array Value::Array(v) => v .value .iter() .enumerate() - .flat_map(|(i, v)| v._every(prev.clone().add(Part::from(i)))) + .flat_map(|(i, v)| v._every(prev.clone().push(Part::from(i)))) .collect::>(), // Process everything else _ => vec![prev],