From f97ee16f9e3774a64446a0a1cb37ced7e6fa63a0 Mon Sep 17 00:00:00 2001 From: Rebecca Le Date: Wed, 4 Feb 2026 14:35:25 +0800 Subject: [PATCH] fix: correct test expectation for `first` aggregate with `include_nil?` The test was asserting buggy behavior. With `sort(title: :asc_nils_first)` and `include_nil?: true`, the `first` aggregate should return `nil` when the first sorted record has a nil value, not skip to the next non-nil value. --- test/aggregate_test.exs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/aggregate_test.exs b/test/aggregate_test.exs index 7d299f40..a4d67ee3 100644 --- a/test/aggregate_test.exs +++ b/test/aggregate_test.exs @@ -874,7 +874,9 @@ defmodule AshSql.AggregateTest do |> Ash.Changeset.manage_relationship(:post, post, type: :append_and_remove) |> Ash.create!() - assert "match" == + # With sort(title: :asc_nils_first), nil comes first. + # With include_nil?: true, we should get nil (not skip to the next non-nil value) + assert nil == Post |> Ash.Query.filter(id == ^post.id) |> Ash.Query.load(:first_comment_nils_first_include_nil)