[Dbix-class] Is columns to cols as +columns is to +cols

Peter Rabbitson rabbit+dbic at rabbit.us
Mon Mar 18 18:13:16 GMT 2013


On Mon, Mar 18, 2013 at 05:54:53PM +0000, Darius Jokilehto wrote:
> Hello,
> 
> Just wanted to point out an issue I ran with cols/+cols when chaining a couple of DBIC queries.
> 
> I was trying to do the following:
> 
> $schema->resultset('CD')->search({}, { cols => 'me.cola'})->search{}, { '+cols' => 'me.colb' });
> 
>  - and was finding that 'colb' wasn't appearing in my query at all (see 
> below test hacked from t/search/select_chain.t for details).
> 
> Had I spent a little more time reading the docs, I would have noticed that I made up '+cols' - there is no mention of it at all in the docs, so really I should have been paying more attention and used '+columns' instead.
> 
> However, as 'cols' is a valid alias for 'columns', I made the assumption that '+cols' would work for '+columns' too. I don't know why this isn't the case (is 'cols' deprecated?), but it would make sense for both keys to be abbreviated the same way (or warn with a deprecation notice if that's not the case) and keep the behaviour consistent.

Yes it is deprecated, but done incorrectly (I am likely to blame). Could 
you please add a carp_unique deprecation notice around here somewhere 
[1]. Btw include_columns is eprecated too, and also unmarked [2] :( git 
format-patch or github pull requests most welcome [3].

Cheers!

[1] https://github.com/dbsrgits/dbix-class/blob/master/lib/DBIx/Class/ResultSet.pm#L440
[2] https://github.com/dbsrgits/dbix-class/blob/master/lib/DBIx/Class/ResultSet.pm#L487
[3] https://metacpan.org/module/RIBASUSHI/DBIx-Class-0.08242-TRIAL/lib/DBIx/Class.pm#HOW-TO-CONTRIBUTE



More information about the DBIx-Class mailing list