ex_admin
ex_admin copied to clipboard
Index sort
Please help, how to sort grid index as: :grid, columns: 4
? I have tried to define order in scope :all
but it doesn't call all
even by clicking it in scopes panel.
In a custom scope like this Ecto returns "expected at most one result but got 10 in query":
from p in Post,
where: not is_nil(p.details),
group_by: [p.id, p.name],
order_by: [asc: p.name]
Something likes this doesn't work too:
query do
%{all: [order_by: [asc: :name]]}
end
Try this for your all scope
scope :all, [default: true], fn(q) ->
order_by(q, [p], asc: p.name)
end
I have tried this already, doesn't work. Query:
SELECT c0."id", ... c0."inserted_at", FROM "blog"."posts" AS c0 ORDER BY c0."id" DESC LIMIT $1 OFFSET $2 [10, 0]
If I change scope to something other than :all, than there should be group_by:
scope :ordered, [default: true], fn(q) ->
group_by(q, [p], [:id, :name])
|> order_by([p], asc: p.name)
end
And response contains error:
expected at most one result but got 10 in query:
from b in Blog.Post,
group_by: [b.id, b.name],
order_by: [asc: b.name],
select: count(b.id)
I have tried to add |> limit([p], 1)
Then app generates two queries. One for All with an order by id, and another one
SELECT count(p0."id") FROM "blog"."post" AS p0 GROUP BY p0."id", p0."name" ORDER BY p0."name" LIMIT 1
- this is definitely wrong.
What version of ExAdmin?
Commit from May 16
I'll try to get some time tonight to look at it. Would be best if you could provide a sample project that reproduces the issue.
I have tried with your Ex_Admin Demo project. Same bugs. :all - nothing changed, :available - expected at most one result but got 16 in query.
ok. Thanks, I'll troubleshoot with that.
Thank you!