* Correct Data Type in SQLT::Parser::DBI::PostgreSQL (patch from Andrew Pam)
* Fix index issue in SQLT::Parser::DBI::PostgreSQL
* Add column and table comments in SQLT::Parser::DBI::PostgreSQL(patch from Andrew Pam)
+* Stop the DBI parser from disconnecting externally supplied DBI handles (RT#35868)
* Fixed alter_drop_constraint for foreign keys and applying multiple changes
via alter_field to a column in Postgres Producer
* Added a working mechanism for naming foreign keys in the PostgreSQL producer
my $db_user = $args->{'db_user'};
my $db_password = $args->{'db_password'};
+ my $dbh_is_local;
unless ( $dbh ) {
die 'No DSN' unless $dsn;
$dbh = DBI->connect( $dsn, $db_user, $db_password,
RaiseError => 1,
}
);
+ $dbh_is_local = 1;
}
die 'No database handle' unless defined $dbh;
SQL::Translator::load( $pkg );
- eval {
+ my $s = eval {
no strict 'refs';
&{ $sub }( $tr, $dbh ) or die "No result from $pkg";
};
+ my $err = $@;
- $dbh->disconnect if defined $dbh;
+ eval { $dbh->disconnect } if (defined $dbh and $dbh_is_local);
- die $@ if $@;
+ die $err if $err;
- return 1;
+ return $s;
}
1;
use Test::SQL::Translator qw(maybe_plan table_ok);
BEGIN {
- maybe_plan(60, 'SQL::Translator::Parser::DBI::PostgreSQL');
+ maybe_plan(61, 'SQL::Translator::Parser::DBI::PostgreSQL');
SQL::Translator::Parser::DBI::PostgreSQL->import('parse');
}
ok($dbh, "dbh setup correctly");
$dbh->do('SET client_min_messages=WARNING');
-my $t = SQL::Translator->new( trace => 0 );
my $sql = q[
drop table if exists sqlt_test2;
drop table if exists sqlt_test1;
$dbh->do($sql);
-my $data = SQL::Translator::Parser::DBI::PostgreSQL::parse( $t, $dbh );
+my $t = SQL::Translator->new(
+ trace => 0,
+ parser => 'DBI',
+ parser_args => { dbh => $dbh },
+);
+$t->translate;
my $schema = $t->schema;
isa_ok( $schema, 'SQL::Translator::Schema', 'Schema object' );
+
+ok ($dbh->ping, 'External handle still connected');
+
my @tables = $schema->get_tables;
my $t1 = $schema->get_table("sqlt_test1");