bigpresh / Dancer-Plugin-Database

Dancer::Plugin::Database - easy database support for Dancer applications
http://search.cpan.org/dist/Dancer-Plugin-Database
37 stars 36 forks source link

database("foo") fails the second time it is called #41

Closed msouth closed 10 years ago

msouth commented 10 years ago

dancer -a Acme::Test::Dancer::Plugin::Database

And then make the config.yml and the .pm file look like this:

https://gist.github.com/msouth/6158618

I put this debugging in Dancer/Plugin/Database.pm:

register database => sub {
Carp::cluck( "settings was already". Dumper( $settings ) ) if $settings; use Data::Dumper; use Carp;
    _load_db_settings() unless $settings;
    my ($dbh, $cfg) = Dancer::Plugin::Database::Core::database( arg => $_[0],
                                                                logger => \&_logger,
                                                                hook_exec => \&_execute_hook,
                                                                settings => $settings );
Carp::cluck( "settings was ". Dumper( $settings ). ' and is about to be '. Dumper( $cfg ) ) ; use Data::Dumper; use Carp;
    $settings = $cfg;
    return $dbh;
};

I think it's an error to put that $cfg into the $settings, because later it will be looking for the ->{connections} key and not find it. Something along those lines.

ambs commented 10 years ago

Solved in d750660. Thanks for the report :+1: