ash v0.1.8 Ash.Filter View Source

A filter expression in Ash.

The way we represent filters may be strange, but its important to have it structured, as merging and checking filter subsets are used all through ash for things like authorization. The ands of a filter are not subject to its ors. The not of a filter is also not subject to its ors. For instance, if a filter A has two ands, B and C and two ors, D and E, and a not of F, the expression as can be represented as (A or D or E) and NOT F and B and C.

The filters attributes and relationships, are subject to the ors of that filter.

<and_statements> AND NOT <not_statement> AND (<one_of_or_statements> OR <attributes + relationships>)

This probably needs to be refactored into something more representative of its behavior, like a series of nested boolean expression structs w/ a reference to the attribute/relationship it references. Maybe. This would be similar to Ecto's BooleanExpr structs.

Link to this section Summary

Link to this section Types

Link to this type

t()

View Source
t() :: %Ash.Filter{
  ands: term(),
  api: Ash.api(),
  attributes: Keyword.t(),
  errors: [String.t()],
  impossible?: boolean(),
  not:
    %Ash.Filter{
      ands: term(),
      api: term(),
      attributes: term(),
      errors: term(),
      impossible?: term(),
      not: term(),
      ors: term(),
      path: term(),
      relationships: term(),
      requests: term(),
      resource: term()
    }
    | nil,
  ors: [
    %Ash.Filter{
      ands: term(),
      api: term(),
      attributes: term(),
      errors: term(),
      impossible?: term(),
      not: term(),
      ors: term(),
      path: term(),
      relationships: term(),
      requests: term(),
      resource: term()
    }
    | nil
  ],
  path: [atom()],
  relationships: map(),
  requests: [Ash.Engine.Request.t()],
  resource: Ash.resource()
}

Link to this section Functions

Link to this function

add_to_filter(filter, addition)

View Source
Link to this function

count_of_clauses(filter)

View Source
Link to this function

get_pkeys(map, api, item)

View Source
Link to this function

parse(resource, filter, api, path \\ [])

View Source
parse(Ash.resource(), Keyword.t(), Ash.api(), relationship_path :: [atom()]) ::
  t()

Parse a filter from a filter expression

The only rason to pass api would be if you intend to leverage any engine requests that would be generated by this filter.

Link to this function

parse_predicates(resource, keyword, attr_name, attr_type)

View Source
Link to this function

predicate_strict_subset_of?(attribute, left, right)

View Source
Link to this function

primary_key_filter?(filter)

View Source
Link to this function

request_filter_for_fetch(filter, data)

View Source
Link to this function

strict_subset_of(filter, candidate)

View Source

Returns true if the second argument is a strict subset (always returns the same or less data) of the first

Link to this function

strict_subset_of?(filter, candidate)

View Source