X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FParser%2FDBI%2FSQLServer.pm;h=267e6f8525e084f9d3cf90519aa467be9aee4719;hb=4ab3763d2ad756c236b757306989cafa08e7f35e;hp=cb2eb4eb00532fa86c030bd68115edb3ad47421c;hpb=4eb28bc31cdc1d754b7a853e7bd00244b683e7cb;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Parser/DBI/SQLServer.pm b/lib/SQL/Translator/Parser/DBI/SQLServer.pm index cb2eb4e..267e6f8 100644 --- a/lib/SQL/Translator/Parser/DBI/SQLServer.pm +++ b/lib/SQL/Translator/Parser/DBI/SQLServer.pm @@ -1,9 +1,7 @@ package SQL::Translator::Parser::DBI::SQLServer; # ------------------------------------------------------------------- -# $Id: SQLServer.pm,v 1.1 2005-06-27 19:00:19 duality72 Exp $ -# ------------------------------------------------------------------- -# Copyright (C) 2002-4 SQLFairy Authors +# 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 @@ -40,7 +38,7 @@ use SQL::Translator::Schema; use Data::Dumper; use vars qw[ $DEBUG $VERSION @EXPORT_OK ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/; +$VERSION = '1.59'; $DEBUG = 0 unless defined $DEBUG; no strict 'refs'; @@ -141,7 +139,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 +222,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 @@ -243,7 +243,7 @@ $table_info->{TABLE_NAME}", 'COLUMN_NAME'); } # add in foreign keys - my $h = $dbh->selectall_hashref("sp_fkeys NULL, + $h = $dbh->selectall_hashref("sp_fkeys NULL, \@fktable_name = '$table_info->{TABLE_NAME}'", 'FK_NAME'); foreach my $fk ( values %{$h} ) { my $constraint = $table->add_constraint( name => $fk->{FK_NAME}, @@ -295,6 +295,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 +321,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},