Skip to content

Commit c9d2814

Browse files
committed
Allow document operator in where
1 parent e413da1 commit c9d2814

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

rust/types/src/where_parsing.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,22 @@ pub fn parse_where(json_payload: &Value) -> Result<Where, WhereValidationError>
311311
}
312312
if operand.is_string() {
313313
let operand_str = operand.as_str().unwrap();
314+
let document_operator_type = match operator.as_str() {
315+
"$contains" => Some(DocumentOperator::Contains),
316+
"$not_contains" => Some(DocumentOperator::NotContains),
317+
"$regex" => Some(DocumentOperator::Regex),
318+
"$not_regex" => Some(DocumentOperator::NotRegex),
319+
_ => None,
320+
};
321+
if let Some(doc_op) = document_operator_type {
322+
if matches!(doc_op, DocumentOperator::Regex | DocumentOperator::NotRegex) {
323+
ChromaRegex::try_from(operand_str.to_string())?;
324+
}
325+
return Ok(Where::Document(crate::DocumentExpression {
326+
operator: doc_op,
327+
pattern: operand_str.to_string(),
328+
}));
329+
}
314330
let operator_type;
315331
if operator == "$eq" {
316332
operator_type = PrimitiveOperator::Equal;

0 commit comments

Comments
 (0)