Time to float this to list, rather than being a pita on IRC. :-) I'm trying to work R::DB objects where I need to create objects with their own values, rather than relying things predefined in the registry.
(people tell Handel what dsn to use with its schema, and Handel doesn't know connection strings ahead of time in order to register them) At first, this sounds simple based on the docs. just call DB->new, set any options via object methods, and you're good to go. But after banging my head against the wall all day, this appears to not be true. Consider the following code: > Rose::DB->register_db( > domain => 'handel', > type => 'default', > driver => 'SQLite' > ); > > > my $db = Rose::DB->new( > domain => 'handel', > type => 'default' > ); > $db->dsn('dbi:SQLite:dbname=F:\CPAN\Handel-Storage-RDBO\t\var\handel.db'); > $db->dbh->do("SELECT * FROM cart"); The last line fails with: > DBD::SQLite::db do failed: no such table: cart(1) at dbdimp.c line 269 However, if one modifies the version in the registry using modify_db, it works: > $db->modify_db( > domain => 'handel', > type => 'default', > dsn => 'dbi:SQLite:dbname=F:\CPAN\Handel-Storage-RDBO\t\var\handel.db' > ); > $db->dbh->do("SELECT * FROM cart"); Since modify_db is a class method, and alters the registry, not the object itself, that's not so good. While digging, I noticed this from the pod: > init_db_info is called as part of the new and connect methods. That seems to imply that no matter what I pass to new(), and no matter what options I set using the object methods, that is all tossed away and overwritten with what's in the registry during the first call to $db->connect/dbh That seems to defeat the purpose of being able to alter a db object if it's always going to get trashed by init_db_info. So, back to the real issue for me. I want to use Rose::DB (::Object). I simply want to give it a dsn and have it DTRT without playing registry_db games as I may not even know connection info until the person using Handel tells me what it is. What's the best way over this hump? -=Chris
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object