Return lines of output in a list context per user request.
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Producer / MySQL.pm
index 4aa0e92..1ded991 100644 (file)
@@ -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) = @_;