KogenCredo.Check.Warning.LimitWithoutStableOrder (KogenCredo v0.1.0)
View SourceBasics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of low and works with any version of Elixir.
Explanation
limit without a total order_by returns an arbitrary subset when sort
values tie, so pagination repeats and skips rows.
Bad:
from(p in Post, order_by: [desc: p.inserted_at], limit: 20)Good:
from(p in Post, order_by: [desc: p.inserted_at, desc: p.id], limit: 20)Check-Specific Parameters
Use the following parameters to configure this check:
:unique_fields
Field names that are unique per row; one of them in order_by makes the order total.
This parameter defaults to [:id].
:ignore_limit_one
Skip literal limit(1) / limit: 1 (default true).
This parameter defaults to true.
:included_paths
Globs of files to check; empty means every file.
This parameter defaults to [].
:excluded_paths
Globs of files to skip (default ["test/**"]).
This parameter defaults to ["test/**"].
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.