Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions helix-db/src/helix_engine/vector_core/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -273,7 +273,7 @@ impl Filterable for HVector {

fn check_property(&self, key: &str) -> Result<Cow<'_, Value>, 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(),
Expand Down
41 changes: 38 additions & 3 deletions helix-db/src/helixc/analyzer/methods/traversal_validation.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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,
Expand All @@ -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()),
};

Expand Down
4 changes: 2 additions & 2 deletions helix-db/src/utils/filterable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl Filterable for Node {
#[inline(always)]
fn check_property(&self, key: &str) -> Result<Cow<'_,Value>, 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
Expand Down Expand Up @@ -227,7 +227,7 @@ impl Filterable for Edge {
#[inline(always)]
fn check_property(&self, key: &str) -> Result<Cow<'_,Value>, 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()))),
Expand Down
Loading