Showing 4 changed files with 10 additions and 2 deletions
+1
Changes
... ...
@@ -1,4 +1,5 @@
1 1
 0.1648
2
+  add experimental DBIx::Custom::Model relation() attribute
2 3
   add experimental update_at(), delete_at(), select_at()
3 4
   add experimental setup_model()
4 5
   add experimental DBIx::Custom::Model columns attirbute
+1 -1
lib/DBIx/Custom.pm
... ...
@@ -607,7 +607,7 @@ sub select {
607 607
     push @sql, $swhere;
608 608
     
609 609
     # Relation
610
-    if ($relation) {
610
+    if (!$selection && $relation) {
611 611
         push @sql, $swhere eq '' ? 'where' : 'and';
612 612
         foreach my $rcolumn (keys %$relation) {
613 613
             push @sql, ("$rcolumn = " . $relation->{$rcolumn},  'and');
+2 -1
lib/DBIx/Custom/Model.pm
... ...
@@ -13,7 +13,8 @@ push @DBIx::Custom::CARP_NOT, __PACKAGE__;
13 13
 __PACKAGE__->attr(
14 14
     ['dbi', 'table'],
15 15
     columns => sub { [] },
16
-    primary_key => sub { [] }
16
+    primary_key => sub { [] },
17
+    relation => sub { {} }
17 18
 );
18 19
 
19 20
 our $AUTOLOAD;
+6
t/dbix-custom-core-sqlite.t
... ...
@@ -1500,3 +1500,9 @@ is($row->{key2}, 2);
1500 1500
 is($row->{key3}, 3);
1501 1501
 
1502 1502
 
1503
+test 'columns';
1504
+use MyDBI1;
1505
+$dbi = MyDBI1->connect($NEW_ARGS->{0});
1506
+$model = $dbi->model('book');
1507
+$model->relation({'book.id' => 'company.id'});
1508
+is_deeply($model->relation, {'book.id' => 'company.id'});