[Bast-commits] r4147 - in DBIx-Class/0.08/branches/cdbicompat_integration: . lib/DBIx/Class/CDBICompat t/cdbi-t

schwern at dev.catalyst.perl.org schwern at dev.catalyst.perl.org
Fri Mar 7 16:08:41 GMT 2008


Author: schwern
Date: 2008-03-07 16:08:41 +0000 (Fri, 07 Mar 2008)
New Revision: 4147

Modified:
   DBIx-Class/0.08/branches/cdbicompat_integration/
   DBIx-Class/0.08/branches/cdbicompat_integration/lib/DBIx/Class/CDBICompat/Relationship.pm
   DBIx-Class/0.08/branches/cdbicompat_integration/lib/DBIx/Class/CDBICompat/Relationships.pm
   DBIx-Class/0.08/branches/cdbicompat_integration/t/cdbi-t/24-meta_info.t
Log:
 r54601 at windhund:  schwern | 2008-02-24 11:13:43 +0100
 Make meta_info() 'args' work.



Property changes on: DBIx-Class/0.08/branches/cdbicompat_integration
___________________________________________________________________
Name: svk:merge
   - 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54599
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:4143
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
   + 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class:32260
9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBIx-Class-CDBICompat:54601
9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBIx-Class:31122
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/versioned_enhancements:4125
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:4143
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510

Modified: DBIx-Class/0.08/branches/cdbicompat_integration/lib/DBIx/Class/CDBICompat/Relationship.pm
===================================================================
--- DBIx-Class/0.08/branches/cdbicompat_integration/lib/DBIx/Class/CDBICompat/Relationship.pm	2008-03-07 16:05:35 UTC (rev 4146)
+++ DBIx-Class/0.08/branches/cdbicompat_integration/lib/DBIx/Class/CDBICompat/Relationship.pm	2008-03-07 16:08:41 UTC (rev 4147)
@@ -13,8 +13,6 @@
 
 Emulate the Class::DBI::Relationship object returned from C<meta_info()>.
 
-The C<args()> method does not return any useful result as it's not clear what it should contain nor if any of the information is applicable to DBIx::Class.
-
 =cut
 
 my %method2key = (
@@ -22,6 +20,7 @@
     class           => 'self_class',
     accessor        => 'accessor',
     foreign_class   => 'class',
+    args            => 'args',
 );
 
 sub new {
@@ -40,10 +39,4 @@
     *{$method} = $code;
 }
 
-sub args {
-    warn "args() is unlikely to ever work";
-    return undef;
-}
-
-
 1;

Modified: DBIx-Class/0.08/branches/cdbicompat_integration/lib/DBIx/Class/CDBICompat/Relationships.pm
===================================================================
--- DBIx-Class/0.08/branches/cdbicompat_integration/lib/DBIx/Class/CDBICompat/Relationships.pm	2008-03-07 16:05:35 UTC (rev 4146)
+++ DBIx-Class/0.08/branches/cdbicompat_integration/lib/DBIx/Class/CDBICompat/Relationships.pm	2008-03-07 16:08:41 UTC (rev 4147)
@@ -27,7 +27,7 @@
   $self->throw_exception( "No such column ${col}" ) unless $self->has_column($col);
   $self->ensure_class_loaded($f_class);
   
-  my $rel;
+  my $rel_info;
 
   if ($args{'inflate'} || $args{'deflate'}) { # Non-database has_a
     if (!ref $args{'inflate'}) {
@@ -40,18 +40,20 @@
     }
     $self->inflate_column($col, \%args);
     
-    $rel = {
+    $rel_info = {
         class => $f_class
     };
   }
   else {
     $self->belongs_to($col, $f_class);
-    $rel = $self->result_source_instance->relationship_info($col);
+    $rel_info = $self->result_source_instance->relationship_info($col);
   }
   
+  $rel_info->{args} = \%args;
+  
   $self->_extend_meta(
     has_a => $col,
-    $rel
+    $rel_info
   );
   
   return 1;
@@ -90,9 +92,14 @@
 
   $class->next::method($rel, $f_class, $f_key, $args);
 
+  my $rel_info = $class->result_source_instance->relationship_info($rel);
+  $args->{mapping}      = \@f_method;
+  $args->{foreign_key}  = $f_key;
+  $rel_info->{args} = $args;
+
   $class->_extend_meta(
     has_many => $rel,
-    $class->result_source_instance->relationship_info($rel)
+    $rel_info
   );
 
   if (@f_method) {
@@ -121,10 +128,13 @@
     $ret = $class->next::method($rel, $f_class, undef,
                                 { proxy => \@columns });
   }
-  
+
+  my $rel_info = $class->result_source_instance->relationship_info($rel);
+  $rel_info->{args}{import} = \@columns;
+
   $class->_extend_meta(
     might_have => $rel,
-    $class->result_source_instance->relationship_info($rel)
+    $rel_info
   );
   
   return $ret;

Modified: DBIx-Class/0.08/branches/cdbicompat_integration/t/cdbi-t/24-meta_info.t
===================================================================
--- DBIx-Class/0.08/branches/cdbicompat_integration/t/cdbi-t/24-meta_info.t	2008-03-07 16:05:35 UTC (rev 4146)
+++ DBIx-Class/0.08/branches/cdbicompat_integration/t/cdbi-t/24-meta_info.t	2008-03-07 16:08:41 UTC (rev 4147)
@@ -7,11 +7,16 @@
 package Temp::DBI;
 use base qw(DBIx::Class::CDBICompat);
 Temp::DBI->columns(All => qw(id date));
-Temp::DBI->has_a( date => 'Time::Piece', inflate => sub { 
-	Time::Piece->strptime(shift, "%Y-%m-%d") 
-});
 
+my $strptime_inflate = sub { 
+    Time::Piece->strptime(shift, "%Y-%m-%d") 
+};
+Temp::DBI->has_a(
+    date => 'Time::Piece',
+    inflate => $strptime_inflate
+);
 
+
 package Temp::Person;
 use base 'Temp::DBI';
 Temp::Person->table('people');
@@ -47,15 +52,11 @@
 
 {
     my $owners = Temp::Pet->meta_info( has_many => 'owners' );
-    warning_like {
-        local $TODO = 'args is unlikely to ever work';
 
-        is_deeply $owners->args, {
-            foreign_key     => 'pet',
-            mapping         => [],
-            order_by        => undef
-        };
-    } qr/^\Qargs() is unlikely to ever work/;
+    is_deeply $owners->args, {
+        foreign_key     => 'pet',
+        mapping         => [],
+    };
 }
 
 {
@@ -63,4 +64,5 @@
     is $date->class,            'Temp::DBI';
     is $date->foreign_class,    'Time::Piece';
     is $date->accessor,         'date';
+    is $date->args->{inflate},  $strptime_inflate;
 }




More information about the Bast-commits mailing list