From: Chris Hilton Date: Fri, 15 Jul 2005 23:36:13 +0000 (+0000) Subject: Fixed case-insensitivity matching for SQL Server and field names X-Git-Tag: v0.11008~496 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3a7eb46ecfa10f9d2fd4eb69c9303d09a7dc2aa7;p=dbsrgits%2FSQL-Translator.git Fixed case-insensitivity matching for SQL Server and field names --- diff --git a/bin/sqlt-diff b/bin/sqlt-diff index 1e2ccbd..cf0bd09 100755 --- a/bin/sqlt-diff +++ b/bin/sqlt-diff @@ -2,7 +2,7 @@ # vim: set ft=perl: # ------------------------------------------------------------------- -# $Id: sqlt-diff,v 1.9 2005-07-07 21:30:42 mwz444 Exp $ +# $Id: sqlt-diff,v 1.10 2005-07-15 23:36:13 duality72 Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002-4 The SQLFairy Authors # @@ -97,7 +97,7 @@ use SQL::Translator; use SQL::Translator::Schema::Constants; use vars qw( $VERSION ); -$VERSION = sprintf "%d.%02d", q$Revision: 1.9 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/; my ( @input, $list, $help, $debug ); for my $arg ( @ARGV ) { @@ -240,7 +240,7 @@ OPTION: my $f1_nullable = $t1_field->is_nullable; my $f1_default = $t1_field->default_value; my $f1_auto_inc = $t1_field->is_auto_increment; - my $t2_field = $t2->get_field( $f1_name ); + my $t2_field = $t2->get_field( $f1_name, $case_insensitive ); my $f1_full_name = "$s1_name.$t1_name.$t1_name"; warn "FIELD '$f1_full_name'\n" if $debug; diff --git a/lib/SQL/Translator/Schema/Table.pm b/lib/SQL/Translator/Schema/Table.pm index 7bef851..d14e7aa 100644 --- a/lib/SQL/Translator/Schema/Table.pm +++ b/lib/SQL/Translator/Schema/Table.pm @@ -1,7 +1,7 @@ package SQL::Translator::Schema::Table; # ---------------------------------------------------------------------- -# $Id: Table.pm,v 1.33 2005-06-29 22:02:29 duality72 Exp $ +# $Id: Table.pm,v 1.34 2005-07-15 23:36:13 duality72 Exp $ # ---------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -51,7 +51,7 @@ use base 'SQL::Translator::Schema::Object'; use vars qw( $VERSION $FIELD_ORDER ); -$VERSION = sprintf "%d.%02d", q$Revision: 1.33 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.34 $ =~ /(\d+)\.(\d+)/; # Stringify to our name, being careful not to pass any args through so we don't @@ -490,6 +490,14 @@ Returns a field by the name provided. my $self = shift; my $field_name = shift or return $self->error('No field name'); + my $case_insensitive = shift; + if ( $case_insensitive ) { + $field_name = uc($field_name); + foreach my $field ( keys %{$self->{fields}} ) { + return $self->{fields}{$field_name} if $field_name eq uc($field); + } + return $self->error(qq[Field "$field_name" does not exist]); + } return $self->error( qq[Field "$field_name" does not exist] ) unless exists $self->{'fields'}{ $field_name }; return $self->{'fields'}{ $field_name };