X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FProducer%2FClassDBI.pm;h=b52f7fe97eba397c6c6d84d90b6e541504263921;hb=f27f9229eaf8c5ce637bea1f99eb8f9bdb42799c;hp=e6ecd404c821d8013910a7d8e53af372a35ca1aa;hpb=4d1e8cb43efcd726f085384b1805a232cc550511;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Producer/ClassDBI.pm b/lib/SQL/Translator/Producer/ClassDBI.pm old mode 100755 new mode 100644 index e6ecd40..b52f7fe --- a/lib/SQL/Translator/Producer/ClassDBI.pm +++ b/lib/SQL/Translator/Producer/ClassDBI.pm @@ -1,24 +1,7 @@ package SQL::Translator::Producer::ClassDBI; -# ------------------------------------------------------------------- -# 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 -# published by the Free Software Foundation; version 2. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -# 02111-1307 USA -# ------------------------------------------------------------------- - use strict; +use warnings; use vars qw[ $VERSION $DEBUG ]; $VERSION = '1.59'; $DEBUG = 1 unless defined $DEBUG; @@ -33,7 +16,6 @@ my %CDBI_auto_pkgs = ( Oracle => 'Oracle', ); -# ------------------------------------------------------------------- sub produce { my $t = shift; local $DEBUG = $t->debug; @@ -58,9 +40,9 @@ sub produce { my $header = header_comment( __PACKAGE__, "# " ); my $parser_type = ( split /::/, $t->parser_type )[-1]; my $from = $CDBI_auto_pkgs{$parser_type} || ''; - my $dsn = $args->{'dsn'} || sprintf( 'dbi:%s:_', - $CDBI_auto_pkgs{ $parser_type } - ? $CDBI_auto_pkgs{ $parser_type } : $parser_type + my $dsn = $args->{'dsn'} || sprintf( 'dbi:%s:_', + $CDBI_auto_pkgs{ $parser_type } + ? $CDBI_auto_pkgs{ $parser_type } : $parser_type ); my $sep = '# ' . '-' x 67; @@ -180,11 +162,11 @@ sub produce { { next unless $field->is_foreign_key; - next unless ( + next unless ( $field->foreign_key_reference->reference_table eq $table_name - || - $field->foreign_key_reference->reference_table eq $link + || + $field->foreign_key_reference->reference_table eq $link ); push @lk_fields, @@ -273,7 +255,7 @@ sub produce { my $table_name = $table->name; my $field_name = $field->name; # my $fk_method = $t->format_fk_name( $table_name, $field_name ); - my $fk_method = join('::', $table_pkg_name, + my $fk_method = join('::', $table_pkg_name, $t->format_fk_name( $table_name, $field_name ) ); my $fk = $field->foreign_key_reference; @@ -352,7 +334,7 @@ sub produce { else { my $table = $schema->get_table( $pkg->{'table'} ); my @field_names = map { $_->name } $table->get_fields; - + push @create, join("\n", $pkg_name."->table('".$pkg->{'table'}."');\n", $pkg_name."->columns(All => qw/". @@ -386,8 +368,6 @@ sub produce { 1; -# ------------------------------------------------------------------- - =pod =head1 NAME