[Catalyst-commits] r14518 - CatalystX-CRUD/CatalystX-CRUD-Model-RDBO/trunk/lib/CatalystX/CRUD/Model
karpet at dev.catalyst.perl.org
karpet at dev.catalyst.perl.org
Sat May 10 20:28:49 GMT 2014
Author: karpet
Date: 2014-05-10 20:28:49 +0000 (Sat, 10 May 2014)
New Revision: 14518
Modified:
CatalystX-CRUD/CatalystX-CRUD-Model-RDBO/trunk/lib/CatalystX/CRUD/Model/RDBO.pm
Log:
small refactor for $c
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 2014-05-10 20:20:54 UTC (rev 14517)
+++ CatalystX-CRUD/CatalystX-CRUD-Model-RDBO/trunk/lib/CatalystX/CRUD/Model/RDBO.pm 2014-05-10 20:28:49 UTC (rev 14518)
@@ -289,6 +289,7 @@
sub _related_query {
my ( $self, $obj, $rel_name ) = @_;
+ my $c = $self->context;
my $relationship = $self->has_relationship( $obj, $rel_name )
or $self->throw_error("no relationship for $rel_name");
@@ -297,7 +298,7 @@
'Rose::DB::Object::Metadata::Relationship::ManyToMany')
)
{
- $self->context->req->params->{'cxc-m2m'} = 1;
+ $c->req->params->{'cxc-m2m'} = 1;
}
my $query = $self->make_query;
my @arg;
@@ -309,15 +310,16 @@
# only want to include the sort_by if it makes sense.
if ( $_ eq 'sort_by' ) {
- # can't reliably predict table prefixes in a m2m
- if ( $self->context->req->params->{'cxc-m2m'} ) {
+ # can't reliably predict table prefixes in a m2m.
+ # NOTE this effectively ignores whatever make_query did.
+ if ( $c->req->params->{'cxc-m2m'} ) {
next;
}
# if sort_by was derived from PK, it may refer to a parent table,
# not the related table. So skip it unless it was explicit.
- if ( !$self->context->req->params->{'cxc-order'}
- and !$self->context->req->params->{'cxc-sort'} )
+ if ( !$c->req->params->{'cxc-order'}
+ and !$c->req->params->{'cxc-sort'} )
{
next;
}
@@ -337,7 +339,8 @@
);
}
- #warn dump \@arg;
+ $c->log->debug( "related_query: " . dump \@arg ) if $c->debug;
+
return @arg;
}
More information about the Catalyst-commits
mailing list