[Jifty-commit] r6981 - Jifty-DBI/trunk/t
Jifty commits
jifty-commit at lists.jifty.org
Mon May 11 17:16:04 EDT 2009
Author: ruz
Date: Mon May 11 17:16:02 2009
New Revision: 6981
Modified:
Jifty-DBI/trunk/t/utils.pl
Log:
* add drop_table_if_exists in t/utils.t
Modified: Jifty-DBI/trunk/t/utils.pl
==============================================================================
--- Jifty-DBI/trunk/t/utils.pl (original)
+++ Jifty-DBI/trunk/t/utils.pl Mon May 11 17:16:02 2009
@@ -309,4 +309,27 @@
return $count;
}
+=head2 drop_table_if_exists
+
+Takes a table name and handle. Drops the table in the DB if it exists.
+Returns nothing interesting, shouldn't die.
+
+=cut
+
+sub drop_table_if_exists {
+ my ($table, $handle) = @_;
+ my $d = handle_to_driver( $handle );
+ if ( $d eq 'Pg' ) {
+ my $exists = $handle->dbh->selectrow_array(
+ "select 1 from pg_tables where tablename = ?", undef, $table
+ );
+ $handle->simple_query("DROP TABLE test") if $exists;
+ }
+ else {
+ local $@;
+ eval { $handle->simple_query("DROP TABLE IF EXISTS $table") };
+ }
+ return;
+}
+
1;
More information about the Jifty-commit
mailing list