package SQL::Translator::Producer::Turnkey;
# -------------------------------------------------------------------
-# $Id: Turnkey.pm,v 1.33 2004-04-03 04:01:13 allenday Exp $
+# $Id: Turnkey.pm,v 1.34 2004-04-06 00:27:02 allenday Exp $
# -------------------------------------------------------------------
# Copyright (C) 2002-4 SQLFairy Authors
#
use strict;
use vars qw[ $VERSION $DEBUG ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.33 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.34 $ =~ /(\d+)\.(\d+)/;
$DEBUG = 1 unless defined $DEBUG;
use SQL::Translator::Schema::Constants;
my $t = shift;
my $meta = shift;
+ $meta->{_dumper} = \&_dumper;
+
my $args = $t->producer_args;
my $type = $meta->{'template'};
return($result);
}
+sub _dumper($) {
+ my $s = shift;
+ warn $s;
+
+ my $d = Data::Dumper($s);
+ warn $d;
+ return $d;
+}
+
1;
# -------------------------------------------------------------------
[% thisnode = h.thisnode_index(0) %]
[% i = 0 %]
[% FOREACH thatnode = h.thatnode %]
+ [% NEXT UNLESS h.thisviafield_index(i).name %]
#[% thisnode.name %]::[% h.thisfield_index(0).name %] -> [% h.vianode.name %]::[% h.thisviafield_index(i).name %] ... [% h.vianode.name %]::[% h.thatviafield_index(0).name %] <- [% h.thatnode_index(0).name %]::[% h.thatfield_index(0).name %]
sub [% h.vianode.table.name %]_[% format_fk(h.vianode,h.thatviafield_index(0).name) %]s { my \$self = shift; return map \$_->[% h.thatviafield_index(0).name %], \$self->[% h.vianode.table.name %]_[% h.thisviafield_index(i).name %] }
[% i = i + 1 %]
thatfield => $self->translator->schema->get_table($field->foreign_key_reference->reference_table)->get_field(($field->foreign_key_reference->reference_fields)[0])
);
+# $node->edgecount($that->name, $node->edgecount($that->name)+1);
$node->edgecount($that->name, $node->edgecount($that->name)+1);
$node->has($that->name, $node->has($that->name)+1);
$that->many($node->name, $that->many($node->name)+1);
+# $that->edgecount($node->name, $that->edgecount($node->name)+1);
$that->edgecount($node->name, $that->edgecount($node->name)+1);
-#warn $node->name . "\t" . $that->edgecount($node->name);
+
+ #warn "\t" . $node->name . "\t" . $node->edgecount($that->name);
$node->push_edges( $edge );
$that->push_edges( $edge->flip );
}
}
+
+ #warn Dumper($node->edgecount());
+ #warn "*****";
}
#
'array_of_objects -class SQL::Translator::Schema::Graph::Edge' => [ qw( edges ) ],
'array_of_objects -class SQL::Translator::Schema::Graph::CompoundEdge' => [ qw( compoundedges ) ],
'array_of_objects -class SQL::Translator::Schema::Graph::HyperEdge' => [ qw( hyperedges ) ],
- 'hash' => [ qw( many via has edgecount data_fields) ],
+ #'hash' => [ qw( many via has edgecount data_fields) ],
+ 'hash' => [ qw( many via has data_fields) ],
scalar => [ qw( base name order primary_key primary_key_accessor table is_trivial_link ) ],
number => [ qw( order ) ],
);
+sub edgecount {
+ my($self) = shift;
+
+ $self->{_edgecount} ||= {};
+
+ if(scalar(@_) == 1){
+ my $k = shift;
+ return $self->{_edgecount}{$k};
+ } elsif(@_) {
+ my %arg = @_;
+
+ foreach my $k (keys %arg){
+ #warn $a,"\t",$arg{$k};
+ $self->{_edgecount}{$k} = $arg{$k};
+ }
+
+ return %arg;
+ } else {
+ return $self->{_edgecount};
+ }
+}
+
1;