[Catalyst-commits] r11532 - in
CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk: .
lib/CatalystX/CRUD/ModelAdapter
karpet at dev.catalyst.perl.org
karpet at dev.catalyst.perl.org
Wed Oct 14 21:35:22 GMT 2009
Author: karpet
Date: 2009-10-14 21:35:21 +0000 (Wed, 14 Oct 2009)
New Revision: 11532
Modified:
CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/Changes
CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/lib/CatalystX/CRUD/ModelAdapter/DBIC.pm
Log:
add a TODO item, working around the problem for now
Modified: CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/Changes
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/Changes 2009-10-14 18:58:23 UTC (rev 11531)
+++ CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/Changes 2009-10-14 21:35:21 UTC (rev 11532)
@@ -35,4 +35,5 @@
0.10 14 July 2009
* fix tests so that (a) sql is complete and (b) skip is sqlite3 cmd tool not found
-
+0.11 xxx
+ * TODO: fix order_by logic to only prefix 'me.' when column actually exists
Modified: CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/lib/CatalystX/CRUD/ModelAdapter/DBIC.pm
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/lib/CatalystX/CRUD/ModelAdapter/DBIC.pm 2009-10-14 18:58:23 UTC (rev 11531)
+++ CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/lib/CatalystX/CRUD/ModelAdapter/DBIC.pm 2009-10-14 21:35:21 UTC (rev 11532)
@@ -10,10 +10,11 @@
use Scalar::Util qw( weaken );
use Carp;
use Data::Dump qw( dump );
+use Sort::SQL;
__PACKAGE__->mk_ro_accessors(qw( treat_like_int ));
-our $VERSION = '0.10';
+our $VERSION = '0.11';
=head1 NAME
@@ -245,15 +246,28 @@
}
# ORDER BY
+ dump $c->action;
+ dump $field_names;
if ( exists $query->{sort_by} ) {
$opts{order_by} ||= $query->{sort_by};
# default is to sort by PK, which might not be prefixed.
- if ( $opts{order_by} !~ m/\./ ) {
- $opts{order_by} = 'me.' . $opts{order_by};
+ my $ss = Sort::SQL->parse($opts{order_by});
+ dump $ss;
+ my @order_by;
+ for my $clause (@$ss) {
+ if ($clause->[0] !~ m/\./) {
+ my $name = "me." . $clause->[0];
+ if (grep {$_ eq $name} @$field_names) {
+ $clause->[0] = $name;
+ }
+ next; # TODO skip if not qualified. see how rdbo addresses m2m issue.
+ }
+ push @order_by, join(' ', @$clause);
}
+ $opts{order_by} = join(', ', @order_by);
}
-
+ dump \%opts;
$query->{OPTS} = \%opts;
$c->log->debug( "query: " . dump $query ) if $c->debug;
More information about the Catalyst-commits
mailing list