diff --git a/helix-db/src/helix_engine/vector_core/vector.rs b/helix-db/src/helix_engine/vector_core/vector.rs index 125949f0..a54a0c56 100644 --- a/helix-db/src/helix_engine/vector_core/vector.rs +++ b/helix-db/src/helix_engine/vector_core/vector.rs @@ -6,7 +6,7 @@ use crate::{ protocol::{return_values::ReturnValue, value::Value}, utils::{ filterable::{Filterable, FilterableType}, - id::v6_uuid, + id::{v6_uuid, ID}, }, }; use core::fmt; @@ -273,7 +273,7 @@ impl Filterable for HVector { fn check_property(&self, key: &str) -> Result, GraphError> { match key { - "id" => Ok(Cow::Owned(Value::from(self.uuid()))), + "id" => Ok(Cow::Owned(Value::Id(ID::from(self.id)))), "label" => Ok(Cow::Owned(Value::from(self.label().to_string()))), "data" => Ok(Cow::Owned(Value::Array( self.data.iter().map(|f| Value::F64(*f)).collect(), diff --git a/helix-db/src/helixc/analyzer/methods/traversal_validation.rs b/helix-db/src/helixc/analyzer/methods/traversal_validation.rs index b8a98473..bc73bae3 100644 --- a/helix-db/src/helixc/analyzer/methods/traversal_validation.rs +++ b/helix-db/src/helixc/analyzer/methods/traversal_validation.rs @@ -1,5 +1,5 @@ use crate::helixc::analyzer::error_codes::*; -use crate::helixc::analyzer::utils::{check_identifier_is_fieldtype, DEFAULT_VAR_NAME}; +use crate::helixc::analyzer::utils::{DEFAULT_VAR_NAME, check_identifier_is_fieldtype}; use crate::helixc::generator::bool_ops::{Contains, IsIn}; use crate::helixc::generator::source_steps::{SearchVector, VFromID, VFromType}; use crate::helixc::generator::traversal_steps::{AggregateBy, GroupBy}; @@ -719,8 +719,7 @@ pub(crate) fn validate_traversal<'a>( | BooleanOpType::GreaterThan(expr) | BooleanOpType::Equal(expr) | BooleanOpType::NotEqual(expr) - | BooleanOpType::Contains(expr) - | BooleanOpType::IsIn(expr) => { + | BooleanOpType::Contains(expr) => { match infer_expr_type( ctx, expr, @@ -744,6 +743,42 @@ pub(crate) fn validate_traversal<'a>( } } } + BooleanOpType::IsIn(expr) => { + match infer_expr_type( + ctx, + expr, + scope, + original_query, + Some(cur_ty.clone()), + gen_query, + ) { + (Type::Array(boxed_ty), _) => match *boxed_ty { + Type::Scalar(ft) => ft, + _ => { + generate_error!( + ctx, + original_query, + b_op.loc.clone(), + E621, + &b_op.loc.span, + "Array elements must be of a scalar type (e.g., ID, String, F32, I32, etc.)" + ); + return Some(Type::Unknown); + } + }, + (field_type, _) => { + generate_error!( + ctx, + original_query, + b_op.loc.clone(), + E621, + &b_op.loc.span, + field_type.kind_str() + ); + return Some(field_type); + } + } + } _ => return Some(cur_ty.clone()), }; diff --git a/helix-db/src/utils/filterable.rs b/helix-db/src/utils/filterable.rs index aca51c3e..2ba771ad 100644 --- a/helix-db/src/utils/filterable.rs +++ b/helix-db/src/utils/filterable.rs @@ -123,7 +123,7 @@ impl Filterable for Node { #[inline(always)] fn check_property(&self, key: &str) -> Result, GraphError> { match key { - "id" | "ID" | "Id"=> Ok(Cow::Owned(Value::String(ID::from(self.id).stringify()))), + "id" | "ID" | "Id"=> Ok(Cow::Owned(Value::Id(ID::from(self.id)))), "label" => Ok(Cow::Owned(Value::from(self.label.to_string()))), _ => match &self.properties { Some(properties) => properties @@ -227,7 +227,7 @@ impl Filterable for Edge { #[inline(always)] fn check_property(&self, key: &str) -> Result, GraphError> { match key { - "id" => Ok(Cow::Owned(Value::from(self.uuid()))), + "id" => Ok(Cow::Owned(Value::Id(ID::from(self.id)))), "label" => Ok(Cow::Owned(Value::from(self.label.to_string()))), "from_node" => Ok(Cow::Owned(Value::from(self.from_node_uuid()))), "to_node" => Ok(Cow::Owned(Value::from(self.to_node_uuid()))),