Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevents auto-reconnect with DBIx::Connector from working. #1

Open
markstos opened this issue Mar 21, 2013 · 5 comments
Open

prevents auto-reconnect with DBIx::Connector from working. #1

markstos opened this issue Mar 21, 2013 · 5 comments
Assignees

Comments

@markstos
Copy link

Thanks for this module. I like the idea of it. I wanted to use it to combine the DBIx::Simple API with the auto-reconnection feature of DBIx::Connector. However, as my testing shows below, it doesn't work in all cases.

Adjust the $DSN to suit you, and then you'll see that when using DBIx::Simple::Inject, the connection doesn't recover from a disconnect:

use Test::More;
use Test::Exception;
use DBIx::Simple::Inject;
use DBIx::Connector;


# The base case, no DBIx::Simple::Inject
{
    my $dbixc = DBIx::Connector->new('dbi:Pg:...','yourname');
    my $dbh = $dbixc->dbh;

    # Reality check connection
    note $dbh->selectrow_array("SELECT version()");

    lives_ok( sub {
        $dbh->disconnect;
        note $dbixc->dbh->selectrow_array("SELECT version()")
    }, "Without DBIx::Simple::Inject: auto-reconnect after dbh->disconnect");

    lives_ok( sub {
        $dbixc->disconnect;
        note $dbixc->dbh->selectrow_array("SELECT version()")
    }, "Without DBIx::Simple::Inject: auto-reconnect after dbixc->disconnect");
}

# With DBIx::Simple::Inject
{
    my $dbixc = DBIx::Connector->new('dbi:Pg:...','yourname', undef, {
        RootClass => 'DBIx::Simple::Inject',
    });
    my $dbh = $dbixc->dbh;

    # Reality check connection
    note $dbh->selectrow_array("SELECT version()");

    lives_ok( sub {
        $dbh->disconnect;
        note $dbixc->dbh->selectrow_array("SELECT version()")
    }, "WITH DBIx::Simple::Inject: auto-reconnect after dbh->disconnect");

    # Currently fails here.
    lives_ok( sub {
        $dbixc->disconnect;
        note $dbixc->dbh->selectrow_array("SELECT version()")
    }, "WITH DBIx::Simple::Inject: auto-reconnect after dbixc->disconnect");
}

done_testing;
~

@ghost ghost assigned tomill Mar 26, 2013
@tomill
Copy link
Owner

tomill commented Mar 26, 2013

thanks the report.
I'm another DBIx::Simple and DBIx::Connector fan ;)

I’ve never seen this error, because I dont call $dbh->disconnect()
to keep connection managing as DBIx::Connector's job.
but in some cases, need it though.

I noticed $dbh->disconntct() should call DBI::db::disconnect() directly
when using DBIx::Simple as a subclass.

Tests(added your above test) passed. How about this?

@ComLock
Copy link

ComLock commented Oct 31, 2013

Any reason why there is not a 0.05 version with this?
Trying to use DBIx::Connector and DBIx::Simple::Inject in an Mojolicious hypnotoad app :)

Database object no longer usable (because of DBIx::Simple=HASH(0x5e612e0)->disconnect at ...local/lib/perl5/DBIx/Simple/Inject.pm line 63)

@markstos
Copy link
Author

DBIx::Simple::Connector is a cleaner design approach to integrating DBIx::Simple and DBIx::Connector. The author of DBIx::Simple has approved the general approach when creating DBIx::Simple::Connector, but has not get formally reviewed and released it, along with the minor updates to DBIx::Simple that it requires:

https://rt.cpan.org/Public/Bug/Display.html?id=89258

@ComLock
Copy link

ComLock commented Nov 25, 2013

I don't have write access to https://rt.cpan.org/Public/Bug/Display.html?id=89258

But I think this is needed aswell:

diff -rN -u DBIx-Simple-1.35/MANIFEST DBIx-Simple-1.40/MANIFEST
--- DBIx-Simple-1.35/MANIFEST   2007-11-11 01:10:33.000000000 +0100
+++ DBIx-Simple-1.40/MANIFEST   2013-11-25 15:26:19.968743073 +0100
@@ -7,6 +7,7 @@
 t/sqlite.t
 t/swap.t
 lib/DBIx/Simple.pm
+lib/DBIx/Simple/Connector.pm
 lib/DBIx/Simple/Examples.pod
 lib/DBIx/Simple/Comparison.pod
 lib/DBIx/Simple/Result/RowObject.pm
diff -rN -u DBIx-Simple-1.35/META.yml DBIx-Simple-1.40/META.yml
--- DBIx-Simple-1.35/META.yml   2011-01-04 23:58:25.000000000 +0100
+++ DBIx-Simple-1.40/META.yml   2013-11-25 15:26:38.329329293 +0100
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               DBIx-Simple
-version:            1.35
+version:            1.40
 abstract:           Very complete easy-to-use OO interface to DBI
 author:
     - Juerd Waalboer 

@ComLock
Copy link

ComLock commented Nov 25, 2013

What about this?

RootClass      => 'DBIx::Simple::Inject',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants