use_ok('DBICTest::Schema');
-my $schema = DBICTest::Schema->connection($dsn, $user, $pass, { AutoCommit => 1 });
+my $schema = DBICTest::Schema->connect($dsn, $user, $pass, { AutoCommit => 1 });
my $parent_rs;
use_ok('DBICTest::Schema');
-my $schema = DBICTest::Schema->connection($dsn, $user, $pass, { AutoCommit => 1, RaiseError => 1, PrintError => 0 });
+my $schema = DBICTest::Schema->connect($dsn, $user, $pass, { AutoCommit => 1, RaiseError => 1, PrintError => 0 });
my $parent_rs;
if $] < '5.008005';
use DBIx::Class::Optional::Dependencies ();
+use Scalar::Util 'weaken';
use lib qw(t/lib);
my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/};
use_ok('DBICTest::Schema');
-my $schema = DBICTest::Schema->connection($dsn, $user, $pass, { AutoCommit => 1, RaiseError => 1, PrintError => 0 });
+my $schema = DBICTest::Schema->connect($dsn, $user, $pass, { AutoCommit => 1, RaiseError => 1, PrintError => 0 });
my $parent_rs;
my $newthread = async {
my $tid = threads->tid;
- # my $dbh = $schema->storage->dbh;
-
+ weaken(my $weak_schema = $schema);
+ weaken(my $weak_parent_rs = $parent_rs);
$schema->txn_do(sub {
- my $child_rs = $schema->resultset('CD')->search({ year => 1901 });
- my $row = $parent_rs->next;
+ my $child_rs = $weak_schema->resultset('CD')->search({ year => 1901 });
+ my $row = $weak_parent_rs->next;
if($row && $row->get_column('artist') =~ /^(?:123|456)$/) {
- $schema->resultset('CD')->create({ title => "test success $tid", artist => $tid, year => scalar(@children) });
+ $weak_schema->resultset('CD')->create({ title => "test success $tid", artist => $tid, year => scalar(@children) });
}
});
sleep(1); # tasty crashes without this
: (0)
) {
- no warnings qw/once/;
+ no warnings qw/once redefine/;
+ my $old_connection = DBICTest::Schema->can('connection');
local *DBICTest::Schema::connection = subname 'DBICTest::Schema::connection' => sub {
- my $s = shift->next::method (@_);
+ my $s = shift->$old_connection(@_);
$s->storage->_use_insert_returning ($use_insert_returning);
$s;
};
plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test'
unless ($dsn && $dbuser);
-my $schema = DBICTest::Schema->connection($dsn, $dbuser, $dbpass, { AutoCommit => 1 });
+my $schema = DBICTest::Schema->connect($dsn, $dbuser, $dbpass, { AutoCommit => 1 });
if ($schema->storage->_server_info->{normalized_dbms_version} >= 9.0) {
if (not try { DBD::Pg->VERSION('2.17.2') }) {
for my $use_insert_returning ($test_server_supports_insert_returning ? (1,0) : (0) ) {
for my $force_ora_joins ($test_server_supports_only_orajoins ? (0) : (0,1) ) {
- no warnings qw/once/;
+ no warnings qw/once redefine/;
+ my $old_connection = DBICTest::Schema->can('connection');
local *DBICTest::Schema::connection = subname 'DBICTest::Schema::connection' => sub {
- my $s = shift->next::method (@_);
+ my $s = shift->$old_connection (@_);
$s->storage->_use_insert_returning ($use_insert_returning);
$s->storage->sql_maker_class('DBIx::Class::SQLMaker::OracleJoins') if $force_ora_joins;
$s;
[ $dsn2, $user2 || '', $pass2 || '' ],
);
-my $schema;
-
for my $connect_info (@connect_info) {
my ($dsn, $user, $pass) = @$connect_info;
next unless $dsn;
- $schema = DBICTest::Schema->connect($dsn, $user, $pass, {
+ my $schema = DBICTest::Schema->connect($dsn, $user, $pass, {
on_connect_call => 'datetime_setup',
quote_names => 1,
});
- my $guard = Scope::Guard->new(\&cleanup);
+ my $guard = Scope::Guard->new(sub { cleanup($schema) });
try { local $^W = 0; $schema->storage->dbh->do('DROP TABLE track') };
$schema->storage->dbh->do(<<"SQL");
# clean up our mess
sub cleanup {
+ my $schema = shift;
# have to reconnect to drop a table that's in use
if (my $storage = eval { $schema->storage }) {
local $^W = 0;
$self;
}
+sub connection {
+ my $self = shift->next::method(@_);
+ populate_weakregistry ( $weak_registry, $self->storage )
+ if $INC{'Test/Builder.pm'};
+ $self;
+}
+
END {
assert_empty_weakregistry($weak_registry, 'quiet');
}
ok $disconnected, 'on_disconnect_do() called after disconnect()';
isa_ok($cb_args[0], 'DBIx::Class::Storage', 'first arg to on_connect_do hook');
+@cb_args = ();
sub check_exists {
my $storage = shift;