#407 ✓resolved
Michael Klishin (antares)

dm-aggregates generates SQL that breaks on PostgreSQL

Reported by Michael Klishin (antares) | June 23rd, 2008 @ 12:04 AM

dm-aggregates suite run with PostgreSQL fails on 44 of 52 examples with invalid SQL like this:

SELECT MAX("toes_on_claw") FROM "dragons" ORDER BY "id"

Errors look like this:

PostgresError in 'DataMapper::Resource.min on a model with a property name should provide the lowest value of an Integer property'

ERROR: column "dragons.id" must appear in the GROUP BY clause or be used in an aggregate function

It is PostgreSQL specific issue. Prolem is in


and I could not fix it in 10 minutes so no patches yet.

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) June 23rd, 2008 @ 01:40 AM

    Perhaps we should make it so the ORDER BY is not used in the simple aggregate functions? As of right now there's no GROUP BY, so ordering doesn't make sense since there's not going to be anymore than a single row.

    When GROUP BY makes it in we can make it so the default ORDER BY is equal to the GROUP BY fields, which themselves are equal to the non-aggregate function fields in SELECT.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) June 23rd, 2008 @ 07:39 PM

    • Assigned user changed from “Sam Smoot” to “Dan Kubb (dkubb)”
    • State changed from “new” to “open”
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) June 24th, 2008 @ 12:13 PM

    • Milestone cleared.
    • State changed from “open” to “resolved”

    The following commit resolves the issue:


    I am marking this ticket as resolved. If the problem persists please reply and I will reopen it.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »