rm does not need all keys

main
Ziyang Hu 2 years ago
parent adcea96088
commit ef7f58b368

@ -867,7 +867,7 @@ impl<'s, S: Storage<'s>> Db<S> {
StoreRelationNotFoundError(meta.name.to_string())
);
existing.ensure_compatible(meta)?;
existing.ensure_compatible(meta, *op == RelationOp::Rm)?;
}
};

@ -163,7 +163,7 @@ impl RelationHandle {
tuple.serialize(&mut Serializer::new(&mut ret)).unwrap();
Ok(ret)
}
pub(crate) fn ensure_compatible(&self, inp: &InputRelationHandle) -> Result<()> {
pub(crate) fn ensure_compatible(&self, inp: &InputRelationHandle, is_remove: bool) -> Result<()> {
let InputRelationHandle { metadata, .. } = inp;
// check that every given key is found and compatible
for col in &metadata.keys {
@ -176,8 +176,10 @@ impl RelationHandle {
for col in &self.metadata.keys {
metadata.satisfied_by_required_col(col, true)?;
}
for col in &self.metadata.non_keys {
metadata.satisfied_by_required_col(col, false)?;
if !is_remove {
for col in &self.metadata.non_keys {
metadata.satisfied_by_required_col(col, false)?;
}
}
Ok(())
}

Loading…
Cancel
Save