-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add not_one_of test * add greater than test * add greater than or equal to test * Ensure we properly read negative numbers from the filter argument * add equal test * add not equal test * add less than test * add less than or equal to test * add one_of test * Add comment to each test that we added about why we use negative filter * ensure we safely pull number from fieldvalue in get_max_fold_count_limit * add test that filters for a count less than usize::max * make the test do what it said it was going to do * improve comment across all new added tests * fix docstring Co-authored-by: Predrag Gruevski <[email protected]> * fix the rest of the test files for not_eq test after previous commit * make test query names more clear * add comment about why we .min on Vec::with_capacity * fix output of fold_count_filter_one_of_with_negative_arg * add better comments to usize_from_fv and panic if we dont get a finite number * improve usize_from_field_value doc comment again * Update trustfall_core/src/interpreter/execution.rs Co-authored-by: Predrag Gruevski <[email protected]> --------- Co-authored-by: Predrag Gruevski <[email protected]>
- Loading branch information
1 parent
ab840bb
commit 7c84689
Showing
46 changed files
with
6,212 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...e/test_data/tests/valid_queries/fold_count_filter_eq_with_negative_arg.graphql-parsed.ron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
Ok(TestParsedGraphQLQuery( | ||
schema_name: "numbers", | ||
query: Query( | ||
root_connection: FieldConnection( | ||
position: Pos( | ||
line: 3, | ||
column: 5, | ||
), | ||
name: "Number", | ||
arguments: { | ||
"max": Int64(6), | ||
"min": Int64(4), | ||
}, | ||
), | ||
root_field: FieldNode( | ||
position: Pos( | ||
line: 3, | ||
column: 5, | ||
), | ||
name: "Number", | ||
coerced_to: Some("Composite"), | ||
connections: [ | ||
(FieldConnection( | ||
position: Pos( | ||
line: 5, | ||
column: 13, | ||
), | ||
name: "value", | ||
), FieldNode( | ||
position: Pos( | ||
line: 5, | ||
column: 13, | ||
), | ||
name: "value", | ||
output: [ | ||
OutputDirective(), | ||
], | ||
)), | ||
(FieldConnection( | ||
position: Pos( | ||
line: 7, | ||
column: 13, | ||
), | ||
name: "primeFactor", | ||
fold: Some(FoldGroup( | ||
fold: FoldDirective(), | ||
transform: Some(TransformGroup( | ||
transform: TransformDirective( | ||
kind: Count, | ||
), | ||
filter: [ | ||
FilterDirective( | ||
operation: Equals((), VariableRef("neg_two")), | ||
), | ||
], | ||
)), | ||
)), | ||
), FieldNode( | ||
position: Pos( | ||
line: 7, | ||
column: 13, | ||
), | ||
name: "primeFactor", | ||
connections: [ | ||
(FieldConnection( | ||
position: Pos( | ||
line: 8, | ||
column: 17, | ||
), | ||
name: "value", | ||
alias: Some("factors"), | ||
), FieldNode( | ||
position: Pos( | ||
line: 8, | ||
column: 17, | ||
), | ||
name: "value", | ||
alias: Some("factors"), | ||
output: [ | ||
OutputDirective(), | ||
], | ||
)), | ||
], | ||
transform_group: Some(TransformGroup( | ||
transform: TransformDirective( | ||
kind: Count, | ||
), | ||
filter: [ | ||
FilterDirective( | ||
operation: Equals((), VariableRef("neg_two")), | ||
), | ||
], | ||
)), | ||
)), | ||
], | ||
), | ||
), | ||
arguments: { | ||
"neg_two": Int64(-2), | ||
}, | ||
)) |
19 changes: 19 additions & 0 deletions
19
...all_core/test_data/tests/valid_queries/fold_count_filter_eq_with_negative_arg.graphql.ron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
TestGraphQLQuery ( | ||
// Ensure that we properly handle negative numbers in a `=` filter on a folded edge's count. | ||
schema_name: "numbers", | ||
query: r#" | ||
{ | ||
Number(min: 4, max: 6) { | ||
... on Composite { | ||
value @output | ||
primeFactor @fold @transform(op: "count") @filter(op: "=", value: ["$neg_two"]) { | ||
factors: value @output | ||
} | ||
} | ||
} | ||
}"#, | ||
arguments: { | ||
"neg_two": Int64(-2), | ||
}, | ||
) |
65 changes: 65 additions & 0 deletions
65
trustfall_core/test_data/tests/valid_queries/fold_count_filter_eq_with_negative_arg.ir.ron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
Ok(TestIRQuery( | ||
schema_name: "numbers", | ||
ir_query: IRQuery( | ||
root_name: "Number", | ||
root_parameters: EdgeParameters( | ||
contents: { | ||
"max": Int64(6), | ||
"min": Int64(4), | ||
}, | ||
), | ||
root_component: IRQueryComponent( | ||
root: Vid(1), | ||
vertices: { | ||
Vid(1): IRVertex( | ||
vid: Vid(1), | ||
type_name: "Composite", | ||
coerced_from_type: Some("Number"), | ||
), | ||
}, | ||
folds: { | ||
Eid(1): IRFold( | ||
eid: Eid(1), | ||
from_vid: Vid(1), | ||
to_vid: Vid(2), | ||
edge_name: "primeFactor", | ||
component: IRQueryComponent( | ||
root: Vid(2), | ||
vertices: { | ||
Vid(2): IRVertex( | ||
vid: Vid(2), | ||
type_name: "Prime", | ||
), | ||
}, | ||
outputs: { | ||
"factors": ContextField( | ||
vertex_id: Vid(2), | ||
field_name: "value", | ||
field_type: "Int", | ||
), | ||
}, | ||
), | ||
post_filters: [ | ||
Equals(Count, Variable(VariableRef( | ||
variable_name: "neg_two", | ||
variable_type: "Int!", | ||
))), | ||
], | ||
), | ||
}, | ||
outputs: { | ||
"value": ContextField( | ||
vertex_id: Vid(1), | ||
field_name: "value", | ||
field_type: "Int", | ||
), | ||
}, | ||
), | ||
variables: { | ||
"neg_two": "Int!", | ||
}, | ||
), | ||
arguments: { | ||
"neg_two": Int64(-2), | ||
}, | ||
)) |
16 changes: 16 additions & 0 deletions
16
...fall_core/test_data/tests/valid_queries/fold_count_filter_eq_with_negative_arg.output.ron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
TestInterpreterOutputData( | ||
schema_name: "numbers", | ||
outputs: { | ||
"factors": Output( | ||
name: "factors", | ||
value_type: "[Int]!", | ||
vid: Vid(2), | ||
), | ||
"value": Output( | ||
name: "value", | ||
value_type: "Int", | ||
vid: Vid(1), | ||
), | ||
}, | ||
results: [], | ||
) |
Oops, something went wrong.