Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

V7.0.5 with Postgres: list(max:...) causes exception on totalCount #297

@Grestorn

Description

@Grestorn

I've just updated my rather large project to Grails 4.0.11 from 3.3. One problem which I couldn't fix seems to be a regression with GORM 7.0.5 on Postgres:

This simple code:

   def activity(Integer max) {
        max = max ?: 50
        params.max = max
        if(!params.sort)
            params.sort = "created"
        if(!params.order)
            params.order = "desc"

        def activityList = Activity.list(params)

        render view:"activity", model:[activityList: activityList, count: activityList.getTotalCount()]
    }

is translated by GORM into

select distinct count(activity0_.id) as col_0_0_ from grails_activity activity0_ order by activity0_.created desc

which, on postgresql causes the following exception

ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list

For "totalCount" there seems to be no necessity to even include the order clause to the SQL statement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions