Skip to content

Commit

Permalink
Change ignore wording for filters
Browse files Browse the repository at this point in the history
  • Loading branch information
acerbusace committed Nov 8, 2024
1 parent 367c495 commit 2eab677
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions elasticgraph-graphql/spec/acceptance/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ module ElasticGraph
string_hash_of(widget1, :id, :amount_cents)
])

# Verify that we can filter on `DateTime` fields (and that `nil` DateTime filter values are ignored)
# Verify that we can filter on `DateTime` fields (and that `nil` DateTime filter values are pruned treating them as `true`)
widgets = list_widgets_with(:created_at,
filter: {created_at: {gte: "2019-07-02T12:00:00Z", lt: nil}},
order_by: [:created_at_ASC])
Expand Down Expand Up @@ -229,7 +229,7 @@ module ElasticGraph
string_hash_of(widget2, :id, created_at: "2019-07-02T12:00:00.000Z")
])

# Verify that we can filter on `Date` fields (and that `nil` Date filter values are ignored)
# Verify that we can filter on `Date` fields (and that `nil` Date filter values are pruned treating them as `true`)
widgets = list_widgets_with(:created_on,
filter: {created_on: {lte: "2019-07-02", gte: nil}},
order_by: [:created_on_ASC])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def search_datastore(**options, &before_msearch)
expect(results).to match_array(ids_of(team2))
end

it "correctly ignores nil filters under `any_satisfy`" do
it "correctly prunes nil filters under `any_satisfy` treating them as `true`" do
results = search_with_filter("current_players_nested", "any_satisfy", {
"name" => {"equal_to_any_of" => nil},
"nicknames" => {"any_satisfy" => {"equal_to_any_of" => nil}}
Expand Down Expand Up @@ -1220,7 +1220,7 @@ def search_datastore(**options, &before_msearch)
expect(inner_not_result3).to eq(outer_not_result3).and eq []
end

it "is ignored when set to nil inside `any_of`" do
it "is pruned when set to nil inside `any_of` treating it as `true`" do
index_into(
graphql,
widget1 = build(:widget, amount_cents: 100),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class GraphQL
}]
end

it "ignores empty filters" do
it "prunes empty filters treating them as `true`" do
query = aggregation_query_of(name: "teams", sub_aggregations: [
nested_sub_aggregation_of(path_in_index: ["current_players_nested"], query: sub_aggregation_query_of(name: "current_players_nested", filter: {
"name" => {"equal_to_any_of" => nil}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ module Aggregation
}]
end

it "ignores an empty filter" do
it "prunes an empty filter treating it as `true`" do
aggs = {
"target:seasons_nested" => {"doc_count" => 423, "meta" => outer_meta}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,13 @@ class GraphQL
]}})
end

it "is ignored when `null` is passed" do
it "is pruned when `null` is passed treating it as `true`" do
query = new_query(filter: {"tags" => {"all_of" => nil}})

expect(datastore_body_of(query)).to not_filter_datastore_at_all
end

it "is ignored when `[]` is passed" do
it "is pruned when `[]` is passed treating it as `true`" do
query = new_query(filter: {"tags" => {"all_of" => []}})

expect(datastore_body_of(query)).to not_filter_datastore_at_all
Expand Down Expand Up @@ -786,7 +786,7 @@ class GraphQL
})
end

it "ignores `count` filter predicates that have a `nil` or `{}` value" do
it "prunes `count` filter predicates that have a `nil` or `{}` value treating it as `true`" do
query = new_query(filter: {"past_names" => {LIST_COUNTS_FIELD => nil}})
expect(datastore_body_of(query)).to not_filter_datastore_at_all

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class GraphQL
expect(parts).to eq []
end

it "ignores `nil` when `equal_to_any_of` includes `nil` with other timestamps" do
it "prunes `nil` when `equal_to_any_of` includes `nil` with other timestamps treating it as `true`" do
parts = search_index_expression_parts_for({"created_at" => {"equal_to_any_of" => [
"2021-01-15T12:30:00Z",
nil,
Expand Down Expand Up @@ -325,7 +325,7 @@ class GraphQL
end

%w[equal_to_any_of gt gte lt lte any_of].each do |operator|
it "ignores a `nil` value for a `#{operator}` filter" do
it "prunes a `nil` value for a `#{operator}` filter treating it as `true`" do
parts = search_index_expression_parts_for({"created_at" => {operator => nil}})

expect(parts).to target_all_widget_indices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def self.grouped_field_from(agg_hash)
})
end

it "ignores empty filters" do
it "prunes empty filters treating them as `true`" do
query = new_query(aggregations: [aggregation_query_of(name: "teams", sub_aggregations: [
nested_sub_aggregation_of(path_in_index: ["current_players_nested"], query: sub_aggregation_query_of(name: "current_players_nested", filter: {
"name" => {"equal_to_any_of" => nil}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ class QueryAdapter
end

describe "`null` leaves" do
it "ignores `filter: null`" do
it "prunes `filter: null` treating it as true" do
query = datastore_query_for(:Query, :components, <<~QUERY)
query {
components(filter: null) {
Expand All @@ -547,7 +547,7 @@ class QueryAdapter
expect(query.filters).to contain_exactly(exclude_incomplete_docs_filter)
end

it "ignores a `field: null` filter since it will get pruned" do
it "prunes `field: null` filter treating it as `true`" do
query = datastore_query_for(:Query, :components, <<~QUERY)
query {
components(filter: {cost: null}) {
Expand Down Expand Up @@ -579,7 +579,7 @@ class QueryAdapter
expect(query.filters).to contain_exactly({"cost" => nil, "name" => {"equal_to_any_of" => ["thingy"]}})
end

it "ignores a `field: {predicate: null}` filter since it will get pruned" do
it "prunes `field: {predicate: null}` filter treating it as `true`" do
query = datastore_query_for(:Query, :components, <<~QUERY)
query {
components(filter: {cost: {equal_to_any_of: null}}) {
Expand Down Expand Up @@ -614,7 +614,7 @@ class QueryAdapter
})
end

it "ignores a `null` filter since it will get pruned" do
it "prunes `null` filter treating it as `true`" do
query = datastore_query_for(:Query, :components, <<~QUERY)
query {
components(filter: {options: null}) {
Expand Down Expand Up @@ -649,7 +649,7 @@ class QueryAdapter
})
end

it "ignores a `parent_field: {child_field: null}` filter since it will get pruned" do
it "prunes `parent_field: {child_field: null}` filter treating it as true" do
query = datastore_query_for(:Query, :components, <<~QUERY)
query {
components(filter: {options: {size: null}}) {
Expand Down Expand Up @@ -684,7 +684,7 @@ class QueryAdapter
})
end

it "ignores a `parent_field: {child_field: {predicate: null}}` filter since it will get pruned" do
it "prunes `parent_field: {child_field: {predicate: null}}` filter treating it as true" do
query = datastore_query_for(:Query, :components, <<~QUERY)
query {
components(filter: {options: {size: {equal_to_any_of: null}}}) {
Expand Down Expand Up @@ -932,7 +932,7 @@ class QueryAdapter
)
end

it "includes the incomplete doc exclusion filter when there are no sub-clauses, because the filter is ignored" do
it "includes the incomplete doc exclusion filter when there are no sub-clauses, because the filter is treated as `false` for being empty" do
query = datastore_query_for(:Query, :components, <<~QUERY)
query {
components(filter: {any_of: []}) {
Expand Down

0 comments on commit 2eab677

Please sign in to comment.