From: Rafael Kitover Date: Tue, 1 Mar 2011 01:36:33 +0000 (-0500) Subject: add EasyDBI object X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=68a4abbc4c33c50cb7cdcf685d784a8db0ed7e42;p=dbsrgits%2FDBIx-Class-Historic.git add EasyDBI object --- diff --git a/lib/DBIx/Class/Storage/DBI/POE/EasyDBI.pm b/lib/DBIx/Class/Storage/DBI/POE/EasyDBI.pm index ebf4b31..895fb56 100644 --- a/lib/DBIx/Class/Storage/DBI/POE/EasyDBI.pm +++ b/lib/DBIx/Class/Storage/DBI/POE/EasyDBI.pm @@ -18,7 +18,7 @@ use POE::Component::EasyDBI; use namespace::clean; __PACKAGE__->mk_group_accessors(simple => qw/ - _normal_storage + _normal_storage _easydbi /); my @proxy_to_normal_storage = qw/ @@ -56,10 +56,6 @@ complete (the rest of the application, that does not depend on L still runs.) To keep your app responsive, I recommend avoiding long-running queries. -=head2 transactions - -Transactions are not currently supported at all. - =cut # make a normal storage for proxying some methods @@ -88,6 +84,34 @@ for my $method (@proxy_to_normal_storage) { }; } +sub _init { + my $self = shift; + + my ($dsn, $user, $pass, $opts) = @{ $self->_dbi_connect_info }; + + $self->throw_exception( + 'coderef connect_info not supported by '.__PACKAGE__ + ) if ref $dsn eq 'CODE'; + + my $easydbi = POE::Component::EasyDBI->new( + alias => '', + dsn => $dsn, + username => $user, + password => $pass, + options => $opts + ); + + $self->_easydbi($easydbi); +} + +sub DESTROY { + my $self = shift; + + if ($self->_easydbi) { + $self->_easydbi->shutdown; + } +} + 1; =head1 AUTHOR diff --git a/t/storage/poe_easydbi.t b/t/storage/poe_easydbi.t index 4215252..f997cd8 100644 --- a/t/storage/poe_easydbi.t +++ b/t/storage/poe_easydbi.t @@ -49,6 +49,11 @@ POE::Session->create( isnt $seq, '0,1,2,3,4,5', 'records were not inserted synchronously'; $_[HEAP]{creates_done_ran} = 1; + + $_[KERNEL]->yield('cleanup'); + }, + cleanup => sub { + delete $_[HEAP]{schema}; # FIXME this should not be necessary }, }, );