package SQL::Translator::Parser::Sybase;
# -------------------------------------------------------------------
-# $Id: Sybase.pm,v 1.5 2003-08-19 21:05:47 kycl4rk Exp $
-# -------------------------------------------------------------------
-# Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>,
-# darren chamberlain <darren@cpan.org>,
-# Chris Mungall <cjm@fruitfly.org>
+# Copyright (C) 2002-2009 SQLFairy Authors
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
=head1 DESCRIPTION
-Parses the output of "dbschema.pl," a Perl script freely available from
-www.midsomer.org.
+Mostly parses the output of "dbschema.pl," a Perl script freely
+available from http://www.midsomer.org. The parsing is not complete,
+however, and you would probably have much better luck using the
+DBI-Sybase parser included with SQL::Translator.
=cut
use strict;
use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/;
+$VERSION = '1.59';
$DEBUG = 0 unless defined $DEBUG;
use Data::Dumper;
@EXPORT_OK = qw(parse);
-# Enable warnings within the Parse::RecDescent module.
-$::RD_ERRORS = 1; # Make sure the parser dies when it encounters an error
-$::RD_WARN = 1; # Enable warnings. This will warn on unused rules &c.
-$::RD_HINT = 1; # Give out hints to help fix problems.
+$::RD_ERRORS = 1;
+$::RD_WARN = 1;
+$::RD_HINT = 1;
$GRAMMAR = q{
{
- our ( %tables, @table_comments );
+ my ( %tables, @table_comments, $table_order );
}
startrule : statement(s) eofile { \%tables }
@table_comments = ();
}
+ $tables{ $table_name }{'order'} = ++$table_order;
$tables{ $table_name }{'name'} = $table_name;
$tables{ $table_name }{'owner'} = $table_owner;
$tables{ $table_name }{'system'} = $item[7];
reference_table => $cdata->{'reference_table'},
reference_fields => $cdata->{'reference_fields'},
match_type => $cdata->{'match_type'} || '',
- on_delete => $cdata->{'on_delete_do'},
- on_update => $cdata->{'on_update_do'},
+ on_delete => $cdata->{'on_delete'} || $cdata->{'on_delete_do'},
+ on_update => $cdata->{'on_update'} || $cdata->{'on_update_do'},
) or die $table->error;
}
}
=head1 SEE ALSO
-perl(1).
+SQL::Translator, SQL::Translator::Parser::DBI, L<http://www.midsomer.org/>.
=cut