[Catalyst-commits] r8332 -
CatalystX-CRUD/CatalystX-CRUD-Model-RDBO/trunk/lib/CatalystX/CRUD/Model
karpet at dev.catalyst.perl.org
karpet at dev.catalyst.perl.org
Tue Sep 2 16:44:17 BST 2008
Author: karpet
Date: 2008-09-02 16:44:17 +0100 (Tue, 02 Sep 2008)
New Revision: 8332
Modified:
CatalystX-CRUD/CatalystX-CRUD-Model-RDBO/trunk/lib/CatalystX/CRUD/Model/RDBO.pm
Log:
fix query for release methods
Modified: CatalystX-CRUD/CatalystX-CRUD-Model-RDBO/trunk/lib/CatalystX/CRUD/Model/RDBO.pm
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD-Model-RDBO/trunk/lib/CatalystX/CRUD/Model/RDBO.pm 2008-09-02 12:28:33 UTC (rev 8331)
+++ CatalystX-CRUD/CatalystX-CRUD-Model-RDBO/trunk/lib/CatalystX/CRUD/Model/RDBO.pm 2008-09-02 15:44:17 UTC (rev 8332)
@@ -273,7 +273,17 @@
=cut
sub _related_query {
- my ($self) = @_;
+ my ( $self, $obj, $rel_name ) = @_;
+ my $relationship = $self->has_relationship( $obj, $rel_name )
+ or $self->throw_error("no relationship for $rel_name");
+
+ # set the param so sort is correctly mangled in make_query()
+ if ($relationship->isa(
+ 'Rose::DB::Object::Metadata::Relationship::ManyToMany')
+ )
+ {
+ $self->context->req->params->{'cxc-m2m'} = 1;
+ }
my $query = $self->make_query;
my @arg;
for (qw( limit offset sort_by )) {
@@ -286,19 +296,19 @@
sub search_related {
my ( $self, $obj, $rel ) = @_;
- return $obj->$rel( $self->_related_query );
+ return $obj->$rel( $self->_related_query( $obj, $rel ) );
}
sub iterator_related {
my ( $self, $obj, $rel ) = @_;
my $method = $rel . '_iterator';
- return $obj->$method( $self->_related_query );
+ return $obj->$method( $self->_related_query( $obj, $rel ) );
}
sub count_related {
my ( $self, $obj, $rel ) = @_;
my $method = $rel . '_count';
- return $obj->$method( $self->_related_query );
+ return $obj->$method( $self->_related_query( $obj, $rel ) );
}
=head2 add_related( I<obj>, I<rel_name>, I<foreign_value> )
@@ -461,7 +471,7 @@
}
}
- #carp dump $q;
+ $c->log->debug( 'make_query: ' . dump $q ) if $c->debug;
return $q;
}
More information about the Catalyst-commits
mailing list