Changes + Reverts for 0.11000, see Changes file for info
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Producer / Sybase.pm
index fe2a1ab..5755cfc 100644 (file)
@@ -1,12 +1,7 @@
 package SQL::Translator::Producer::Sybase;
 
 # -------------------------------------------------------------------
-# $Id: Sybase.pm,v 1.6 2003-08-18 15:43:15 kycl4rk Exp $
-# -------------------------------------------------------------------
-# Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>,
-#                    darren chamberlain <darren@cpan.org>,
-#                    Chris Mungall <cjm@fruitfly.org>,
-#                    Sam Angiuoli <angiuoli@users.sourceforge.net>
+# 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
@@ -27,11 +22,22 @@ package SQL::Translator::Producer::Sybase;
 
 SQL::Translator::Producer::Sybase - Sybase producer for SQL::Translator
 
+=head1 SYNOPSIS
+
+  use SQL::Translator;
+
+  my $t = SQL::Translator->new( parser => '...', producer => 'Sybase' );
+  $t->translate;
+
+=head1 DESCRIPTION
+
+This module will produce text output of the schema suitable for Sybase.
+
 =cut
 
 use strict;
 use vars qw[ $DEBUG $WARN $VERSION ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/;
+$VERSION = '1.59';
 $DEBUG = 1 unless defined $DEBUG;
 
 use Data::Dumper;
@@ -314,6 +320,40 @@ sub produce {
         );
     }
 
+    foreach my $view ( $schema->get_views ) {
+        my (@comments, $view_name);
+
+        $view_name = $view->name();
+        push @comments, "--\n-- View: $view_name\n--" unless $no_comments;
+
+        # text of view is already a 'create view' statement so no need
+        # to do anything fancy.
+
+        $output .= join("\n\n",
+                       @comments,
+                       $view->sql(),
+                       );
+    }
+
+
+    foreach my $procedure ( $schema->get_procedures ) {
+        my (@comments, $procedure_name);
+
+        $procedure_name = $procedure->name();
+        push @comments, 
+            "--\n-- Procedure: $procedure_name\n--" unless $no_comments;
+
+        # text of procedure  already has the 'create procedure' stuff
+        # so there is no need to do anything fancy. However, we should
+        # think about doing fancy stuff with granting permissions and
+        # so on.
+
+        $output .= join("\n\n",
+                       @comments,
+                       $procedure->sql(),
+                       );
+    }
+
     if ( $WARN ) {
         if ( %truncated ) {
             warn "Truncated " . keys( %truncated ) . " names:\n";
@@ -395,9 +435,14 @@ sub unreserve {
 
 =pod
 
+=head1 SEE ALSO
+
+SQL::Translator.
+
 =head1 AUTHORS
 
 Sam Angiuoli E<lt>angiuoli@users.sourceforge.netE<gt>,
-Ken Y. Clark E<lt>kclark@cpan.orgE<gt>
+Paul Harrington E<lt>harringp@deshaw.comE<gt>,
+Ken Youens-Clark E<lt>kclark@cpan.orgE<gt>.
 
 =cut