[Catalyst-commits] r9513 - in
Catalyst-Controller-DBIC-API/1.001/trunk:
lib/Catalyst/Controller/DBIC/API
t/lib/RestTest/Schema/ResultSet t/rpc t/var
lukes at dev.catalyst.perl.org
lukes at dev.catalyst.perl.org
Wed Mar 18 11:10:19 GMT 2009
Author: lukes
Date: 2009-03-18 11:10:19 +0000 (Wed, 18 Mar 2009)
New Revision: 9513
Modified:
Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API/Base.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/ResultSet/Track.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:
list_search_allows working with custom col
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-18 11:02:24 UTC (rev 9512)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API/Base.pm 2009-03-18 11:10:19 UTC (rev 9513)
@@ -108,6 +108,7 @@
my %_col_map = map { $_ => 1 } @valid_cols;
my %_rel_map = map { $_ => 1 } @valid_rels;
+ my %_source_col_map = map { $_ => 1 } $source->columns;
# validate search params
foreach my $key (keys %{$params}) {
@@ -128,7 +129,11 @@
next unless (exists $params->{$column});
next if ($_rel_map{$column} && ref $params->{$column});
- $search_params{join('.', $base, $column)} = $params->{$column};
+ if ($_source_col_map{$column}) {
+ $search_params{join('.', $base, $column)} = $params->{$column};
+ } else {
+ $search_params{$column} = $params->{$column};
+ }
}
# build up related conditions
Modified: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/ResultSet/Track.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/ResultSet/Track.pm 2009-03-18 11:02:24 UTC (rev 9512)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/ResultSet/Track.pm 2009-03-18 11:10:19 UTC (rev 9513)
@@ -7,7 +7,10 @@
my $self = shift;
my ($clause, $params) = @_;
- use Data::Dumper; warn Dumper($params);
+ # test custom attrs
+ if (my $pretend = delete $clause->{pretend}) {
+ $clause->{'cd.year'} = $pretend;
+ }
my $rs = $self->SUPER::search(@_);
}
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-18 11:02:24 UTC (rev 9512)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/rpc/list_search_allows.t 2009-03-18 11:10:19 UTC (rev 9513)
@@ -107,7 +107,7 @@
}, 'Accept' => 'text/x-json' );
$mech->request($req);
- cmp_ok( $mech->status, '==', 200, 'search on various cd fields okay' );
+ cmp_ok( $mech->status, '==', 200, 'search with custom col okay' );
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 => 'true',list => \@expected_response }, $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