From: biopete Date: Thu, 5 Oct 2006 17:55:46 +0000 (+0000) Subject: check some hashrefs for existence before trying to access in some column_* meths. X-Git-Tag: 2.12~48 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=3bd1e85e239f9f3c36abf8ec42a4109e27766395;p=maypole.git check some hashrefs for existence before trying to access in some column_* meths. git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@526 48953598-375a-da11-a14b-00016c27c3ee --- diff --git a/lib/Maypole/Model/CDBI.pm b/lib/Maypole/Model/CDBI.pm index 50e4d30..ed59356 100644 --- a/lib/Maypole/Model/CDBI.pm +++ b/lib/Maypole/Model/CDBI.pm @@ -693,7 +693,7 @@ sub required_columns { sub column_required { my ($class, $colname) = @_; - $colname or $class->_croak( "Need a column for column_nullable" ); + $colname or $class->_croak( "Need a column for column_required" ); $class->_column_info() unless ref $class->COLUMN_INFO; if ($class->_isa_class($colname)) { return $class->_isa_class($colname)->column_required($colname); @@ -703,7 +703,8 @@ sub column_required { warn "$colname is not a recognised column in this class ", ref $class || $class, "\n"; return undef; } - return $class->COLUMN_INFO->{$colname}{required} || 0; + return $class->COLUMN_INFO->{$colname}{required} if ($class->COLUMN_INFO and $class->COLUMN_INFO->{$colname}); + return 0; } =head2 column_nullable @@ -734,7 +735,8 @@ sub column_nullable { warn "$colname is not a recognised column in this class ", ref $class || $class, "\n"; return undef; } - return $class->COLUMN_INFO->{$colname}{nullable} || 0; + return $class->COLUMN_INFO->{$colname}{nullable} if ($class->COLUMN_INFO and $class->COLUMN_INFO->{$colname}); + return 0; } =head2 column_default @@ -757,7 +759,8 @@ sub column_default { return undef; } - return $class->COLUMN_INFO->{$colname}{default}; + return $class->COLUMN_INFO->{$colname}{default} if ($class->COLUMN_INFO and $class->COLUMN_INFO->{$colname}); + return; } =head2 get_classmetadata