chore: allow page: [] in new pagination error

This commit is contained in:
Zach Daniel 2023-02-13 23:44:58 -05:00
parent 9924cfc7c0
commit 0c767d0fa1
2 changed files with 2 additions and 2 deletions

View file

@ -1197,7 +1197,7 @@ defmodule Ash.Api do
end
defp pagination_check(action, resource, opts) do
if Keyword.get(opts, :page) && !Map.get(action, :pagination) do
if Keyword.get(opts, :page) && Keyword.get(opts, :page) != [] && !Map.get(action, :pagination) do
{:error,
Ash.Error.to_error_class(
PageRequiresPagination.exception(resource: resource, action: action)

View file

@ -259,7 +259,7 @@ defmodule Ash.Test.Actions.ReadTest do
test "raises an error when page is sent but pagination is not enabled on a resource" do
res =
assert_raise Ash.Error.Invalid, fn ->
Api.read!(Post, page: [])
Api.read!(Post, page: [limit: 10])
end
assert %Ash.Error.Invalid.PageRequiresPagination{resource: Post, action: _} = hd(res.errors)