Permalink
Browse files

optionally callback after connect

This is useful if you want your handle to do something unusual after
connect, such as quiet warnings.
  • Loading branch information...
1 parent 8863e73 commit 18b2c19368b71bc05c6777d31cab2ae3ad0c12cd @cxreg cxreg committed Jul 22, 2010
Showing with 8 additions and 0 deletions.
  1. +6 −0 t/35-Pg-common.t
  2. +2 −0 t/99-common.pl6
View
@@ -18,6 +18,12 @@ my ( $mdriver, $test_dsn, $test_user, $test_password );
$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
warn $! if "ok 99-common.pl6" ne eval slurp 't/99-common.pl6';
View
@@ -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> );
ok $dbh, "connect to $test_dsn"; # test 3
+eval '$post_connect_cb.($dbh)';
+
# 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.
my $sth = $dbh.prepare("DROP TABLE IF EXISTS nom");

0 comments on commit 18b2c19

Please sign in to comment.