From: Peter Rabbitson Date: Thu, 3 Jun 2010 09:08:14 +0000 (+0000) Subject: Fix index quoting for mysql X-Git-Tag: v0.11008~43 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=20476859c3c7f21b0193c827dfcab7fdda4017c1;p=dbsrgits%2FSQL-Translator.git Fix index quoting for mysql --- diff --git a/Changes b/Changes index 6a278ee..c7a1e64 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,7 @@ * Fix Producer::Oracle translate float and double to float instead of number * Fix Producer::Oracle generation of too long unique constraint names * Fix Producer::SQLite when generating VIEWs with add_drop_table => 1 +* Fix Producer::MySQL not quoting index names when requested (RT#56173) * Fix Field::default_value to behave like a real accessor (allow undef as an unsetting argument) * Producer::Oracle tests now use Test::Differences diff --git a/lib/SQL/Translator/Producer/MySQL.pm b/lib/SQL/Translator/Producer/MySQL.pm index 707abea..2214e8a 100644 --- a/lib/SQL/Translator/Producer/MySQL.pm +++ b/lib/SQL/Translator/Producer/MySQL.pm @@ -628,12 +628,10 @@ sub create_index map { $_ || () } lc $index->type eq 'normal' ? 'INDEX' : $index->type . ' INDEX', $index->name - ? ( - truncate_id_uniquely( + ? $qf . truncate_id_uniquely( $index->name, $options->{max_id_length} || $DEFAULT_MAX_ID_LENGTH - ) - ) + ) . $qf : '', '(' . $qf . join( "$qf, $qf", $index->fields ) . $qf . ')' ); diff --git a/t/38-mysql-producer.t b/t/38-mysql-producer.t index 59e26fb..61d2289 100644 --- a/t/38-mysql-producer.t +++ b/t/38-mysql-producer.t @@ -148,8 +148,8 @@ my @stmts = ( `foo` integer, `foo2` integer, `bar_set` set('foo', 'bar', 'baz'), - INDEX index_1 (`id`), - INDEX really_long_name_bigger_than_64_chars_aaaaaaaaaaaaaaaaa_aed44c47 (`id`), + INDEX `index_1` (`id`), + INDEX `really_long_name_bigger_than_64_chars_aaaaaaaaaaaaaaaaa_aed44c47` (`id`), INDEX (`foo`), INDEX (`foo2`), PRIMARY KEY (`id`, `foo`),