From: Jules Bean Date: Thu, 1 Dec 2005 20:04:37 +0000 (+0000) Subject: die() if the user inadvertently tries to set the column list using X-Git-Tag: v0.05005~159 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e75133196363e43a69f5909d5c688e08789d83b4;p=dbsrgits%2FDBIx-Class.git die() if the user inadvertently tries to set the column list using columns() as if it was add_columns(). --- diff --git a/lib/DBIx/Class/Table.pm b/lib/DBIx/Class/Table.pm index 34e926e..2fa6f06 100644 --- a/lib/DBIx/Class/Table.pm +++ b/lib/DBIx/Class/Table.pm @@ -217,7 +217,10 @@ sub column_info { =cut -sub columns { return keys %{shift->_columns}; } +sub columns { + die "columns() is a read-only accessor, did you mean add_columns()?" if (@_ > 1); + return keys %{shift->_columns}; +} 1; diff --git a/t/20setuperrors.t b/t/20setuperrors.t new file mode 100644 index 0000000..f082e93 --- /dev/null +++ b/t/20setuperrors.t @@ -0,0 +1,14 @@ +#!/usr/bin/perl + +use Test::More tests => 1; + +eval { + package BuggyTable; + use base 'DBIx::Class'; + + __PACKAGE__->load_components qw/Core/; + __PACKAGE__->columns qw/this doesnt work as expected/; +}; + +like($@,qr/^columns\(\) is a read-only/, + "columns() error when apparently misused");