[RDBO] Classless Rose::DB::Objects

2007-06-18 Thread mla
I'm interested in doing complex joins with RDBO but without having to map the results to specific Rose::DB::Object classes. I found a discussion along these lines from '05. http://www.gossamer-threads.com/lists/catalyst/users/3095 excerpt: "For funky SQL in the FROM clause or the column list,

Re: [RDBO] MakeMethods::Generic.pm 'count' interface errors

2007-06-18 Thread mla
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 => >>

Re: [RDBO] MakeMethods::Generic.pm 'count' interface errors

2007-06-18 Thread Randal L. Schwartz
> "Lars" == Lars Haugseth <[EMAIL PROTECTED]> writes: Lars> How to pick a separator character that is guaranteed not to appear in Lars> the column values, though? "StUfYFuNk". :) 10 points to those who remember where that's from. :) -- Randal L. Schwartz - Stonehenge Consulting Services, I

Re: [RDBO] MakeMethods::Generic.pm 'count' interface errors

2007-06-18 Thread Lars Haugseth
On Monday 18 June 2007 17:32:38 Ovid wrote: > - Original Message > From: Derek Watson <[EMAIL PROTECTED]> > > > > It seems like a simple concat (pg operator ||) would work in this case: > > > > > > SELECT COUNT(t1.a_id || t1.b_id) > > > > Ugh, I forgot the DISTINCT again: > > > > SELECT CO

Re: [RDBO] MakeMethods::Generic.pm 'count' interface errors

2007-06-18 Thread Randal L. Schwartz
> "Ovid" == Ovid <[EMAIL PROTECTED]> writes: Ovid> So what happens when you concatenate the IDs '1', '12' and '11', '2'? I think you need a separator in there: Ovid> SELECT COUNT(DISTINCT t1.a_id || '-' || t1.b_id) We need join(). :) -- Randal L. Schwartz - Stonehenge Consulting Ser

Re: [RDBO] MakeMethods::Generic.pm 'count' interface errors

2007-06-18 Thread Ovid
- Original Message From: Derek Watson <[EMAIL PROTECTED]> > > It seems like a simple concat (pg operator ||) would work in this case: > > > > SELECT COUNT(t1.a_id || t1.b_id) > > Ugh, I forgot the DISTINCT again: > > SELECT COUNT(DISTINCT t1.a_id || t1.b_id) > > But this is tested and wor

Re: [RDBO] MakeMethods::Generic.pm 'count' interface errors

2007-06-18 Thread Derek Watson
> It seems like a simple concat (pg operator ||) would work in this case: > > SELECT COUNT(t1.a_id || t1.b_id) Ugh, I forgot the DISTINCT again: SELECT COUNT(DISTINCT t1.a_id || t1.b_id) But this is tested and works properly too. -

Re: [RDBO] MakeMethods::Generic.pm 'count' interface errors

2007-06-18 Thread Derek Watson
> What you need is > > COUNT(DISTINCT some_function_that_joins_all_args(arg, arg)) > > because you really want "4,5" to be counted distinctly from "4,6". > So coalesce definitely doesn't do it. Right, It seems like a simple concat (pg operator ||) would work in this case: SELECT COUNT(t1.a_id

Re: [RDBO] MakeMethods::Generic.pm 'count' interface errors

2007-06-18 Thread Randal L. Schwartz
> "John" == John Siracusa <[EMAIL PROTECTED]> writes: John> You need the DISTINCT part if you join with any ...-to-many John> relationship. I'm not sure in your example if the DISTINCT should John> have been there, but I can imagine cases where it will need to be John> there, so we need some

Re: [RDBO] MakeMethods::Generic.pm 'count' interface errors

2007-06-18 Thread John Siracusa
On 6/18/07, Derek Watson <[EMAIL PROTECTED]> wrote: > Postgres defines the function separately from count(*): > > count(expression) number of input values for which the value of > expression is not null > > In this case I would write > > SELECT COUNT(coalesce(t1.a_id, t1.b_id)) > > Which would coun

Re: [RDBO] MakeMethods::Generic.pm 'count' interface errors

2007-06-18 Thread Derek Watson
> > Which dies because $count is assigned zero, making the statement > > evaluate false. > > Whoops, careless copy/paste. That's fixed in SVN now. Great, thanks very much! > > > 2. If I am counting objects related by a many-to-many where the > > mapping table has a multi-valued primary key, the

Re: [RDBO] MakeMethods::Generic.pm 'count' interface errors

2007-06-18 Thread John Siracusa
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 => >