Skip to content

Commit a64f977

Browse files
bpamiriclaude
andcommitted
fix: Add returnAs=query to status counts findAll for aggregate column access
Wheels findAll returns model objects by default, stripping columns that aren't model properties. The COUNT(*) aggregate needs a raw query result to be accessible. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c631943 commit a64f977

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/controllers/web/BlogController.cfc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ component extends="app.Controllers.Controller" {
3030
statuses = blogStatuses();
3131

3232
var statusCountsQuery = model("Blog").findAll(
33-
select = "statusId, COUNT(*) as CNT",
33+
select = "statusId, COUNT(*) as cnt",
3434
where = "createdBy = #userId# AND blog_posts.statusId <> #statuses.TRASH#",
35-
group = "statusId"
35+
group = "statusId",
36+
returnAs = "query"
3637
);
3738

3839
statusCounts = {"all" = 0, "draft" = 0, "published" = 0, "pending" = 0};

0 commit comments

Comments
 (0)