error on set=null

This commit is contained in:
Orion Henry 2020-03-28 18:49:31 -07:00
parent b9d003d13d
commit 6e76450f5a
3 changed files with 8 additions and 9 deletions
automerge-backend-wasm
automerge-backend/src

View file

@ -56,7 +56,7 @@ let loadChanges = (backend,changes) => {
}
let applyLocalChange = (backend,request) => {
//console.log("LOCAL REQUEST",request)
//console.log("LOCAL REQUEST",request)
return mutate(backend, (b) => b.applyLocalChange(toJS(request)));
}

View file

@ -63,7 +63,7 @@ impl Backend {
ReqOpType::Link => OpType::Link(child),
ReqOpType::Inc => OpType::Inc(rop.number_value()?),
ReqOpType::Set => OpType::Set(
rop.primitive_value()?,
rop.primitive_value(),
rop.datatype.clone().unwrap_or(DataType::Undefined),
),
};

View file

@ -154,9 +154,10 @@ impl OpID {
// _ => {
let mut i = s.split('@');
match (i.next(), i.next(), i.next()) {
(Some(seq_str), Some(actor_str), None) => seq_str.parse().ok().map(|seq| {
OpID::ID(seq, actor_str.to_string())
}),
(Some(seq_str), Some(actor_str), None) => seq_str
.parse()
.ok()
.map(|seq| OpID::ID(seq, actor_str.to_string())),
_ => None,
}
// }
@ -473,10 +474,8 @@ pub struct OpRequest {
}
impl OpRequest {
pub fn primitive_value(&self) -> Result<PrimitiveValue, AutomergeError> {
self.value
.clone()
.ok_or(AutomergeError::MissingPrimitiveValue)
pub fn primitive_value(&self) -> PrimitiveValue {
self.value.clone().unwrap_or(PrimitiveValue::Null)
}
pub fn obj_type(&self) -> Option<ObjType> {