- Added some stuff to MANIFEST.SKIP
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Parser / DBI / SQLServer.pm
index c22160a..bd67a43 100644 (file)
@@ -1,7 +1,7 @@
 package SQL::Translator::Parser::DBI::SQLServer;
 
 # -------------------------------------------------------------------
-# $Id: SQLServer.pm,v 1.2 2005-07-07 15:20:00 mwz444 Exp $
+# $Id$
 # -------------------------------------------------------------------
 # Copyright (C) 2002-4 SQLFairy Authors
 #
@@ -40,7 +40,7 @@ use SQL::Translator::Schema;
 use Data::Dumper;
 
 use vars qw[ $DEBUG $VERSION @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/;
 $DEBUG   = 0 unless defined $DEBUG;
 
 no strict 'refs';
@@ -141,7 +141,7 @@ SELECT o.name, colid,c.text
   FROM syscomments c
   JOIN sysobjects o
     ON c.id = o.id
- WHERE o.type ='P'
+ WHERE o.type in ('P', 'FN', 'TF', 'IF')
 }
 );
 
@@ -224,8 +224,10 @@ $table_info->{TABLE_TYPE},
                                          ) || die $table->error;
                 $f->is_nullable($c->{NULLABLE} == 1);
                 $f->is_auto_increment($is_auto_increment);
-                $c->{COLUMN_DEF} =~ s#\('?(.*?)'?\)#$1#;
-                $f->default_value($c->{COLUMN_DEF}) if defined $c->{COLUMN_DEF};
+                if ( defined $c->{COLUMN_DEF}) {
+                       $c->{COLUMN_DEF} =~ s#\('?(.*?)'?\)#$1#;
+                       $f->default_value($c->{COLUMN_DEF});
+                }
             }
 
             # add in primary key
@@ -295,6 +297,7 @@ $_->{INDEX_NAME},
         } elsif ($table_info->{TABLE_TYPE} eq 'VIEW') {
                next if $table_info->{TABLE_NAME} eq 'sysconstraints'
                        || $table_info->{TABLE_NAME} eq 'syssegments';
+               next if !$stuff->{view}->{$table_info->{TABLE_NAME}}->{text};
             my $view =  $schema->add_view(
                                           name =>
 $table_info->{TABLE_NAME},
@@ -320,6 +323,7 @@ $table_info->{TABLE_NAME},
     }
 
     foreach my $p (values %{$stuff->{procedures}}) {
+       next if !$p->{text};
         my $proc = $schema->add_procedure(
                                name      => $p->{name},
                                owner     => $p->{PROCEDURE_OWNER},