Changelog

View Source

0.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/7 options:
    • :default_limit and :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 the query JSON holds the search text (default "q").
    • :include_schema (default true) - set false to leave the schema key (the Elixir module name) out of the envelope and every record.
    • :include_debug (default true) - set false to leave the debug block (params and specs) out of error responses.
  • QueryEngine.get/5 options: :by (look up by another field, such as :key), :base_queryable (scope the lookup), :include_schema, :include_debug.
  • QueryEngine.build/4 takes :search and :search_param.
  • QueryPager.paging/2, QueryPager.apply/2, QueryPager.page_info/2: work out limit and offset once, so the rows returned and page_info agree.
  • QuerySerializer: overridable serializer_virtual_fields/1 (default []) to serialize virtual fields, such as a search snippet set with select_merge. A schema that already defines a function with that name and arity must rename it.
  • Preloads may scope rows with a query, assoc: query or assoc: {query, nested}; serialization follows the nested part.
  • JS codegen maps binary_id, Ecto.UUID, decimal, *_usec datetimes, time, {:array, t}, {:map, t} and Ecto.Enum instead of any, and includes serializer_virtual_fields/1.

Fixed

  • get/5 works for non-integer primary keys (UUIDs, slugs): string ids are cast to the key's type instead of String.to_integer/1.
  • Index counts use the schema's primary key instead of :id, so tables keyed by a slug count correctly.
  • limit and offset sent as integer strings are applied, not only reported.
  • Errors raised while querying, counting or serializing are returned as error responses instead of escaping (catch only caught throws before).
  • JS codegen: the show result typedef names results, the key the engine actually returns (it said result); results.schema is optional; ResourceServiceMethods ids are number | string.

Behaviour changes

  • A malformed query param (invalid JSON) returns {:error, %{status: 400}} instead of raising Jason.DecodeError.
  • An unknown sort key is dropped instead of raising ArgumentError.
  • get/5 with an id that can't be cast to the key's type ("abc" for an integer key) returns a 404 instead of raising ArgumentError.
  • QueryPager.compute_pagination/2 ignores a non-integer limit/offset string 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.