From: Tina Mueller Date: Fri, 11 May 2012 16:22:38 +0000 (+0200) Subject: produce_diff_sql(): list context X-Git-Tag: v0.011017~26 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f19edf3642e7e41b090683ff00c87c6e3cf2094e;p=dbsrgits%2FSQL-Translator.git produce_diff_sql(): list context rather change the calling of alter_field and the other methods to list context so that if they return multiple statements produce_diff_sql() can return them also seperately in list context --- diff --git a/Changes b/Changes index a216bdf..f8e590e 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,7 @@ * De-linkify XML namespace in docs (RT#81838) * Allow both single and double quotes for values in MySQL parser * Fix diff for altering two things per column - add ; at the end +* Call all diff methods in list context (it can be merged later) # ---------------------------------------------------------- # 0.11016 2012-10-09 diff --git a/lib/SQL/Translator/Diff.pm b/lib/SQL/Translator/Diff.pm index a9f7654..c291ce4 100644 --- a/lib/SQL/Translator/Diff.pm +++ b/lib/SQL/Translator/Diff.pm @@ -248,8 +248,7 @@ sub produce_diff_sql { my $meth = $producer_class->can($_); $meth ? map { - my $sql = $meth->( (ref $_ eq 'ARRAY' ? @$_ : $_), $self->producer_args ); - $sql ? ("$sql") : (); + map { $_ ? "$_" : () } $meth->( (ref $_ eq 'ARRAY' ? @$_ : $_), $self->producer_args ); } @{ $flattened_diffs{$_} } : $self->ignore_missing_methods ? "-- $producer_class cant $_" diff --git a/t/30sqlt-new-diff-pgsql.t b/t/30sqlt-new-diff-pgsql.t index 24086ea..ba61ee5 100644 --- a/t/30sqlt-new-diff-pgsql.t +++ b/t/30sqlt-new-diff-pgsql.t @@ -78,6 +78,7 @@ ALTER TABLE person ALTER COLUMN age SET DEFAULT 18; ALTER TABLE person ALTER COLUMN iq TYPE bigint; ALTER TABLE person ALTER COLUMN nickname SET NOT NULL; + ALTER TABLE person ALTER COLUMN nickname TYPE character varying(24); ALTER TABLE person RENAME COLUMN description TO physical_description; @@ -136,6 +137,7 @@ ALTER TABLE person ALTER COLUMN age SET DEFAULT 18; ALTER TABLE person ALTER COLUMN iq TYPE bigint; ALTER TABLE person ALTER COLUMN nickname SET NOT NULL; + ALTER TABLE person ALTER COLUMN nickname TYPE character varying(24); ALTER TABLE person RENAME COLUMN description TO physical_description;