From: Ken Youens-Clark Date: Wed, 15 Jun 2005 18:05:07 +0000 (+0000) Subject: Put field and table comments into proper MySQL syntax. X-Git-Tag: v0.11008~535 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f8b6e804df25208360580608e365986f10135787;hp=62bff80557556f36704816a1eaebb23708033ae3;p=dbsrgits%2FSQL-Translator.git Put field and table comments into proper MySQL syntax. --- diff --git a/lib/SQL/Translator/Producer/MySQL.pm b/lib/SQL/Translator/Producer/MySQL.pm index 001e8fa..1b5a388 100644 --- a/lib/SQL/Translator/Producer/MySQL.pm +++ b/lib/SQL/Translator/Producer/MySQL.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::MySQL; # ------------------------------------------------------------------- -# $Id: MySQL.pm,v 1.43 2005-06-08 14:44:07 grommit Exp $ +# $Id: MySQL.pm,v 1.44 2005-06-15 18:05:07 kycl4rk Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -83,7 +83,7 @@ Set the fields charater set and collation order. use strict; use vars qw[ $VERSION $DEBUG ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.43 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.44 $ =~ /(\d+)\.(\d+)/; $DEBUG = 0 unless defined $DEBUG; use Data::Dumper; @@ -252,6 +252,10 @@ sub produce { } } + if ( my $comments = $field->comments ) { + $field_def .= qq[ comment '$comments']; + } + # auto_increment? $field_def .= " auto_increment" if $field->is_auto_increment; push @field_defs, $field_def; @@ -353,9 +357,12 @@ sub produce { my $mysql_table_type = $table->extra('mysql_table_type'); my $charset = $table->extra('mysql_charset'); my $collate = $table->extra('mysql_collate'); + my $comments = $table->comments; + $create .= " Type=$mysql_table_type" if $mysql_table_type; $create .= " DEFAULT CHARACTER SET $charset" if $charset; $create .= " COLLATE $collate" if $collate; + $create .= qq[ comment='$comments'] if $comments; $create .= ";\n\n"; }