Development

#2823 (sfPropelActAsRatableBehavior doesn't seems to work with pgsql (and probably some other db))

You must first sign up to be able to contribute.

Ticket #2823 (new defect)

Opened 5 months ago

sfPropelActAsRatableBehavior doesn't seems to work with pgsql (and probably some other db)

Reported by: caeies Assigned to: fabien
Priority: major Milestone:
Component: plugins Version: 1.0.10
Keywords: sfPropelActAsRatableBehavior Cc: nperriault@gmail.com
Qualification: Unreviewed

Description

It looks like pgsql doesn't like the way some SELECT are done : typically the getRating() method use the COUNT() and SUM() method to build agregate. Unfortunately, only one GROUP BY is done (perhaps intentionnelly) and pgsql complains about that : he doesn't know how to aggregate columns that are selected. I don't have time to investigate, but I modified the lib/sfPropelActAsRatableBehavior.class.php like this :

Index: lib/sfPropelActAsRatableBehavior.class.php
===================================================================
--- lib/sfPropelActAsRatableBehavior.class.php  (revision 7146)
+++ lib/sfPropelActAsRatableBehavior.class.php  (working copy)
@@ -278,6 +278,10 @@
     $c->addAsColumn('nb_ratings', 'COUNT('.sfRatingPeer::ID.')');
     $c->addAsColumn('total', 'SUM('.sfRatingPeer::RATING.')');
     $c->addGroupByColumn(sfRatingPeer::RATABLE_MODEL);
+    $c->addGroupByColumn(sfRatingPeer::ID);
+    $c->addGroupByColumn(sfRatingPeer::RATABLE_ID);
+    $c->addGroupByColumn(sfRatingPeer::USER_ID);
+    $c->addGroupByColumn(sfRatingPeer::RATING);
     $rs = sfRatingPeer::doSelectRS($c);
     $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     while ($rs->next())