From facf5c570ad281be1f5e7f2eb6130c67187f19f1 Mon Sep 17 00:00:00 2001 From: Florian Arens <60519307+Flo0807@users.noreply.github.com> Date: Fri, 24 Jan 2025 10:09:55 +0100 Subject: [PATCH] Update upgrade guide --- guides/upgrading/v0.11.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/guides/upgrading/v0.11.md b/guides/upgrading/v0.11.md index 3ec41639..f533f9b0 100644 --- a/guides/upgrading/v0.11.md +++ b/guides/upgrading/v0.11.md @@ -17,3 +17,31 @@ Update Backpex to the latest version: In case you are using `Backpex.Resource` or one of the `Backpex.Adapter` modules (`Backpex.Adapters.Ecto` or `Backpex.Adapters.Ash`) directly check out the updated function definitions. This will also apply in case you built your own adapter. + +## Make sure to cover all cases with the `item_query/3` function + +We have removed code that ensures that a fallback item query function is always added to your LiveResource. + +Make sure to always cover all possible cases or add a fallback `item_query/3` function that just returns the query. + +For example: + +```elixir +# in your resource configuration file (live resource) +use Backpex.LiveResource, + # ...other options + adapter_config: [ + # ...other adapter options + item_query: &__MODULE__.item_query/3 + ] + + def item_query(query, :index, _assigns) do + query + |> where([post], post.published) + end + + # make sure to add this fallback function + def item_query(query, _live_action, _assigns) do + query + end +``` \ No newline at end of file