X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FProducer%2FMySQL.pm;h=1ded991ebb9ceb2c51b488cb36465a66cc19467b;hb=bf75adec88e7d32b300af8897772a1522955d185;hp=4aa0e920feb86870e7d47c9f90472b7e4a2e4490;hpb=08dd65937e43a5d15659144bee2e5d3a5f763f27;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Producer/MySQL.pm b/lib/SQL/Translator/Producer/MySQL.pm index 4aa0e92..1ded991 100644 --- a/lib/SQL/Translator/Producer/MySQL.pm +++ b/lib/SQL/Translator/Producer/MySQL.pm @@ -1,8 +1,6 @@ package SQL::Translator::Producer::MySQL; # ------------------------------------------------------------------- -# $Id$ -# ------------------------------------------------------------------- # Copyright (C) 2002-2009 SQLFairy Authors # # This program is free software; you can redistribute it and/or @@ -101,7 +99,8 @@ Set the fields charater set and collation order. use strict; use warnings; -use vars qw[ $DEBUG %used_names ]; +use vars qw[ $VERSION $DEBUG %used_names ]; +$VERSION = '1.59'; $DEBUG = 0 unless defined $DEBUG; # Maximum length for most identifiers is 64, according to: @@ -370,7 +369,7 @@ sub create_table my $qt = $options->{quote_table_names} || ''; my $qf = $options->{quote_field_names} || ''; - my $table_name = $table->name; + my $table_name = quote_table_name($table->name, $qt); debug("PKG: Looking at table '$table_name'\n"); # @@ -378,9 +377,9 @@ sub create_table # my $create = ''; my $drop; - $create .= "--\n-- Table: $qt$table_name$qt\n--\n" unless $options->{no_comments}; - $drop = qq[DROP TABLE IF EXISTS $qt$table_name$qt] if $options->{add_drop_table}; - $create .= "CREATE TABLE $qt$table_name$qt (\n"; + $create .= "--\n-- Table: $table_name\n--\n" unless $options->{no_comments}; + $drop = qq[DROP TABLE IF EXISTS $table_name] if $options->{add_drop_table}; + $create .= "CREATE TABLE $table_name (\n"; # # Fields @@ -429,6 +428,14 @@ sub create_table return $drop ? ($drop,$create) : $create; } +sub quote_table_name { + my ($table_name, $qt) = @_; + + $table_name =~ s/\./$qt.$qt/g; + + return "$qt$table_name$qt"; +} + sub generate_table_options { my ($table, $options) = @_;