-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use
AshSql
for running aggregate queries
this came up due to a bug where `ash_sqlite` was not applying filters. using the abstracted `AshSql.AggregateQuery` code both fixes the bug and ensures that `AshSqlite` gets the state of the art from the new(-ish) centralized `AshSql` code.
- Loading branch information
1 parent
2678759
commit 180c140
Showing
2 changed files
with
26 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule AshSqlite.AggregatesTest do | ||
use AshSqlite.RepoCase, async: false | ||
|
||
require Ash.Query | ||
alias AshSqlite.Test.Post | ||
|
||
test "a count with a filter returns the appropriate value" do | ||
Ash.Seed.seed!(%Post{title: "foo"}) | ||
Ash.Seed.seed!(%Post{title: "foo"}) | ||
Ash.Seed.seed!(%Post{title: "bar"}) | ||
|
||
count = | ||
Post | ||
|> Ash.Query.filter(title == "foo") | ||
|> Ash.count!() | ||
|
||
assert count == 2 | ||
end | ||
end |