From 0cbfeb23d411c1cbc092428be423055667e607e4 Mon Sep 17 00:00:00 2001 From: Diab Jerius Date: Sat, 23 Sep 2023 12:19:30 -0400 Subject: [PATCH] drop table statement wasn't added to create statement if add_drop_able attribute was set --- lib/SQL/Translator/Producer/Sybase.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/SQL/Translator/Producer/Sybase.pm b/lib/SQL/Translator/Producer/Sybase.pm index 0080c47f..55108262 100644 --- a/lib/SQL/Translator/Producer/Sybase.pm +++ b/lib/SQL/Translator/Producer/Sybase.pm @@ -289,18 +289,19 @@ sub produce { join( ', ', $index->fields ) . ")"; } - my $drop_statement = $add_drop_table - ? qq[DROP TABLE $table_name_ur] : ''; - my $create_statement = qq[CREATE TABLE $table_name_ur (\n]. + my @statements; + push @statements, qq[DROP TABLE $table_name_ur\n\n] if $add_drop_table; + push @statements, qq[CREATE TABLE $table_name_ur (\n]. join( ",\n", map { " $_" } @field_defs, @constraint_defs ). "\n)" ; - $create_statement = join("\n\n", @comments) . "\n\n" . $create_statement; + # prefix the first statement with the comments + unshift @statements, join("\n\n", @comments) . "\n\n" . shift( @statements ); push @output, - $create_statement, + @statements, @index_defs, ; }