Justin Wienckowski | 22 Jul 18:59

Rails 2.1 upgrade problem with PostgreSQL 8.1


Hey folks,

I've been upgrading an application from rails 1.2.6 and 2.1, and most  
of it has gone smoothly, with one exception.  ActiveRecord is  
producing the following error on many queries with a PostgreSQL 8.1.5  
database:

ActiveRecord::StatementInvalid: PGError: ERROR:  for SELECT DISTINCT,  
ORDER BY expressions must appear in select list
: SELECT DISTINCT people.* FROM people    INNER JOIN subscriptions ON  
people.id = subscriptions.person_id    WHERE  
((subscriptions.publication_id = 1))  ORDER BY  
subscriptions.user_order asc

The full stack trace is at the bottom of this email.

This exact query seems to get run in a large number of places where  
I'm querying other objects (i.e. not Person) which are associated  
with Person.  I've tried using the postgres, pq, and postgres-pr gems  
(one at a time, not all installed at once), with no change.  I've  
attempted to eliminate as many upgrade issues as possible.  I've  
already updated all my plugins (will_paginate, acts_as_versioned,  
has_many_polymorphs) to confirmed rails-2.1 compatible versions,  
updated the postgres gem, and updated the rails config files.

I see a lot of code in the postgresql connection adapter that seems  
specific to postgres 8.3 or greater - but I was under the impression  
that the adapter was supposed to support postgres from 7.4 on up.   
I'm attempting to avoid upgrading my DB as it's shared among multiple  
(Continue reading)


Gmane