[Catalyst-commits] r9363 - trunk/Catalyst-Example-InstantCRUD/script
zby at dev.catalyst.perl.org
zby at dev.catalyst.perl.org
Fri Feb 20 15:02:38 GMT 2009
Author: zby
Date: 2009-02-20 15:02:38 +0000 (Fri, 20 Feb 2009)
New Revision: 9363
Modified:
trunk/Catalyst-Example-InstantCRUD/script/instantcrud.pl
Log:
fix for oveloading; refactoring schema loading
Modified: trunk/Catalyst-Example-InstantCRUD/script/instantcrud.pl
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/script/instantcrud.pl 2009-02-20 13:50:28 UTC (rev 9362)
+++ trunk/Catalyst-Example-InstantCRUD/script/instantcrud.pl 2009-02-20 15:02:38 UTC (rev 9363)
@@ -89,8 +89,9 @@
local $FindBin::Bin = dir($appdir, 'script');
+my $full_schema_name = $appname . '::' . $schema_name;
make_schema_at(
- $appname . '::' . $schema_name,
+ $full_schema_name,
{
# debug => 1,
dump_directory => dir( $appdir , 'lib')->absolute->stringify,
@@ -100,16 +101,16 @@
[ $dsn, $duser, $dpassword ],
);
-{
- no strict 'refs';
- @{"$schema_name\::ISA"} = qw/DBIx::Class::Schema::Loader/;
- $schema_name->loader_options(relationships => 1, exclude => qr/^sqlite_sequence$/);
-}
+#{
+# no strict 'refs';
+# @{"$schema_name\::ISA"} = qw/DBIx::Class::Schema::Loader/;
+# $schema_name->loader_options(relationships => 1, exclude => qr/^sqlite_sequence$/);
+#}
-my $schema = $schema_name->connect($dsn, $duser, $dpassword);
+my $schema = $full_schema_name->connect(); #$dsn, $duser, $dpassword);
my ( $m2m, $bridges ) = guess_m2m( $schema );
-for my $result_class ( keys %$m2m ){
+for my $result_class ( $schema->sources ){
my $result_source = $schema->source( $result_class );
my $overload_method = first { $_ =~ /name/i } $result_source->columns;
$overload_method ||= 'id';
@@ -149,8 +150,7 @@
CLASS:
for my $s ( $schema->sources ) {
my $source = $schema->source($s);
- my $c = $schema->class($s);
- my @relationships = $c->relationships;
+ my @relationships = $source->relationships;
my @cols = $source->columns;
next if scalar @relationships != 2;
next if scalar @cols!= 2;
@@ -161,10 +161,9 @@
my $rclass_name = $info->{class};
$rclass_name =~ /([^:]*)$/;
$rclass_name = $1;
- my $rclass = $schema->class( $rclass_name );
my $rsource = $schema->source( $rclass_name );
my $found;
- for my $rrel ( $rclass->relationships ){
+ for my $rrel ( $rsource->relationships ){
my $rinfo = $rsource->relationship_info($rrel);
my $rrclass_name = $rinfo->{class};
$rrclass_name =~ /([^:]*)$/;
More information about the Catalyst-commits
mailing list