X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole%2FModel%2FCDBI.pm;h=c7621d2c493491c33415dd7f021940395687e13d;hb=e47bbd30a5e5ff445ebac73c378d21550a64b697;hp=43b8c7be0d808b22879d7d1edc24e357a984fbfe;hpb=48b7f94a68422ee2d1ee9ca6bf9cd5c2ee34e189;p=maypole.git diff --git a/lib/Maypole/Model/CDBI.pm b/lib/Maypole/Model/CDBI.pm index 43b8c7b..c7621d2 100644 --- a/lib/Maypole/Model/CDBI.pm +++ b/lib/Maypole/Model/CDBI.pm @@ -65,11 +65,14 @@ sub delete :Exported { sub adopt { my ($self, $child) = @_; $child->autoupdate(1); - $child->columns( Stringify => qw/ name / ); + if (grep { $_ eq "name" } $child->columns) { # Common case + $child->columns( Stringify => qw/ name / ); + } # Otherwise, work it out for yourself. } sub search :Exported { - return shift->SUPER::search(@_) if caller eq "Class::DBI"; # oops + return shift->SUPER::search(@_) if caller ne "Maypole::Model::Base"; + # A real CDBI search. my ($self, $r) = @_; my %fields = map {$_ => 1 } $self->columns; my $oper = "like"; # For now @@ -101,11 +104,13 @@ sub list :Exported { } sub setup_database { - my ($self, $config, $namespace, $dsn) = @_; + my ($self, $config, $namespace, $dsn, $u, $p) = @_; $config->{dsn} = $dsn; $config->{loader} = Class::DBI::Loader->new( namespace => $namespace, - dsn => $dsn + dsn => $dsn, + user => $u, + password => $p, ); $config->{classes} = [ $config->{loader}->classes ]; $config->{tables} = [ $config->{loader}->tables ];