[Catalyst-commits] r10530 - in
CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk: .
lib/CatalystX/CRUD/ModelAdapter t
karpet at dev.catalyst.perl.org
karpet at dev.catalyst.perl.org
Sun Jun 14 02:39:37 GMT 2009
Author: karpet
Date: 2009-06-14 02:39:37 +0000 (Sun, 14 Jun 2009)
New Revision: 10530
Modified:
CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/Changes
CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/lib/CatalystX/CRUD/ModelAdapter/DBIC.pm
CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/t/01-dbic.t
Log:
release 0.09
Modified: CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/Changes
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/Changes 2009-06-13 18:29:52 UTC (rev 10529)
+++ CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/Changes 2009-06-14 02:39:37 UTC (rev 10530)
@@ -29,3 +29,7 @@
0.08 29 April 2009
* switch to MRO::Compat from Class::C3
+0.09 13 June 2009
+ * fix ORDER BY via cxc-order so that it actually works, including tests for multi-column sort.
+
+
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-06-13 18:29:52 UTC (rev 10529)
+++ CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/lib/CatalystX/CRUD/ModelAdapter/DBIC.pm 2009-06-14 02:39:37 UTC (rev 10530)
@@ -13,7 +13,7 @@
__PACKAGE__->mk_ro_accessors(qw( treat_like_int ));
-our $VERSION = '0.08';
+our $VERSION = '0.09';
=head1 NAME
@@ -245,13 +245,18 @@
}
# ORDER BY
- if ( exists $query->{order_by} ) {
- $opts{order_by} ||= $query->{order_by};
+ 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};
+ }
}
$query->{OPTS} = \%opts;
- #$c->log->debug( "query: " . dump $query ) if $c->debug;
+ $c->log->debug( "query: " . dump $query ) if $c->debug;
return $query;
}
Modified: CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/t/01-dbic.t
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/t/01-dbic.t 2009-06-13 18:29:52 UTC (rev 10529)
+++ CatalystX-CRUD/CatalystX-CRUD-ModelAdapter-DBIC/trunk/t/01-dbic.t 2009-06-14 02:39:37 UTC (rev 10530)
@@ -1,4 +1,4 @@
-use Test::More tests => 17;
+use Test::More tests => 21;
BEGIN {
use lib qw( ../../CatalystX-CRUD/trunk/lib t );
@@ -31,7 +31,11 @@
"GET view" );
#diag( $res->content );
-is( $res->content, '{ title => "Beat It", trackid => 1 }', "GET track 1" );
+is_deeply(
+ eval $res->content,
+ { title => "Beat It", trackid => 1 },
+ "GET track 1"
+);
# create
ok( $res = request(
@@ -46,11 +50,40 @@
);
#diag( $res->content );
-is( $res->content,
- '{ title => "Something New, Something Blue", trackid => 8 }',
+is_deeply(
+ eval $res->content,
+ { title => "Something New, Something Blue", trackid => 8 },
"POST new track"
);
+# GET new track
+ok( $res = request('/crud/8/view'), "get /crud/8/view" );
+is_deeply(
+ eval $res->content,
+ { title => "Something New, Something Blue", trackid => 8 },
+ "GET new track"
+);
+
+# multiple column search
+ok( $res = request(
+ POST(
+ '/crud/search',
+ [ 'cxc-query' => qq/me.trackid=7/,
+ 'cxc-order' => 'me.trackid ASC me.title DESC',
+ ]
+ )
+ ),
+ 'multi-column sort POST'
+);
+
+#warn $res->content;
+
+is_deeply(
+ eval $res->content,
+ { title => "The Way I Am", trackid => 7 },
+ 'multi-column sort'
+);
+
# test *_related features
ok( $res = request( POST( '/crud/3/cds/1/add', [] ), "/crud/3/tracks/1/add" )
@@ -69,3 +102,4 @@
is( $res->headers->{status}, 204, "POST returned OK" );
#dump $res;
+
More information about the Catalyst-commits
mailing list