From: Tina Mueller Date: Fri, 11 May 2012 15:25:04 +0000 (+0200) Subject: fix diff for altering two things per column - add ; at the end X-Git-Tag: v0.011017~27 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8953d9e7977191db443a7b110971793e02bf92dc;p=dbsrgits%2FSQL-Translator.git fix diff for altering two things per column - add ; at the end replaced /;$/xms with /;\s*\z/xms since alter_field can return two or more statements --- diff --git a/Changes b/Changes index 3fdbed0..a216bdf 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,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 # ---------------------------------------------------------- # 0.11016 2012-10-09 diff --git a/lib/SQL/Translator/Diff.pm b/lib/SQL/Translator/Diff.pm index cc1ff17..a9f7654 100644 --- a/lib/SQL/Translator/Diff.pm +++ b/lib/SQL/Translator/Diff.pm @@ -308,7 +308,7 @@ sub produce_diff_sql { } my @return = - map { $_ ? ( $_ =~ /;$/xms ? $_ : "$_;\n\n" ) : "\n" } + map { $_ ? ( $_ =~ /;\s*\z/xms ? $_ : "$_;\n\n" ) : "\n" } ("-- Convert schema '$src_name' to '$tar_name':", @diffs); return wantarray ? @return : join('', @return); diff --git a/t/30sqlt-new-diff-pgsql.t b/t/30sqlt-new-diff-pgsql.t index 61dc4b5..24086ea 100644 --- a/t/30sqlt-new-diff-pgsql.t +++ b/t/30sqlt-new-diff-pgsql.t @@ -77,6 +77,9 @@ 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; ALTER TABLE person ADD CONSTRAINT unique_name UNIQUE (name); @@ -132,6 +135,9 @@ 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; ALTER TABLE person ADD CONSTRAINT UC_person_id UNIQUE (person_id); diff --git a/t/data/diff/pgsql/create1.yml b/t/data/diff/pgsql/create1.yml index 3fd443a..d313146 100644 --- a/t/data/diff/pgsql/create1.yml +++ b/t/data/diff/pgsql/create1.yml @@ -202,6 +202,17 @@ schema: size: - 11 - 2 + nickname: + data_type: varchar + default_value: ~ + extra: {} + is_nullable: 1 + is_primary_key: 0 + is_unique: 0 + name: nickname + order: 8 + size: + - 20 indices: - fields: - name diff --git a/t/data/diff/pgsql/create2.yml b/t/data/diff/pgsql/create2.yml index 42f9916..b58fdee 100644 --- a/t/data/diff/pgsql/create2.yml +++ b/t/data/diff/pgsql/create2.yml @@ -213,6 +213,17 @@ schema: size: - 11 - 2 + nickname: + data_type: varchar + default_value: ~ + extra: {} + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: nickname + order: 8 + size: + - 24 indices: - fields: - name