diff --git a/src/data/keyword.rs b/src/data/keyword.rs index 1697c6ae..1d1e5b92 100644 --- a/src/data/keyword.rs +++ b/src/data/keyword.rs @@ -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(), diff --git a/src/data/value.rs b/src/data/value.rs index 0c7393b1..27e68acc 100644 --- a/src/data/value.rs +++ b/src/data/value.rs @@ -100,7 +100,8 @@ impl DataValue { pub(crate) fn get_entity_id(&self) -> Result { 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), } } } diff --git a/src/parse/query.rs b/src/parse/query.rs index 32b97410..7c6094f7 100644 --- a/src/parse/query.rs +++ b/src/parse/query.rs @@ -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 );