fix unify query

main
Ziyang Hu 2 years ago
parent 934c54d05e
commit 4d8e560a96

@ -40,6 +40,9 @@ impl Keyword {
.0
.starts_with(['_', ':', '<', '.', '*', '#', '$', '?', '!', ']', '['])
}
pub(crate) fn is_query_var(&self) -> bool {
self.0.starts_with('?') && self.0.len() > 1
}
pub(crate) fn validate_not_reserved(&self) -> Result<()> {
ensure!(
!self.is_reserved(),

@ -100,7 +100,8 @@ impl DataValue {
pub(crate) fn get_entity_id(&self) -> Result<EntityId> {
match self {
DataValue::EnId(id) => Ok(*id),
v => bail!("type mismatch: expect type {:?}, got value {:?}", self, v),
DataValue::Int(id) => Ok(EntityId(*id as u64)),
v => bail!("type mismatch: expect type EntId, got value {:?}", self),
}
}
}

@ -186,7 +186,7 @@ impl SessionTx {
.ok_or_else(|| anyhow!("expect field 'unify' to be a keyword"))?;
let binding = Keyword::from(binding);
ensure!(
!binding.is_reserved(),
binding.is_query_var(),
"binding for unification {} is reserved",
binding
);

Loading…
Cancel
Save