Skip Menu |

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 64977
Status: rejected
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: rob [...] robboerman.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.08120
Fixed in: (no value)



Subject: +select +as in resultset search does not add a column
When I add additional columns to my resultset with the +select attribute and +as modifier to give it a custom name, I cannot access the resulting column in the resultset. EG: my $objects = $self->schema->resultset('Todo')->search(undef,{ +select => [ \'DATEDIFF(me.duedate,NOW())' ], +as => [ 'daysleft' ] }); Resultset: '_column_data' => { 'owner' => '1', 'status' => 'open', 'name' => 'test validation', 'type' => '1', 'id' => '18', 'duedate' => undef } When I manually select the columns with normal 'select' and 'as' modifiers it does work
On Fri Jan 21 05:25:30 2011, rboerman wrote: Show quoted text
> When I add additional columns to my resultset with the +select > attribute and +as modifier to > give it a custom name, I cannot access the resulting column in the > resultset. EG: > > my $objects = $self->schema->resultset('Todo')->search(undef,{ > +select => [ > \'DATEDIFF(me.duedate,NOW())' > ], > +as => [ > 'daysleft' > ] > });
$objects now does not contain "objects", it contains another resultset instance. You can call again search() on it or get something out of it with ->all/->next Show quoted text
> > Resultset: > > '_column_data' => { > 'owner' => '1', > 'status' => 'open', > 'name' => 'test validation', > 'type' => '1', > 'id' => '18', > 'duedate' => undef > }
Perhaps you mean s/Resultset/Result/ ? Show quoted text
> When I manually select the columns with normal 'select' and 'as' > modifiers it does work
You marked this ticket as "broken in 0.08120". The current version is 0.08127. What exactly are you using?
From: rob [...] robboerman.com
On Fri 21 Jan 2011 05:30:59, RIBASUSHI wrote: Show quoted text
> On Fri Jan 21 05:25:30 2011, rboerman wrote:
> > When I add additional columns to my resultset with the +select > > attribute and +as modifier to > > give it a custom name, I cannot access the resulting column in the > > resultset. EG: > > > > my $objects = $self->schema->resultset('Todo')->search(undef,{ > > +select => [ > > \'DATEDIFF(me.duedate,NOW())' > > ], > > +as => [ > > 'daysleft' > > ] > > });
> > $objects now does not contain "objects", it contains another resultset > instance. You can call again search() on it or get something out of it > with ->all/->next >
You're right, I am looping through the records with ->next. When I dump the resultset with as_query it does create the correct SQL statement including the aliased column, but the records themselves don't. Show quoted text
> > > > Resultset: > > > > '_column_data' => { > > 'owner' => '1', > > 'status' => 'open', > > 'name' => 'test validation', > > 'type' => '1', > > 'id' => '18', > > 'duedate' => undef > > }
> > Perhaps you mean s/Resultset/Result/ ?
Absolutely right, sorry for that Show quoted text
>
> > When I manually select the columns with normal 'select' and 'as' > > modifiers it does work
> > You marked this ticket as "broken in 0.08120". The current version is > 0.08127. What exactly are you using? >
I am running on a Debian Lenny server. It includes version 0.08120. I did not find any fixes for this in the changelogs however in newer versions.
On Fri Jan 21 05:37:20 2011, rboerman wrote: Show quoted text
> On Fri 21 Jan 2011 05:30:59, RIBASUSHI wrote:
> > On Fri Jan 21 05:25:30 2011, rboerman wrote:
> > > When I add additional columns to my resultset with the +select > > > attribute and +as modifier to > > > give it a custom name, I cannot access the resulting column in the > > > resultset. EG: > > > > > > my $objects = $self->schema->resultset('Todo')->search(undef,{ > > > +select => [ > > > \'DATEDIFF(me.duedate,NOW())' > > > ], > > > +as => [ > > > 'daysleft' > > > ] > > > });
> >
The above search is completely legitimate. Show quoted text
> >
> I am running on a Debian Lenny server. It includes version 0.08120. I > did not find any fixes > for this in the changelogs however in newer versions. >
This is a silly argument. None of the developers will go chasing bugs without ample proof the problem is present in current versions. Please confirm the problem on 0.08127 (or for that matter on 0.08123 available in debian testing).
On Fri Jan 21 05:25:30 2011, rboerman wrote: Show quoted text
> When I add additional columns to my resultset with the +select > attribute and +as modifier to > give it a custom name, I cannot access the resulting column in the > resultset. EG: > > my $objects = $self->schema->resultset('Todo')->search(undef,{ > +select => [ > \'DATEDIFF(me.duedate,NOW())' > ], > +as => [ > 'daysleft' > ] > });
In fact now that I look at this - is this the actual code? If yes - you are missing the quotes around +<something>. Consider: perl -MData::Dumper -E 'say Dumper { +foo => "bar", "+foo" => "baz" }'
Subject: Re: [rt.cpan.org #64977] +select +as in resultset search does not add a column
Date: Fri, 21 Jan 2011 15:26:28 +0100
To: bug-DBIx-Class [...] rt.cpan.org
From: Rob Boerman <rob [...] robboerman.com>
Hi, I actually checked it with the quotes around it. What I will do is prepare an example with full code and on the latest version Met vriendelijke groet, Rob Boerman
robboerman_logo_small.png
Op 21 jan 2011, om 12:48 heeft Peter Rabbitson via RT het volgende geschreven: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=64977 > > > On Fri Jan 21 05:25:30 2011, rboerman wrote:
>> When I add additional columns to my resultset with the +select >> attribute and +as modifier to >> give it a custom name, I cannot access the resulting column in the >> resultset. EG: >> >> my $objects = $self->schema->resultset('Todo')->search(undef,{ >> +select => [ >> \'DATEDIFF(me.duedate,NOW())' >> ], >> +as => [ >> 'daysleft' >> ] >> });
> > In fact now that I look at this - is this the actual code? If yes - you > are missing the quotes around +<something>. Consider: > > perl -MData::Dumper -E 'say Dumper { +foo => "bar", "+foo" => "baz" }' > >
From: rob [...] robboerman.com
Show quoted text
> I actually checked it with the quotes around it. What I will do is > prepare an example with full code and on the latest version
I confirmed the bug in 0.08127 I quickly created a short script that tries to add a calculated column to the results using the +select and +as modifier. According to the docs this should add an additional column to the results, but instead it ONLY fetches the additional column. <code> use strict; use lib qw(/home/rob/projects/afs/AFS/lib); use AFS::Schema; use Data::Dumper; my $schema = AFS::Schema->connect('dbi:mysql:afsdb','afsdb','lemmein'); my $objects = $schema->resultset('Todo')->search(undef); my $row = $objects->first; print "duedate:".$row->duedate."\n\n"; my $objects = $schema->resultset('Todo')->search(undef,{ +select => [ \'DATEDIFF(me.duedate,NOW())' ], +as => [ 'daysleft' ] }); my $row = $objects->first; print "duedate:".$row->duedate."\n"; print "calculated column daysleft: ".$row->get_column('daysleft')."\n\n"; $objects = $schema->resultset('Todo')->search(undef,{ +select => [ { 'DATEDIFF' => 'me.duedate,NOW()', -as => 'daysleft'} ] }); $row = $objects->first; print "duedate:".$row->duedate."\n"; print "calculated column daysleft: ".$row->get_column('daysleft')."\n\n"; </code> <output> rob@testbak:~/projects/temp$ DBIC_TRACE=1 perl DBIx-Class-bug.pl SELECT me.id, me.owner, me.name, me.duedate, me.memo, me.type, me.prepost, me.status FROM todos me: duedate:2011-01-01 SELECT DATEDIFF(me.duedate,NOW()) FROM todos me: duedate: calculated column daysleft: -33 SELECT DATEDIFF( me.duedate,NOW() ) AS daysleft FROM todos me: duedate: calculated column daysleft: -33 </output>
Subject: Re: [rt.cpan.org #64977] +select +as in resultset search does not add a column
Date: Thu, 03 Feb 2011 13:07:55 +0100
To: bug-DBIx-Class [...] rt.cpan.org
From: Peter Rabbitson <ribasushi [...] cpan.org>
Rob Boerman via RT wrote: Show quoted text
> Queue: DBIx-Class > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=64977 > >
>> I actually checked it with the quotes around it. What I will do is >> prepare an example with full code and on the latest version
> > I confirmed the bug in 0.08127 > > I quickly created a short script that tries to add a calculated column to the results using the > +select and +as modifier. According to the docs this should add an additional column to the > results, but instead it ONLY fetches the additional column. > > <code> > use strict; > use lib qw(/home/rob/projects/afs/AFS/lib); > use AFS::Schema; > use Data::Dumper; > my $schema = AFS::Schema->connect('dbi:mysql:afsdb','afsdb','lemmein'); > > my $objects = $schema->resultset('Todo')->search(undef); > > my $row = $objects->first; > print "duedate:".$row->duedate."\n\n"; > > my $objects = $schema->resultset('Todo')->search(undef,{ > +select => [ > \'DATEDIFF(me.duedate,NOW())' > ], > +as => [ > 'daysleft' > ] > }); > > my $row = $objects->first; > print "duedate:".$row->duedate."\n"; > print "calculated column daysleft: ".$row->get_column('daysleft')."\n\n"; > > > $objects = $schema->resultset('Todo')->search(undef,{ > +select => [ > { 'DATEDIFF' => 'me.duedate,NOW()', -as => 'daysleft'} > ] > }); > > $row = $objects->first; > print "duedate:".$row->duedate."\n"; > print "calculated column daysleft: ".$row->get_column('daysleft')."\n\n"; > </code>
Once again - the code will *not* work as written. Once again - consider: perl -MData::Dumper -E 'say Dumper { +foo => "bar", "+foo" => "baz" }' Quote your '+select', This is a perl syntax thing, not much we can do about it.
Subject: Re: [rt.cpan.org #64977] +select +as in resultset search does not add a column
Date: Thu, 3 Feb 2011 13:20:10 +0100
To: bug-DBIx-Class [...] rt.cpan.org
From: Rob Boerman <rob [...] robboerman.com>
Shit, sorry about that. you're absolutely right. In trying to recreate it in the latest version I again forgot to add the quotes. with the quotes added there is nothing wrong... Sorry to have wasted your time, I will be more careful in the future before submitting a bug (was my first time as you might have gathered). Kind regards, Rob Op 3 feb 2011, om 13:08 heeft Peter Rabbitson via RT het volgende geschreven: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=64977 > > > Rob Boerman via RT wrote:
>> Queue: DBIx-Class >> Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=64977 > >>
>>> I actually checked it with the quotes around it. What I will do is >>> prepare an example with full code and on the latest version
>> >> I confirmed the bug in 0.08127 >> >> I quickly created a short script that tries to add a calculated column to the results using the >> +select and +as modifier. According to the docs this should add an additional column to the >> results, but instead it ONLY fetches the additional column. >> >> <code> >> use strict; >> use lib qw(/home/rob/projects/afs/AFS/lib); >> use AFS::Schema; >> use Data::Dumper; >> my $schema = AFS::Schema->connect('dbi:mysql:afsdb','afsdb','lemmein'); >> >> my $objects = $schema->resultset('Todo')->search(undef); >> >> my $row = $objects->first; >> print "duedate:".$row->duedate."\n\n"; >> >> my $objects = $schema->resultset('Todo')->search(undef,{ >> +select => [ >> \'DATEDIFF(me.duedate,NOW())' >> ], >> +as => [ >> 'daysleft' >> ] >> }); >> >> my $row = $objects->first; >> print "duedate:".$row->duedate."\n"; >> print "calculated column daysleft: ".$row->get_column('daysleft')."\n\n"; >> >> >> $objects = $schema->resultset('Todo')->search(undef,{ >> +select => [ >> { 'DATEDIFF' => 'me.duedate,NOW()', -as => 'daysleft'} >> ] >> }); >> >> $row = $objects->first; >> print "duedate:".$row->duedate."\n"; >> print "calculated column daysleft: ".$row->get_column('daysleft')."\n\n"; >> </code>
> > Once again - the code will *not* work as written. Once again - consider: > > perl -MData::Dumper -E 'say Dumper { +foo => "bar", "+foo" => "baz" }' > > Quote your '+select', This is a perl syntax thing, not much we can do > about it. >
On Thu Feb 03 07:20:22 2011, rboerman wrote: Show quoted text
> > Shit, sorry about that. you're absolutely right. In trying to recreate > it in the latest version I again forgot to add the quotes. with the > quotes added there is nothing wrong... > > Sorry to have wasted your time, I will be more careful in the future > before submitting a bug (was my first time as you might have > gathered). >
Not an issue at all. There will be no bogus reports only if people stop reporting altogether, and nobody wants that ;) If you run into another problem feel free to let us know.