[Catalyst-commits] r9511 - in
Catalyst-Controller-DBIC-API/1.001/trunk:
lib/Catalyst/Controller/DBIC/API t/rpc t/var
lukes at dev.catalyst.perl.org
lukes at dev.catalyst.perl.org
Wed Mar 18 10:15:36 GMT 2009
Author: lukes
Date: 2009-03-18 10:15:34 +0000 (Wed, 18 Mar 2009)
New Revision: 9511
Modified:
Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API/Base.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/rpc/list_search_allows.t
Catalyst-Controller-DBIC-API/1.001/trunk/t/var/DBIxClass.db
Log:
fixed alias issue
Modified: Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API/Base.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API/Base.pm 2009-03-17 20:31:10 UTC (rev 9510)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API/Base.pm 2009-03-18 10:15:34 UTC (rev 9511)
@@ -75,6 +75,10 @@
$self->push_error($c, { message => "list_page can only be used with list_count" });
}
$args->{select} = $req_params->{list_returns} || ((scalar(@{$self->list_returns})) ? $self->list_returns : undef);
+ if ($args->{select}) {
+ # make sure all columns have an alias to avoid ambiguous issues
+ $args->{select} = [map { ($_ =~ m/\./) ? $_ : "me.$_" } (ref $args->{select}) ? @{$args->{select}} : $args->{select}];
+ }
$args->{join} = $join;
return [$params, $args];
@@ -250,7 +254,7 @@
unless (defined $value) {
$self->push_error($c, { message => "No value supplied for ${key} and no default" });
}
- }
+ }
}
# TODO: do automatic col type checking here
Modified: Catalyst-Controller-DBIC-API/1.001/trunk/t/rpc/list_search_allows.t
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/rpc/list_search_allows.t 2009-03-17 20:31:10 UTC (rev 9510)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/rpc/list_search_allows.t 2009-03-18 10:15:34 UTC (rev 9511)
@@ -19,7 +19,7 @@
ok(my $schema = DBICTest->init_schema(), 'got schema');
my $track_list_url = "$base/api/rpc/track_exposed/list";
-my $base_rs = $schema->resultset('Track')->search({}, { select => [qw/title position/], order_by => 'position' });
+my $base_rs = $schema->resultset('Track')->search({}, { select => [qw/me.title me.position/], order_by => 'position' });
# test open request
{
@@ -60,3 +60,31 @@
my $response = JSON::Syck::Load( $mech->content);
is_deeply({ success => 'false',messages => ["title is not a valid column"]}, $response, 'correct message returned' );
}
+
+{
+ my $uri = URI->new( $track_list_url );
+ $uri->query_form({ 'search.title' => 'Stripy' });
+ my $req = GET( $uri, {
+
+ }, 'Accept' => 'text/x-json' );
+ $mech->request($req);
+ cmp_ok( $mech->status, '==', 400, 'search on title not okay' );
+
+ my $expected_response = map { { $_->get_columns } } $base_rs->search({ position => 1 })->all;
+ my $response = JSON::Syck::Load( $mech->content);
+ is_deeply({ success => 'false',messages => ["title is not a valid column"]}, $response, 'correct message returned' );
+}
+
+{
+ my $uri = URI->new( $track_list_url );
+ $uri->query_form({ 'search.cd.title' => 'Spoonful of bees', 'search.cd.year' => '1999' });
+ my $req = GET( $uri, {
+
+ }, 'Accept' => 'text/x-json' );
+ $mech->request($req);
+ cmp_ok( $mech->status, '==', 200, 'search on various cd fields okay' );
+ warn $mech->content;
+ my $expected_response = map { { $_->get_columns } } $base_rs->search({ 'cd.year' => '1999', 'cd.title' => 'Spoonful of bees' }, { join => 'cd' })->all;
+ my $response = JSON::Syck::Load( $mech->content);
+ is_deeply({ success => 'false',messages => ["title is not a valid column"]}, $response, 'correct message returned' );
+}
Modified: Catalyst-Controller-DBIC-API/1.001/trunk/t/var/DBIxClass.db
===================================================================
(Binary files differ)
More information about the Catalyst-commits
mailing list