X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole%2FModel%2FCDBI.pm;fp=lib%2FMaypole%2FModel%2FCDBI.pm;h=ce93690d065c86d99ea98214ed2ab63852b15287;hb=695634a55e7a5293c9b5197d9d6b93245ff3ff14;hp=5433beba42282488de1de6e584f1f9e36366f94c;hpb=90b7b082066bee6303621aab49b166546445085c;p=maypole.git diff --git a/lib/Maypole/Model/CDBI.pm b/lib/Maypole/Model/CDBI.pm index 5433beb..ce93690 100644 --- a/lib/Maypole/Model/CDBI.pm +++ b/lib/Maypole/Model/CDBI.pm @@ -1,6 +1,8 @@ package Maypole::Model::CDBI; use strict; +use Data::Dumper; + =head1 NAME Maypole::Model::CDBI - Model class based on Class::DBI @@ -503,7 +505,6 @@ sub _isa_class { # sub _column_info { sub _column_info { my $self = shift; - warn "__column_info called by ", join (', ', caller), "\n"; my $dbh = $self->db_Main; my $meta; # The info we are after @@ -531,8 +532,7 @@ sub _hash_type_meta { # required / nullable $meta->{$colname}{nullable} = $row->{NULLABLE}; - - $meta->{$colname}{required} = ($row->{NULLABLE} && $row->{NULLABLE} == 0) ? 1 : 0; + $meta->{$colname}{required} = ( $meta->{$colname}{nullable} == 0 ) ? 1 : 0; # default if (defined $row->{COLUMN_DEF}) { @@ -648,6 +648,7 @@ sub required_columns { my ($class, $columns) = @_; $class->_column_info() unless ref $class->COLUMN_INFO; my $column_info = $class->COLUMN_INFO; + if ($columns) { foreach my $colname ( @$columns ) { if ($class->_isa_class($colname)) { @@ -659,12 +660,12 @@ sub required_columns { warn "$colname is not a recognised column in this class ", ref $class || $class, "\n"; next; } - $column_info->{required} = 1; + $column_info->{$colname}{required} = 1; } $class->COLUMN_INFO($column_info); } - return [ grep ($column_info->{$_}{required}, keys %{$column_info}) ] ; + return [ grep ($column_info->{$_}{required}, keys %$column_info) ] ; } =head2 column_required