[Catalyst-commits] r9509 - in
Catalyst-Controller-DBIC-API/1.001/trunk:
lib/Catalyst/Controller/DBIC lib/Catalyst/Controller/DBIC/API
t/lib/RestTest t/lib/RestTest/Controller/API/RPC
t/lib/RestTest/Schema t/lib/RestTest/Schema/Result
t/lib/RestTest/Schema/ResultSet t/rpc
lukes at dev.catalyst.perl.org
lukes at dev.catalyst.perl.org
Tue Mar 17 20:01:51 GMT 2009
Author: lukes
Date: 2009-03-17 20:01:51 +0000 (Tue, 17 Mar 2009)
New Revision: 9509
Added:
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Artist.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/CD.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/CD_to_Producer.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Producer.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Tag.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Track.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/ResultSet.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/ResultSet/
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/ResultSet/Track.pm
Removed:
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Artist.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/CD.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/CD_to_Producer.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Producer.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Tag.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Track.pm
Modified:
Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API.pm
Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API/Base.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Controller/API/RPC/TrackExposed.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/rpc/list_search_allows.t
Log:
basics of search_list_exposes
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 17:58:27 UTC (rev 9508)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API/Base.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -9,7 +9,7 @@
use JSON::Any;
__PACKAGE__->mk_accessors(qw(
- class create_requires update_requires update_allows $self->rs_stash_key create_allows list_count list_returns list_grouped_by list_ordered_by rs_stash_key object_stash_key setup_list_method
+ class create_requires update_requires update_allows $self->rs_stash_key create_allows list_count list_returns list_grouped_by list_search_exposes list_ordered_by rs_stash_key object_stash_key setup_list_method
));
__PACKAGE__->config(
@@ -20,6 +20,7 @@
update_allows => [],
list_returns => [],
list_grouped_by => [],
+ list_search_exposes => [],
list_ordered_by => [],
list_count => undef,
object_stash_key => 'object',
@@ -60,7 +61,7 @@
if (exists $req_params->{search}
&& ref $req_params->{search} eq 'HASH'
) {
- ($params, $join) = $self->_format_search({ params => $req_params->{search}, source => $source }) if ($req_params->{search});
+ ($params, $join) = $self->_format_search($c, { params => $req_params->{search}, source => $source }) if ($req_params->{search});
}
# assume json if search wasn't expanded by expand_hash
else {
@@ -80,31 +81,53 @@
}
sub _format_search {
- my ($self, $p) = @_;
+ my ($self, $c, $p) = @_;
my $params = $p->{params};
my $source = $p->{source};
my $base = $p->{base} || 'me';
my $join = {};
- my %relname_map = map { $_ => 1 } $source->relationships;
my %search_params;
+ # munge list_search_exposes into format that's easy to do with
+ my %valid = map { (ref $_) ? %{$_} : ($_ => 1) } @{$self->list_search_exposes};
+
+ # figure out the valid cols, defaulting to all cols if not specified
+ my @valid_cols = @{$self->list_search_exposes} ? (grep { $valid{$_} eq 1 } keys %valid) : $source->columns;
+
+ # figure out the valid rels, defaulting to all rels if not specified
+ my @valid_rels = @{$self->list_search_exposes} ? (grep { ref $valid{$_} } keys %valid) : $source->relationships;
+
+ my %_col_map = map { $_ => 1 } @valid_cols;
+ my %_rel_map = map { $_ => 1 } @valid_rels;
+
+ # validate search params
+ foreach my $key (keys %{$params}) {
+ # if req args is a ref, assume it refers to a rel
+ # XXX this is broken when attempting complex search
+ # XXX clauses on a col like { col => { LIKE => '%dfdsfs%' } }
+ # XXX when rel and col have the same name
+ if (ref $params->{$key} && $_rel_map{$key}) {
+ $self->push_error($c, { message => "${key} is not a valid relation" }) unless (exists $_rel_map{$key});
+ } else {
+ $self->push_error($c, { message => "${key} is not a valid column" }) unless exists $_col_map{$key};
+ }
+ }
+
# build up condition on root source
- foreach my $column ($source->columns) {
+ foreach my $column (@valid_cols) {
next unless (exists $params->{$column});
- # FIXME: we assume that if the value is a reference, then it can't
- # be a base condition. but this is not true in the case of { col => { LIKE => '%stuff%' }
- next if ($relname_map{$column} && ref $params->{$column});
+ next if ($_rel_map{$column} && ref $params->{$column});
$search_params{join('.', $base, $column)} = $params->{$column};
}
# build up related conditions
- foreach my $rel (keys %relname_map) {
+ foreach my $rel (@valid_rels) {
next if ($search_params{join('.', $base, $rel)}); # if it's a condition on the base source, then it's can't also be a rel
if (exists $params->{$rel}) {
my $rel_params;
- ($rel_params, $join->{$rel}) = $self->_format_search({ params => $params->{$rel}, source => $source->related_source($rel), base => $rel });
+ ($rel_params, $join->{$rel}) = $self->_format_search($c, { params => $params->{$rel}, source => $source->related_source($rel), base => $rel });
%search_params = ( %search_params, %{$rel_params} );
}
}
Modified: Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API.pm 2009-03-17 17:58:27 UTC (rev 9508)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/lib/Catalyst/Controller/DBIC/API.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -97,6 +97,12 @@
Arguments to pass to L<DBIx::Class::ResultSet/order_by> when performing search for L</list>.
+=head2 list_search_exposes
+
+Columns and related columns that are okay to search on. For example if only the position column and all cd columns were to be allowed
+
+ list_search_exposes => [qw/position/, { cd => ['*'] }]
+
=head2 list_count
Arguments to pass to L<DBIx::Class::ResultSet/rows> when performing search for L</list>.
@@ -122,7 +128,7 @@
__PACKAGE__->config(
...,
- setup_list_method => 'filter_search_params'
+ setup_lis_metthod => 'filter_search_params'
);
sub filter_search_params : Private {
Modified: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Controller/API/RPC/TrackExposed.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Controller/API/RPC/TrackExposed.pm 2009-03-17 17:58:27 UTC (rev 9508)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Controller/API/RPC/TrackExposed.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -10,7 +10,7 @@
class => 'RestTestDB::Track',
list_returns => [qw/position title/],
list_ordered_by => [qw/position/],
- list_search_allows => [qw/title/],
+ list_search_exposes => [qw/position/, { cd => ['*'] }],
);
1;
Deleted: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Artist.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Artist.pm 2009-03-17 17:58:27 UTC (rev 9508)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Artist.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -1,25 +0,0 @@
-package # hide from PAUSE
- RestTest::Schema::Artist;
-
-use base 'DBIx::Class::Core';
-
-__PACKAGE__->table('artist');
-__PACKAGE__->add_columns(
- 'artistid' => {
- data_type => 'integer',
- is_auto_increment => 1,
- },
- 'name' => {
- data_type => 'varchar',
- size => 100,
- is_nullable => 1,
- },
-);
-__PACKAGE__->set_primary_key('artistid');
-
-__PACKAGE__->has_many(
- cds => 'RestTest::Schema::CD', undef,
- { order_by => 'year' },
-);
-
-1;
Deleted: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/CD.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/CD.pm 2009-03-17 17:58:27 UTC (rev 9508)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/CD.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -1,44 +0,0 @@
-package # hide from PAUSE
- RestTest::Schema::CD;
-
-use base 'DBIx::Class::Core';
-
-__PACKAGE__->table('cd');
-__PACKAGE__->add_columns(
- 'cdid' => {
- data_type => 'integer',
- is_auto_increment => 1,
- },
- 'artist' => {
- data_type => 'integer',
- },
- 'title' => {
- data_type => 'varchar',
- size => 100,
- },
- 'year' => {
- data_type => 'varchar',
- size => 100,
- },
-);
-__PACKAGE__->set_primary_key('cdid');
-__PACKAGE__->add_unique_constraint([ qw/artist title/ ]);
-
-__PACKAGE__->belongs_to( artist => 'RestTest::Schema::Artist' );
-
-__PACKAGE__->has_many( tracks => 'RestTest::Schema::Track' );
-__PACKAGE__->has_many(
- tags => 'RestTest::Schema::Tag', undef,
- { order_by => 'tag' },
-);
-__PACKAGE__->has_many(
- cd_to_producer => 'RestTest::Schema::CD_to_Producer' => 'cd'
-);
-
-__PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' );
-__PACKAGE__->many_to_many(
- producers_sorted => cd_to_producer => 'producer',
- { order_by => 'producer.name' },
-);
-
-1;
Deleted: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/CD_to_Producer.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/CD_to_Producer.pm 2009-03-17 17:58:27 UTC (rev 9508)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/CD_to_Producer.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -1,23 +0,0 @@
-package # hide from PAUSE
- RestTest::Schema::CD_to_Producer;
-
-use base 'DBIx::Class::Core';
-
-__PACKAGE__->table('cd_to_producer');
-__PACKAGE__->add_columns(
- cd => { data_type => 'integer' },
- producer => { data_type => 'integer' },
-);
-__PACKAGE__->set_primary_key(qw/cd producer/);
-
-__PACKAGE__->belongs_to(
- 'cd', 'RestTest::Schema::CD',
- { 'foreign.cdid' => 'self.cd' }
-);
-
-__PACKAGE__->belongs_to(
- 'producer', 'RestTest::Schema::Producer',
- { 'foreign.producerid' => 'self.producer' }
-);
-
-1;
Deleted: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Producer.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Producer.pm 2009-03-17 17:58:27 UTC (rev 9508)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Producer.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -1,21 +0,0 @@
-package # hide from PAUSE
- RestTest::Schema::Producer;
-
-use base 'DBIx::Class::Core';
-
-__PACKAGE__->table('producer');
-__PACKAGE__->add_columns(
- 'producerid' => {
- data_type => 'integer',
- is_auto_increment => 1
- },
- 'name' => {
- data_type => 'varchar',
- size => 100,
- default_value => 'fred'
- },
-);
-__PACKAGE__->set_primary_key('producerid');
-__PACKAGE__->add_unique_constraint(prod_name => [ qw/name/ ]);
-
-1;
Added: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Artist.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Artist.pm (rev 0)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Artist.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -0,0 +1,25 @@
+package # hide from PAUSE
+ RestTest::Schema::Result::Artist;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('artist');
+__PACKAGE__->add_columns(
+ 'artistid' => {
+ data_type => 'integer',
+ is_auto_increment => 1,
+ },
+ 'name' => {
+ data_type => 'varchar',
+ size => 100,
+ is_nullable => 1,
+ },
+);
+__PACKAGE__->set_primary_key('artistid');
+
+__PACKAGE__->has_many(
+ cds => 'RestTest::Schema::Result::CD', undef,
+ { order_by => 'year' },
+);
+
+1;
Added: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/CD.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/CD.pm (rev 0)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/CD.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -0,0 +1,44 @@
+package # hide from PAUSE
+ RestTest::Schema::Result::CD;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('cd');
+__PACKAGE__->add_columns(
+ 'cdid' => {
+ data_type => 'integer',
+ is_auto_increment => 1,
+ },
+ 'artist' => {
+ data_type => 'integer',
+ },
+ 'title' => {
+ data_type => 'varchar',
+ size => 100,
+ },
+ 'year' => {
+ data_type => 'varchar',
+ size => 100,
+ },
+);
+__PACKAGE__->set_primary_key('cdid');
+__PACKAGE__->add_unique_constraint([ qw/artist title/ ]);
+
+__PACKAGE__->belongs_to( artist => 'RestTest::Schema::Result::Artist' );
+
+__PACKAGE__->has_many( tracks => 'RestTest::Schema::Result::Track' );
+__PACKAGE__->has_many(
+ tags => 'RestTest::Schema::Result::Tag', undef,
+ { order_by => 'tag' },
+);
+__PACKAGE__->has_many(
+ cd_to_producer => 'RestTest::Schema::Result::CD_to_Producer' => 'cd'
+);
+
+__PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' );
+__PACKAGE__->many_to_many(
+ producers_sorted => cd_to_producer => 'producer',
+ { order_by => 'producer.name' },
+);
+
+1;
Added: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/CD_to_Producer.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/CD_to_Producer.pm (rev 0)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/CD_to_Producer.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -0,0 +1,23 @@
+package # hide from PAUSE
+ RestTest::Schema::Result::CD_to_Producer;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('cd_to_producer');
+__PACKAGE__->add_columns(
+ cd => { data_type => 'integer' },
+ producer => { data_type => 'integer' },
+);
+__PACKAGE__->set_primary_key(qw/cd producer/);
+
+__PACKAGE__->belongs_to(
+ 'cd', 'RestTest::Schema::Result::CD',
+ { 'foreign.cdid' => 'self.cd' }
+);
+
+__PACKAGE__->belongs_to(
+ 'producer', 'RestTest::Schema::Result::Producer',
+ { 'foreign.producerid' => 'self.producer' }
+);
+
+1;
Added: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Producer.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Producer.pm (rev 0)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Producer.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -0,0 +1,21 @@
+package # hide from PAUSE
+ RestTest::Schema::Result::Producer;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('producer');
+__PACKAGE__->add_columns(
+ 'producerid' => {
+ data_type => 'integer',
+ is_auto_increment => 1
+ },
+ 'name' => {
+ data_type => 'varchar',
+ size => 100,
+ default_value => 'fred'
+ },
+);
+__PACKAGE__->set_primary_key('producerid');
+__PACKAGE__->add_unique_constraint(prod_name => [ qw/name/ ]);
+
+1;
Added: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Tag.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Tag.pm (rev 0)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Tag.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -0,0 +1,24 @@
+package # hide from PAUSE
+ RestTest::Schema::Result::Tag;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('tags');
+__PACKAGE__->add_columns(
+ 'tagid' => {
+ data_type => 'integer',
+ is_auto_increment => 1,
+ },
+ 'cd' => {
+ data_type => 'integer',
+ },
+ 'tag' => {
+ data_type => 'varchar',
+ size => 100,
+ },
+);
+__PACKAGE__->set_primary_key('tagid');
+
+__PACKAGE__->belongs_to( cd => 'RestTest::Schema::Result::CD' );
+
+1;
Added: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Track.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Track.pm (rev 0)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Result/Track.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -0,0 +1,36 @@
+package # hide from PAUSE
+ RestTest::Schema::Result::Track;
+
+use base 'DBIx::Class::Core';
+__PACKAGE__->table('track');
+__PACKAGE__->add_columns(
+ 'trackid' => {
+ data_type => 'integer',
+ is_auto_increment => 1,
+ },
+ 'cd' => {
+ data_type => 'integer',
+ },
+ 'position' => {
+ data_type => 'integer',
+ accessor => 'pos',
+ default_value => 0
+ },
+ 'title' => {
+ data_type => 'varchar',
+ size => 100,
+ },
+ last_updated_on => {
+ data_type => 'datetime',
+ accessor => 'updated_date',
+ is_nullable => 1
+ },
+);
+__PACKAGE__->set_primary_key('trackid');
+
+__PACKAGE__->add_unique_constraint([ qw/cd position/ ]);
+__PACKAGE__->add_unique_constraint([ qw/cd title/ ]);
+
+__PACKAGE__->belongs_to( cd => 'RestTest::Schema::Result::CD');
+
+1;
Added: 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 (rev 0)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/ResultSet/Track.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -0,0 +1,14 @@
+package # hide from PAUSE
+ RestTest::Schema::ResultSet::Track;
+
+use base 'RestTest::Schema::ResultSet';
+
+sub search {
+ my $self = shift;
+ my ($clause, $params) = @_;
+
+
+ my $rs = $self->SUPER::search(@_);
+}
+
+1;
Added: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/ResultSet.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/ResultSet.pm (rev 0)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/ResultSet.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -0,0 +1,6 @@
+package # hide from PAUSE
+ RestTest::Schema::ResultSet;
+
+use base 'DBIx::Class::ResultSet';
+
+1;
Deleted: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Tag.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Tag.pm 2009-03-17 17:58:27 UTC (rev 9508)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Tag.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -1,24 +0,0 @@
-package # hide from PAUSE
- RestTest::Schema::Tag;
-
-use base qw/DBIx::Class::Core/;
-
-__PACKAGE__->table('tags');
-__PACKAGE__->add_columns(
- 'tagid' => {
- data_type => 'integer',
- is_auto_increment => 1,
- },
- 'cd' => {
- data_type => 'integer',
- },
- 'tag' => {
- data_type => 'varchar',
- size => 100,
- },
-);
-__PACKAGE__->set_primary_key('tagid');
-
-__PACKAGE__->belongs_to( cd => 'RestTest::Schema::CD' );
-
-1;
Deleted: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Track.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Track.pm 2009-03-17 17:58:27 UTC (rev 9508)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema/Track.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -1,36 +0,0 @@
-package # hide from PAUSE
- RestTest::Schema::Track;
-
-use base 'DBIx::Class::Core';
-__PACKAGE__->table('track');
-__PACKAGE__->add_columns(
- 'trackid' => {
- data_type => 'integer',
- is_auto_increment => 1,
- },
- 'cd' => {
- data_type => 'integer',
- },
- 'position' => {
- data_type => 'integer',
- accessor => 'pos',
- default_value => 0
- },
- 'title' => {
- data_type => 'varchar',
- size => 100,
- },
- last_updated_on => {
- data_type => 'datetime',
- accessor => 'updated_date',
- is_nullable => 1
- },
-);
-__PACKAGE__->set_primary_key('trackid');
-
-__PACKAGE__->add_unique_constraint([ qw/cd position/ ]);
-__PACKAGE__->add_unique_constraint([ qw/cd title/ ]);
-
-__PACKAGE__->belongs_to( cd => 'RestTest::Schema::CD');
-
-1;
Modified: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema.pm 2009-03-17 17:58:27 UTC (rev 9508)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Schema.pm 2009-03-17 20:01:51 UTC (rev 9509)
@@ -5,6 +5,6 @@
no warnings qw/qw/;
-__PACKAGE__->load_classes(qw/Artist CD Track Tag Producer CD_to_Producer/);
+__PACKAGE__->load_namespaces;
1;
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 17:58:27 UTC (rev 9508)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/rpc/list_search_allows.t 2009-03-17 20:01:51 UTC (rev 9509)
@@ -31,7 +31,6 @@
my @expected_response = map { { $_->get_columns } } $base_rs->all;
my $response = JSON::Syck::Load( $mech->content);
- warn $mech->content;
is_deeply( { list => \@expected_response, success => 'true' }, $response, 'correct message returned' );
}
@@ -43,7 +42,6 @@
}, 'Accept' => 'text/x-json' );
$mech->request($req);
cmp_ok( $mech->status, '==', 200, 'search on position okay' );
-
my @expected_response = map { { $_->get_columns } } $base_rs->search({ position => 1 })->all;
my $response = JSON::Syck::Load( $mech->content);
is_deeply( { list => \@expected_response, success => 'true' }, $response, 'correct message returned' );
@@ -58,5 +56,7 @@
$mech->request($req);
cmp_ok( $mech->status, '==', 400, 'search on title not okay' );
- warn $mech->content;
+ 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' );
}
More information about the Catalyst-commits
mailing list