The annexed patch is by a colleague of mine, Adriano Nagelschmidt RODRIGUES. Now I can use SQL Fairy in multi-schema MySQL dumps, with both table and column comments.
There are ſtill ſome issues, but we do not feel like tackling them
right now (lack of time and experience):
* Comments are ignored, not showing up neither in diagrams nor in model
listings;
* In multi-schema dumps, tables having the same name as one formerly
declared in another schema are ignored: that is, only the first one
appears.
Also I am checking sql2dia, but it is crude. It would be nice if
anyone had anything using SQL Fairy to generate Dia files or something
the like — Kivio perhaps?
--
Leandro Guimarães Faria Corcete DUTRA <[EMAIL PROTECTED]>
http://orolix.com.br./
+55 (11) 2122 0302
Join the FSF: http://www.fsf.org/register_form?referrer=4686
diff -ru SQL.ori/Translator/Parser/MySQL.pm SQL.new/Translator/Parser/MySQL.pm
--- SQL.ori/Translator/Parser/MySQL.pm 2006-07-04 18:42:10.000000000 -0300
+++ SQL.new/Translator/Parser/MySQL.pm 2007-02-08 12:20:05.000000000 -0200
@@ -176,7 +176,7 @@
| insert
| <error>
-use : /use/i WORD ';'
+use : /use/i NAME ';'
{
$database_name = $item[2];
@table_comments = ();
@@ -185,9 +185,9 @@
set : /set/i /[^;]+/ ';'
{ @table_comments = () }
-drop : /drop/i TABLE /[^;]+/ ';'
+drop : /drop/i inline_comment(?) TABLE /[^;]+/ ';'
-drop : /drop/i WORD(s) ';'
+drop : /drop/i inline_comment(?) NAME(s) ';'
{ @table_comments = () }
insert : /insert/i /[^;]+/ ';'
@@ -206,7 +206,7 @@
alter_specification : ADD foreign_key_def
{ $return = $item[2] }
-create : CREATE /database/i WORD ';'
+create : CREATE /database/i inline_comment(?) NAME inline_comment(?) ';'
{ @table_comments = () }
create : CREATE TEMPORARY(?) TABLE opt_if_not_exists(?) table_name '(' create_definition(s /,/) /(,\s*)?\)/ table_option(s?) ';'
@@ -283,7 +283,14 @@
comment : /\/\*/ /[^\*]+/ /\*\// ';'
{
- my $comment = $item[2];
+ my $comment = $item[1];
+ $comment =~ s/^\s*|\s*$//g;
+ $return = $comment;
+ }
+
+inline_comment : /\/\*/ /[^\*]+/ /\*\//
+ {
+ my $comment = $item[1];
$comment =~ s/^\s*|\s*$//g;
$return = $comment;
}
@@ -296,9 +303,19 @@
$return = $comment;
}
+col_comment : 'COMMENT' /'(?:''|[^'])*'/
+ {
+ $return = $item[2];
+ }
+
+table_comment : 'COMMENT' '=' /'(?:''|[^'])*'/
+ {
+ $return = $item[3];
+ }
+
blank : /\s*/
-field : field_comment(s?) field_name data_type field_qualifier(s?) reference_definition(?) on_update_do(?) field_comment(s?)
+field : field_comment(s?) field_name data_type field_qualifier(s?) col_comment(?) reference_definition(?) on_update_do(?) field_comment(s?)
{
my %qualifiers = map { %$_ } @{ $item{'field_qualifier(s?)'} || [] };
if ( my @type_quals = @{ $item{'data_type'}{'qualifiers'} || [] } ) {
@@ -367,7 +384,7 @@
}
}
-reference_definition : /references/i table_name parens_field_list(?) match_type(?) on_delete_do(?) on_update_do(?)
+reference_definition : /references/i schema_name parens_field_list(?) match_type(?) on_delete_do(?) on_update_do(?)
{
$return = {
type => 'foreign_key',
@@ -379,6 +396,12 @@
}
}
+schema_name :
+ db_name '.' table_name
+ { $return = $item[3] }
+ |
+ table_name
+
match_type : /match full/i { 'full' }
|
/match partial/i { 'partial' }
@@ -406,6 +429,8 @@
table_name : NAME
+db_name : NAME
+
field_name : NAME
index_name : NAME
@@ -503,7 +528,12 @@
$return = $item[2];
}
|
- /default/i /'(?:.*?\\')*.*?'|(?:')?[\w\d:.-]*(?:')?/
+ /default/i 'NULL'
+ {
+ $return = $item[2];
+ }
+ |
+ /default/i /'(?:''|[^'])*'|/
{
$item[2] =~ s/^\s*'|'\s*$//g;
$return = $item[2];
@@ -599,6 +629,7 @@
{
$return = { $item[1] => $item[3] };
}
+ | table_comment
ADD : /add/i
signature.asc
Description: Esta é uma parte de mensagem assinada digitalmente
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
-- sqlfairy-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sqlfairy-developers
