On Wed Jan 23 08:32:45 2013, RIBASUSHI wrote:
Show quoted text> I much prefer this last option. Care to take a stab at a patch?
Done! The first code I've ever written on an airplane.
*** SQL-Translator-0.11016/lib/SQL/Translator/Producer/SQLite.pm 2012-09-23 11:17:34.000000000 -0400
--- SQL-Translator-0.11016-mod/lib/SQL/Translator/Producer/SQLite.pm 2013-01-27 11:27:04.682708900 -0400
***************
*** 70,81 ****
my @create = ();
! push @create, "BEGIN TRANSACTION" unless $no_txn;
for my $table ( $schema->get_tables ) {
push @create, create_table($table, { no_comments => $no_comments,
sqlite_version => $sqlite_version,
add_drop_table => $add_drop_table,});
}
for my $view ( $schema->get_views ) {
--- 70,82 ----
my @create = ();
! my $stmt_input = 0;
for my $table ( $schema->get_tables ) {
push @create, create_table($table, { no_comments => $no_comments,
sqlite_version => $sqlite_version,
add_drop_table => $add_drop_table,});
+ $stmt_input = 1;
}
for my $view ( $schema->get_views ) {
***************
*** 83,88 ****
--- 84,90 ----
add_drop_view => $add_drop_table,
no_comments => $no_comments,
});
+ $stmt_input = 1;
}
for my $trigger ( $schema->get_triggers ) {
***************
*** 90,98 ****
add_drop_trigger => $add_drop_table,
no_comments => $no_comments,
});
}
! push @create, "COMMIT" unless $no_txn;
if (wantarray) {
return ($head||(), @create);
--- 92,104 ----
add_drop_trigger => $add_drop_table,
no_comments => $no_comments,
});
+ $stmt_input = 1;
}
! if ($stmt_input and not $no_txn) {
! unshift @create, "BEGIN TRANSACTION";
! push @create, "COMMIT";
! }
if (wantarray) {
return ($head||(), @create);
***************
*** 100,106 ****
return join ('',
$head||(),
join(";\n\n", @create ),
! ";\n",
);
}
}
--- 106,112 ----
return join ('',
$head||(),
join(";\n\n", @create ),
! $stmt_input ? ";\n" : '',
);
}
}