Changeset 104

Show
Ignore:
Timestamp:
05/04/06 00:08:26 (4 years ago)
Author:
sky
Message:

r107@crucially-3 (orig r1091): ykerherve | 2006-02-02 19:19:28 -0800
Let's also croak for column('inexistent')


Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/Data/ObjectDriver/BaseObject.pm

    r102 r104  
    117117sub column_values { $_[0]->{'column_values'} } 
    118118 
     119## In 0.1 version we didn't die on inexistent column 
     120## which might lead to silent bugs 
     121## You should override column if you want to find the old  
     122## behaviour 
    119123sub column { 
    120124    my $obj = shift; 
    121125    my $col = shift or return; 
     126    unless ($obj->has_column($col)) { 
     127        Carp::croak("Cannot find column '$col' for class '" . ref($obj) . "'"); 
     128    } 
    122129    $obj->{column_values}->{$col} = shift if @_; 
    123130    $obj->{column_values}->{$col}; 
  • trunk/t/02-basic.t

    r103 r104  
    1919} 
    2020 
    21 plan tests => 22; 
     21plan tests => 23; 
    2222 
    2323use Wine; 
     
    3535    ok $w->has_column("name"); 
    3636    ok ! $w->has_column("inexistent"); 
    37     dies_ok { $w->inexistent("hell") } "dies on setting inexistent column"; 
     37    dies_ok { $w->inexistent("hell") } "dies on setting inexistent column : 'inexistent()'"; 
     38    dies_ok { $w->column('inexistent') } "dies on setting inexistent column : 'column()'"; 
    3839} 
    3940