0.27.0
·
31 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
Changed
- Require the
ecto_typeoption for join fields and custom fields. - Raise a
Flop.UnknownFieldErrorinstead of aFunctionClauseErrorwhen
Flop.Schema.field_info/2,Flop.Schema.get_field/2or
Flop.Filter.allowed_operators/2is called with a field that is not
configured in the schema. - Reject compound and alias fields as order fields for cursor pagination during
validation. They can still be used with offset and page based pagination. - Raise an
ArgumentErrorinstead of ignoring the filter when an unsupported
operator is applied to a compound field. This only affects unvalidated
filters.
Fixed
- Return an empty list from
Flop.aliases/2if theorder_byparameter is
nil, instead of raising aProtocol.UndefinedError. - Build the meta struct in
Flop.meta/3if neither a page size nor a limit is
set, instead of raising anArithmeticError. - Fall back to the first page or to offset
0inFlop.set_page/2and
Flop.set_offset/2if the given string is not a number, instead of raising
anArgumentError. - Merge adapter options passed at the call site with the options set on the
backend module, instead of discarding them.
Security
- Limit the number of filters that can be applied in one request to 20 by
default. Configurable with themax_filtersoption. - Remove the debug log on validation errors. It logged the changeset, which
contains the user-supplied filter values. The errors are returned to the
caller in theFlop.Metastruct, so nothing is lost.
How to upgrade
Add the ecto_type options to all Flop.Schema derivations that don't have it
already:
@derive {
Flop.Schema,
filterable: [],
sortable: [],
adapter_opts: [
join_fields: [
owner_age: [
binding: :owner,
field: :age,
+ ecto_type: :integer
]
],
custom_fields: [
partial_id: [
filter: {__MODULE__, :partial_id_filter, []},
+ ecto_type: :string
]
]
]
}Filter lists longer than 20 are now rejected with a validation error on
filters. If your query handles longer filter lists, pass the max_filters
option:
Flop.validate_and_run(Pet, params, for: Pet, max_filters: 50)The option can also be set via application environment or backend module.