Changelog
View Source0.2.9
Backwards compatible for callers that pass no new options, except where marked Behaviour change. Every function keeps its name and arity.
Added
QueryEngine.all/7options::default_limitand:max_limit(server-side page size and cap).:search- opt-in text search hook,{module, function}or a 2-arity function called as(query, text)when the request's search text is non-blank. Ignored when not given.:search_param- which key of thequeryJSON holds the search text (default"q").:include_schema(defaulttrue) - setfalseto leave theschemakey (the Elixir module name) out of the envelope and every record.:include_debug(defaulttrue) - setfalseto leave thedebugblock (params and specs) out of error responses.
QueryEngine.get/5options::by(look up by another field, such as:key),:base_queryable(scope the lookup),:include_schema,:include_debug.QueryEngine.build/4takes:searchand:search_param.QueryPager.paging/2,QueryPager.apply/2,QueryPager.page_info/2: work out limit and offset once, so the rows returned andpage_infoagree.QuerySerializer: overridableserializer_virtual_fields/1(default[]) to serialize virtual fields, such as a search snippet set withselect_merge. A schema that already defines a function with that name and arity must rename it.- Preloads may scope rows with a query,
assoc: queryorassoc: {query, nested}; serialization follows the nested part. - JS codegen maps
binary_id,Ecto.UUID,decimal,*_usecdatetimes,time,{:array, t},{:map, t}andEcto.Enuminstead ofany, and includesserializer_virtual_fields/1.
Fixed
get/5works for non-integer primary keys (UUIDs, slugs): string ids are cast to the key's type instead ofString.to_integer/1.- Index counts use the schema's primary key instead of
:id, so tables keyed by a slug count correctly. limitandoffsetsent as integer strings are applied, not only reported.- Errors raised while querying, counting or serializing are returned as error
responses instead of escaping (
catchonly caught throws before). - JS codegen: the show result typedef names
results, the key the engine actually returns (it saidresult);results.schemais optional;ResourceServiceMethodsids arenumber | string.
Behaviour changes
- A malformed
queryparam (invalid JSON) returns{:error, %{status: 400}}instead of raisingJason.DecodeError. - An unknown sort key is dropped instead of raising
ArgumentError. get/5with an id that can't be cast to the key's type ("abc"for an integer key) returns a 404 instead of raisingArgumentError.QueryPager.compute_pagination/2ignores a non-integerlimit/offsetstring instead of raising.- A filter spec naming a field the schema doesn't have still raises: that is a bug in the caller, not a bad request.