Skip to content

Commit

Permalink
optionally callback after connect
Browse files Browse the repository at this point in the history
This is useful if you want your handle to do something unusual after
connect, such as quiet warnings.
  • Loading branch information
cxreg committed Jul 22, 2010
1 parent 8863e73 commit 18b2c19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions t/35-Pg-common.t
Expand Up @@ -18,6 +18,12 @@ my ( $mdriver, $test_dsn, $test_user, $test_password );
$test_password = 'testpass'; $test_password = 'testpass';
} }


my $dbh;
my $post_connect_cb = {
my $dbh = @_.shift;
$dbh.do('SET client_min_messages = warning');
};

# Detect and report possible errors from eval of the common test script # Detect and report possible errors from eval of the common test script
warn $! if "ok 99-common.pl6" ne eval slurp 't/99-common.pl6'; warn $! if "ok 99-common.pl6" ne eval slurp 't/99-common.pl6';


Expand Down
2 changes: 2 additions & 0 deletions t/99-common.pl6
Expand Up @@ -18,6 +18,8 @@ ok $drh_version > 0, "MiniDBD::$mdriver version $drh_version"; # test 2
my $dbh = MiniDBI.connect( $test_dsn, $test_user, $test_password, :RaiseError<1> ); my $dbh = MiniDBI.connect( $test_dsn, $test_user, $test_password, :RaiseError<1> );
ok $dbh, "connect to $test_dsn"; # test 3 ok $dbh, "connect to $test_dsn"; # test 3


eval '$post_connect_cb.($dbh)';

# Test .prepare() and .execute() a few times while setting things up. # Test .prepare() and .execute() a few times while setting things up.
# Drop a table of the same name so that the following create can work. # Drop a table of the same name so that the following create can work.
my $sth = $dbh.prepare("DROP TABLE IF EXISTS nom"); my $sth = $dbh.prepare("DROP TABLE IF EXISTS nom");
Expand Down

0 comments on commit 18b2c19

Please sign in to comment.