Skip Menu |

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

Report information
The Basics
Id: 63843
Status: open
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors:
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Inconsistent SQL equivalence in Manual::Cookbook illustrating 'select' and 'as'
An example at http://search.cpan.org/perldoc?DBIx::Class::Manual::Cookbook intends to show an "AS" clause, but does not mention 'name_length' in the purportedly equivalent SQL. A more specific URL: http://search.cpan.org/~frew/DBIx-Class-0.08124/lib/DBIx/Class/Manual/Cookbook.pod#Using_database_functions_or_stored_procedures my $rs = $schema->resultset('Artist')->search( {}, { select => [ 'name', { LENGTH => 'name' } ], as => [qw/ name name_length /], } ); # Equivalent SQL: # SELECT name name, LENGTH( name ) # FROM artist
Subject: Incomplete example in Manual::Cookbook illustrating 'select' and 'as'
On Sun Dec 12 02:20:29 2010, MichaelRWolf@att.net wrote: Show quoted text
> An example at > http://search.cpan.org/perldoc?DBIx::Class::Manual::Cookbook > > intends to show an "AS" clause, but does not mention 'name_length' in > the purportedly equivalent SQL. > > A more specific URL: > http://search.cpan.org/~frew/DBIx-Class- >
0.08124/lib/DBIx/Class/Manual/Cookbook.pod#Using_database_functions_or_stored_procedures Show quoted text
> > > my $rs = $schema->resultset('Artist')->search( > {}, > { > select => [ 'name', { LENGTH => 'name' } ], > as => [qw/ name name_length /], > } > ); > > # Equivalent SQL: > # SELECT name name, LENGTH( name ) > # FROM artist
OK. I didn't read enough to realize that my reported bug is not correct as it stands. I retract my misinterpretation, but retain the stumbling block that 'name_length' is only used once in the example. Let me reframe this ticket as a request for example code to illustrate how 'as' parameters are used in client code: my $main_attraction = $rs->first->name; my $marquee_characters_needed = $rs->first->name_length; And.... likewise for the section of code that follows this one my $quantity_sold = $rs->first->num_cds; And, although you *do* have a link that explains the issue, I'd still recommend having a phrase in this manual that summarizes: ... NB The 'as' attribute does *not* affect the equivalent SQL. The 'as' attribute does affect how you access the row objects from this record set by remapping it to to a new inflation name. Generally: $obj->$inflation_name $obj->get_column($inflation_name) or Specifically $obj->name_length; $obj->get_column('name_length'); $obj->num_cds; $obj->get_column('num_cds'); even that link doesn't have complete coverage for perhaps a phrase like 'The 'as' parameter
OK. I (almost) retract this whole ticket. Retained: Please add code like this: $obj = $rs->first; $blah = $obj->get_column('num_cds'); And add an ammplifying or clarifying sentence that makes a *positive* association with the 'as' attribute. The current ones are *negative* (i.e. 'as' does *not* relate to the SQL 'AS'). The positive statement is as mentioned in my previous reply, and adds the notion of 'as' related to inflated name of row object in contrast to 'AS' related to SQL. I'm almost completely clear on the issue now, but if it tripped me, it's likely to trip others. I *do* see that you put up guard rails to keep me on the path. My two (small) suggestions would have me. Perhaps they'll help others.
On Sun Dec 12 02:58:13 2010, MichaelRWolf@att.net wrote: Show quoted text
> OK. I (almost) retract this whole ticket. > > Retained: > > Please add code like this: > $obj = $rs->first; > $blah = $obj->get_column('num_cds'); > > And add an ammplifying or clarifying sentence that makes a *positive* > association with the 'as' attribute. The current ones are *negative* > (i.e. 'as' does *not* relate to the SQL 'AS'). > > The positive statement is as mentioned in my previous reply, and adds > the notion of 'as' related to inflated name of row object in contrast to > 'AS' related to SQL. > > I'm almost completely clear on the issue now, but if it tripped me, it's > likely to trip others. I *do* see that you put up guard rails to keep > me on the path. My two (small) suggestions would have me. Perhaps > they'll help others.
Can I have this in patch form (or as a pull request on github), with a line to add to http://search.cpan.org/~frew/DBIx-Class-0.08124/lib/DBIx/Class.pm#CONTRIBUTORS ? This way you get exactly what you want and I don't guess what it is you wanted the doc to say :)