Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add deprecation warnings for cols/include_columns

* Also update docs and include test
  • Loading branch information...
commit 11343b34c7d3278f087f81d9bb281512d55b34c9 1 parent eba59b7
@dariusj dariusj authored ribasushi committed
View
4 Changes
@@ -1,5 +1,9 @@
Revision history for DBIx::Class
+ * New Features / Changes
+ - Officially deprecate the 'cols' and 'include_columns' resultset
+ attributes
+
0.08209 2013-03-01 12:56 (UTC)
* New Features / Changes
- Debugging aid - warn on invalid result objects created by what
View
2  lib/DBIx/Class.pm
@@ -362,6 +362,8 @@ clkao: CL Kao
da5id: David Jack Olrik <djo@cpan.org>
+dariusj: Darius Jokilehto <dariusjokilehto@yahoo.co.uk>
+
davewood: David Schmidt <davewood@gmx.at>
debolaz: Anders Nor Berle <berle@cpan.org>
View
19 lib/DBIx/Class/ResultSet.pm
@@ -439,6 +439,7 @@ sub search_rs {
# older deprecated name, use only if {columns} is not there
if (my $c = delete $new_attrs->{cols}) {
+ carp_unique( "Resultset attribute 'cols' is deprecated, use 'columns' instead" );
if ($new_attrs->{columns}) {
carp "Resultset specifies both the 'columns' and the legacy 'cols' attributes - ignoring 'cols'";
}
@@ -485,8 +486,12 @@ sub _normalize_selection {
my ($self, $attrs) = @_;
# legacy syntax
- $attrs->{'+columns'} = $self->_merge_attr($attrs->{'+columns'}, delete $attrs->{include_columns})
- if exists $attrs->{include_columns};
+ if ( exists $attrs->{include_columns} ) {
+ carp_unique( "Resultset attribute 'include_columns' is deprecated, use '+columns' instead" );
+ $attrs->{'+columns'} = $self->_merge_attr(
+ $attrs->{'+columns'}, delete $attrs->{include_columns}
+ );
+ }
# columns are always placed first, however
@@ -3799,7 +3804,7 @@ case the key is the C<as> value, and the value is used as the C<select>
expression). Adds C<me.> onto the start of any column without a C<.> in
it and sets C<select> from that, then auto-populates C<as> from
C<select> as normal. (You may also use the C<cols> attribute, as in
-earlier versions of DBIC.)
+earlier versions of DBIC, but this is deprecated.)
Essentially C<columns> does the same as L</select> and L</as>.
@@ -3818,10 +3823,10 @@ is the same as
=back
-Indicates additional columns to be selected from storage. Works the same
-as L</columns> but adds columns to the selection. (You may also use the
-C<include_columns> attribute, as in earlier versions of DBIC). For
-example:-
+Indicates additional columns to be selected from storage. Works the same as
+L</columns> but adds columns to the selection. (You may also use the
+C<include_columns> attribute, as in earlier versions of DBIC, but this is
+deprecated). For example:-
$schema->resultset('CD')->search(undef, {
'+columns' => ['artist.name'],
View
25 t/search/deprecated_attributes.t
@@ -0,0 +1,25 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Warn;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+my $cd_rs = $schema->resultset("CD");
+
+warnings_exist( sub {
+ $cd_rs->search_rs( undef, { cols => [ { name => 'artist.name' } ], join => [ 'artist' ] })
+}, qr/Resultset attribute 'cols' is deprecated/,
+'deprecation warning when passing cols attribute');
+
+warnings_exist( sub {
+ $cd_rs->search_rs( undef, {
+ include_columns => [ { name => 'artist.name' } ], join => [ 'artist' ]
+ })
+}, qr/Resultset attribute 'include_columns' is deprecated/,
+'deprecation warning when passing include_columns attribute');
+
+done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.