John Siracusa wrote:
> On 6/14/07, Derek Watson <[EMAIL PROTECTED]> wrote:
>> 1. A fatal error is thrown when the object count is zero. I believe
>> this is happening around line 2749 of MakeMethods::Generic:
>>
>> $count =
>>   $ft_manager->$ft_count_method(query => [EMAIL PROTECTED], db =>
>>                                 $self->db, %args)
>>               or die $ft_manager->error;
>>
>> Which dies because $count is assigned zero, making the statement
>> evaluate false.
> 
> Whoops, careless copy/paste.  That's fixed in SVN now.
> 
>> 2. If I am counting objects related by a many-to-many where the
>> mapping table has a multi-valued primary key, the query generated is
>> something like
>>
>> SELECT
>>         COUNT(DISTINCT t1.a_id, t1.b_id)
>>         FROM
>>           a_b_map t1
>>           JOIN b t2 ON (t1.b_id = t2.id)
>>         WHERE
>>           t1.a_id=xxx
>>
>> But Postgres says
>>
>> ERROR:  function count(integer, integer) does not exist at character 9
> 
> Hm, what is the correct SQL in that case for Postgres?

Subselect?

SELECT count(*)
   FROM (
     SELECT DISTINCT a_id, b_id
       FROM a_b_map
      WHERE a_id = xxx
   ) s
;

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to