Skip to content

Commit

Permalink
you guys it works!
Browse files Browse the repository at this point in the history
  • Loading branch information
hallettj committed Nov 11, 2024
1 parent fe48f60 commit e9ee52a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
13 changes: 4 additions & 9 deletions crates/cli/src/native_query/pipeline/match_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,13 @@ fn analyze_match_operator(
&TypeConstraint::Scalar(BsonScalarType::Bool),
match_expression,
)?,
// In MongoDB $type accepts either a number, a string, an array of numbers, or an array of
// strings - for simplicity we're only accepting an array of strings since this form can
// express all comparisons that can be expressed with the other forms.
"$type" => analyze_match_expression(
context,
desired_object_type_name,
&TypeConstraint::OneOf(
[
TypeConstraint::Scalar(BsonScalarType::String),
TypeConstraint::ArrayOf(Box::new(TypeConstraint::Scalar(
BsonScalarType::String,
))),
]
.into(),
),
&TypeConstraint::ArrayOf(Box::new(TypeConstraint::Scalar(BsonScalarType::String))),
match_expression,
)?,
"$mod" => match match_expression {
Expand Down
1 change: 0 additions & 1 deletion crates/cli/src/native_query/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ fn supports_various_query_predicate_operators() -> googletest::Result<()> {
"num_mflix_comments": { "$in": "{{ num_comments_options }}" },
"$not": { "runtime": { "$lt": "{{ runtime }}" } },
"tomatoes.critic": { "$exists": "{{ critic_exists }}" },
"lastUpdated": { "$type": "date" },
"released": { "$type": ["date", "{{ other_type }}"] },
"$or": [
{ "$and": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ fn element_of(array_type: Type) -> Result<Type> {
let element_type = match array_type {
Type::ArrayOf(elem_type) => Ok(*elem_type),
Type::Nullable(t) => element_of(*t).map(|t| Type::Nullable(Box::new(t))),
Type::ExtendedJSON => Ok(Type::ExtendedJSON),
_ => Err(Error::ExpectedArray {
actual_type: array_type,
}),
Expand Down
1 change: 1 addition & 0 deletions crates/test-helpers/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub fn mflix_config() -> Configuration {
("num_mflix_comments", named_type("Int")),
("rated", named_type("String")),
("released", named_type("Date")),
("runtime", named_type("Int")),
("title", named_type("String")),
("writers", array_of(named_type("String"))),
("year", named_type("Int")),
Expand Down

0 comments on commit e9ee52a

Please sign in to comment.