From: Allen Day Date: Mon, 13 Oct 2003 22:05:44 +0000 (+0000) Subject: ugh, i don't want to maintain this branch any longer... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e12e1ffc871bcc1572385aa2bac082dffc07f9e7;p=dbsrgits%2FSQL-Translator.git ugh, i don't want to maintain this branch any longer... this fix addresses non-generation of atom-container associations for 1-M and M-1 relationships. prior to this fix only M-M relationships were written to the xml config file --- diff --git a/lib/SQL/Translator/Producer/Turnkey.pm b/lib/SQL/Translator/Producer/Turnkey.pm index 0a5dc8e..89f9043 100644 --- a/lib/SQL/Translator/Producer/Turnkey.pm +++ b/lib/SQL/Translator/Producer/Turnkey.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::Turnkey; # ------------------------------------------------------------------- -# $Id: Turnkey.pm,v 1.1.2.6 2003-10-13 19:44:33 allenday Exp $ +# $Id: Turnkey.pm,v 1.1.2.7 2003-10-13 22:05:44 allenday Exp $ # ------------------------------------------------------------------- # Copyright (C) 2003 Allen Day , # Ying Zhang @@ -23,7 +23,7 @@ package SQL::Translator::Producer::Turnkey; use strict; use vars qw[ $VERSION $DEBUG ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.1.2.6 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.1.2.7 $ =~ /(\d+)\.(\d+)/; $DEBUG = 1 unless defined $DEBUG; use SQL::Translator::Schema::Constants; @@ -186,6 +186,9 @@ sub produce { #push @{ $packages{ $table_pkg_name }{'has_many'}{ $link }{'one_one'} }, # {link_method_name => $linkmethodname, primary_key_field => ($schema->get_table($link)->primary_key->fields)[0], # table_name => $linkable{$table_name}{$link}->name, rk_field => $rk_field}; + + if(!$linktable{$table_name} and !$linktable{$link}){ $linkable{$table_name}{$link} ||= 1; } + } #else there is more than one way to traverse it. ack! #let's treat these types of link tables as a many-to-one (easier) @@ -205,6 +208,9 @@ sub produce { # { # table_name => $linkable{$table_name}{$link}->name, rk_field => $rk_field # }; + + if(!$linktable{$table_name} and !$linktable{$link}){ $linkable{$table_name}{$link} ||= 1; } + } } elsif (scalar(@lk_fields) == 1) { #these will be taken care of on the other end... @@ -224,6 +230,9 @@ sub produce { # { # table_name => $linkable{$table_name}{$link}->name, rk_field => $rk_field # }; + + if(!$linktable{$table_name} and !$linktable{$link}){ $linkable{$table_name}{$link} ||= 1; } + } } } @@ -250,6 +259,7 @@ sub produce { " return shift->$field_name\n}\n\n" ; + if(!$linktable{$ref_table} and !$linktable{$table_name}){ $linkable{$ref_table}{$table_name} ||= 1; } # # If this table "has a" to the other, then it follows @@ -267,6 +277,8 @@ sub produce { push @{ $packages{ $ref_pkg }{'has_many'}{ $table_name }{'fk_pluralized'} }, { table_name => $table_name, field_name => $field_name }; + if(!$linktable{$ref_table} and !$linktable{$table_name}){ $linkable{$ref_table}{$table_name} ||= 1; } + #else ugly } else { } @@ -276,6 +288,8 @@ sub produce { # "'$table_pkg_name' => '$field_name'\n);\n\n"; push @{ $packages{ $ref_pkg }{'has_many'}{ $table_name }{pluralized} }, { ref_pkg => $ref_pkg, table_pkg_name => $table_pkg_name, table_name => $table_name, field_name => $field_name }; + + if(!$linktable{$ref_table} and !$linktable{$table_name}){ $linkable{$ref_table}{$table_name} ||= 1; } } } } @@ -369,6 +383,7 @@ sub head { [% END %] EOF + my $turnkey_dbi_tt2 = <_do_search(ILIKE => @_) } [% FOREACH package = packages %] [% printPackage(package.value) %] [% END %] +EOF my $turnkey_xml_tt2 = < @@ -472,14 +488,16 @@ my $turnkey_xml_tt2 = < [% FOREACH package = linkable %] - + [% class = package.key | replace('Turnkey::Model::',''); class = class FILTER ucfirst; %] + [% END %] [% FOREACH focus_atom = linkable %] [% FOREACH link_atom = focus_atom.value %] - + [% class = focus_atom.key | replace('Turnkey::Model::',''); class = class FILTER ucfirst; %] + [% END %] [% END %] @@ -501,7 +519,8 @@ my $turnkey_xml_tt2 = < [% FOREACH focus_atom = linkable %] - + [% class = focus_atom.key | replace('Turnkey::Model::','') ; class = class FILTER ucfirst %] + [% END %]