Skip Menu |

This queue is for tickets about the Catalyst-Model-Adaptor CPAN distribution.

Report information
The Basics
Id: 70316
Status: new
Priority: 0/
Queue: Catalyst-Model-Adaptor

People
Owner: Nobody in particular
Requestors: KTHAKORE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.10
Fixed in: 0.10



Subject: args options with a non default constructor
HI Thomas, I am trying to use Catalyst::Model::Adaptor with Mongoose where I do use base 'Catalyst::Model::Adaptor'; __PACKAGE__->config( class => 'Mongoose', constructor => 'db', args => { 'db_name'=> 'medapp' } ); However with the current code it fails: Couldn't load class (MedApp) because: Couldn't instantiate component "MedApp::Model::Mongoose", "Attribute (name) does not pass the type constraint because: Validation failed for 'Str' with value HASH(0x5123b30) at constructor MongoDB::Database::new (defined at /home/kthakore/.perl5/perls/perl-5.12.2/lib/site_perl/5.12.2/x86_64-linux-thread-multi/MongoDB/Database.pm line 329) line 44 MongoDB::Database::new('MongoDB::Database', '_connection', 'MongoDB::Connection=HASH(0x511bbc8)', 'name', 'HASH(0x5123b30)') called at /home/kthakore/.perl5/perls/perl-5.12.2/lib/site_perl/5.12.2/x86_64-linux-thread-multi/MongoDB/Connection.pm line 556 MongoDB::Connection::get_database('MongoDB::Connection=HASH(0x511bbc8)', 'HASH(0x5123b30)') called at /home/kthakore/.perl5/perls/perl-5.12.2/lib/site_perl/5.12.2/Mongoose.pm line 86 Mongoose::connect('Mongoose') called at /home/kthakore/.perl5/perls/perl-5.12.2/lib/site_perl/5.12.2/Mongoose.pm line 77 Mongoose::db('Mongoose', 'HASH(0x5123b30)') called at /home/kthakore/.perl5/perls/perl-5.12.2/lib/site_perl/5.12.2/Catalyst/Model/Adaptor/Base.pm line 27 Catalyst::Model::Adaptor::Base::_create_instance('MedApp::Model::Mongoose=HASH(0x4a0d4b0)', 'MedApp', 'HASH(0x4a0b618)') called at /home/kthakore/.perl5/perls/perl-5.12.2/lib/site_perl/5.12.2/Catalyst/Model/Adaptor.pm line 24 Catalyst::Model::Adaptor::COMPONENT('MedApp::Model::Mongoose', 'MedApp', 'HASH(0x4a0b738)') called at /home/kthakore/.perl5/perls/perl-5.12.2/lib/site_perl/5.12.2/Catalyst.pm line 2550 As you can see the Base is sending a HASH ref as a parameter rather then converting it to a list. I traced the problem to the mangle_parameters function: https://github.com/kthakore/catalyst-model-adaptor/commit/24284bb699605548fd7c55bb17c59847aab0a5c0 And I fixed it as it was mentioned in the docs for Catalyst::Model::Adaptor. I have forked and patched the repo and pushed a pull request. Please consider accepting it.