[Dbix-class] Is the 'as' attribute to a search method broken?
Randy Moore
ramoore at axion-it.com
Mon Oct 29 02:51:12 GMT 2007
Hi again,
Sorry to follow up my own post, but I just found that the 'as' attribute
*IS* working, but the SQL query reported to debug (I used
export DBIC_TRACE=1 ), is not showing the 'AS' names in the query.
Thanks.
Randy Moore wrote:
> Hi,
>
> I'm very new with DBIx-Class, but I don't think I'm doing anything
> wrong <grin>. It looks like the 'as' attribute to a search is not
> working.
> I'm running inside of Catalyst BTW, and I've created a trivial example
> that I think should work.
>
> my $rs = $c->model('PjAppDB::Categories')->search(undef, {
> select => [
> 'name',
> { length => 'name' }
> ],
> as => ['name', 'namelength'],
> });
> my $result = $rs->first();
>
> My Categories model class *does* have a column named 'name'.
>
> This code is producing: SELECT name, LENGTH( name ) FROM categories me
> But I think it should produce: SELECT name name, LENGTH( name )
> namelength FROM categories me
>
> The SQL query that it does produce works perfectly, I just don't see
> how I can access the result for the LENGTH.
> I was expecting to use $result->get_column('namelength')
>
> Am I missing something blindingly obvious?
>
> Is there some alternate to using get_column that will let me retrieve
> this unnamed value?
>
> Thanks.
>
--
Randy Moore
Axion Information Technologies, Inc.
phone: 301-587-3300 x 511
fax: 301-585-7450
http://www.axion-it.com
More information about the DBIx-Class
mailing list