[Catalyst-commits] r8404 - in CatalystX-CRUD/CatalystX-CRUD/trunk:
. lib/CatalystX/CRUD/Model
karpet at dev.catalyst.perl.org
karpet at dev.catalyst.perl.org
Thu Sep 11 18:48:39 BST 2008
Author: karpet
Date: 2008-09-11 18:48:38 +0100 (Thu, 11 Sep 2008)
New Revision: 8404
Modified:
CatalystX-CRUD/CatalystX-CRUD/trunk/Changes
CatalystX-CRUD/CatalystX-CRUD/trunk/MANIFEST
CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Model/Utils.pm
Log:
0.30 release
Modified: CatalystX-CRUD/CatalystX-CRUD/trunk/Changes
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD/trunk/Changes 2008-09-11 17:47:12 UTC (rev 8403)
+++ CatalystX-CRUD/CatalystX-CRUD/trunk/Changes 2008-09-11 17:48:38 UTC (rev 8404)
@@ -139,7 +139,7 @@
* refactored REST controller to support related methods and provide better
HTTP status checks and responses.
-0.30 xxx
+0.30 11 Sept 2008
* fix uninit value warning in Controller
* change REST create() : Local to _rest_create() : Path('create') to make it easier for
create_form() to call create() in superclass.
Modified: CatalystX-CRUD/CatalystX-CRUD/trunk/MANIFEST
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD/trunk/MANIFEST 2008-09-11 17:47:12 UTC (rev 8403)
+++ CatalystX-CRUD/CatalystX-CRUD/trunk/MANIFEST 2008-09-11 17:48:38 UTC (rev 8404)
@@ -1,34 +1,37 @@
Changes
-MANIFEST
-Makefile.PL
-README
lib/CatalystX/CRUD.pm
+lib/CatalystX/CRUD/Controller.pm
+lib/CatalystX/CRUD/Iterator.pm
+lib/CatalystX/CRUD/Iterator/File.pm
lib/CatalystX/CRUD/Model.pm
+lib/CatalystX/CRUD/Model/File.pm
lib/CatalystX/CRUD/Model/Utils.pm
-lib/CatalystX/CRUD/Controller.pm
-lib/CatalystX/CRUD/REST.pm
+lib/CatalystX/CRUD/ModelAdapter.pm
+lib/CatalystX/CRUD/ModelAdapter/File.pm
lib/CatalystX/CRUD/Object.pm
-lib/CatalystX/CRUD/Iterator.pm
lib/CatalystX/CRUD/Object/File.pm
-lib/CatalystX/CRUD/Model/File.pm
-lib/CatalystX/CRUD/Iterator/File.pm
+lib/CatalystX/CRUD/REST.pm
+lib/CatalystX/CRUD/Results.pm
+lib/CatalystX/CRUD/Test/Controller.pm
+lib/CatalystX/CRUD/Test/Form.pm
lib/CatalystX/CRUD/Tutorial.pod
-lib/CatalystX/CRUD/Results.pm
+Makefile.PL
+MANIFEST
+README
t/00-load.t
-t/boilerplate.t
-t/pod-coverage.t
-t/pod.t
t/01-file.t
t/02-controller.t
t/03-rest.t
+t/04-query.t
+t/boilerplate.t
t/lib/MyApp.pm
-t/lib/MyApp/File.pm
-t/lib/MyApp/Model/File.pm
t/lib/MyApp/Controller/File.pm
+t/lib/MyApp/Controller/FileAdapter.pm
t/lib/MyApp/Controller/REST/File.pm
-lib/CatalystX/CRUD/ModelAdapter.pm
-lib/CatalystX/CRUD/ModelAdapter/File.pm
-lib/CatalystX/CRUD/Test/Controller.pm
-lib/CatalystX/CRUD/Test/Form.pm
-t/lib/MyApp/Controller/FileAdapter.pm
+t/lib/MyApp/Controller/Search.pm
+t/lib/MyApp/File.pm
t/lib/MyApp/Form.pm
+t/lib/MyApp/Model/File.pm
+t/lib/MyApp/Model/FileSearch.pm
+t/pod-coverage.t
+t/pod.t
Modified: CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Model/Utils.pm
===================================================================
--- CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Model/Utils.pm 2008-09-11 17:47:12 UTC (rev 8403)
+++ CatalystX-CRUD/CatalystX-CRUD/trunk/lib/CatalystX/CRUD/Model/Utils.pm 2008-09-11 17:48:38 UTC (rev 8404)
@@ -5,6 +5,7 @@
use Sort::SQL;
use Data::Pageset;
use Search::QueryParser::SQL;
+use Carp;
__PACKAGE__->mk_accessors(qw( use_ilike ne_sign ));
@@ -54,7 +55,7 @@
Returns a hashref suitable for passing to a SQL-oriented model.
-I<field_names> should be an array of valid form field names.
+I<field_names> should be an array of valid column names.
If false or missing, will call $c->controller->field_names().
The following reserved request param names are implemented:
@@ -137,10 +138,9 @@
}
sub make_sql_query {
- my $self = shift;
- my $c = $self->context;
- my $field_names
- = shift
+ my $self = shift;
+ my $c = $self->context;
+ my $field_names = shift
|| $c->req->params->{'cxc-query-fields'}
|| $c->controller->field_names($c)
|| $self->throw_error("field_names required");
@@ -153,13 +153,12 @@
$field_names = $c->req->params->{'cxc-query-fields'};
}
- my $p2q = $self->params_to_sql_query($field_names);
- my $params = $c->req->params;
- my $sp = Sort::SQL->string2array( $self->_which_sort($c) );
- my $s = join( ' ', map {%$_} @$sp );
- my $offset = $params->{'cxc-offset'} || $params->{'_offset'};
- my $page_size
- = $params->{'cxc-page_size'}
+ my $p2q = $self->params_to_sql_query($field_names);
+ my $params = $c->req->params;
+ my $sp = Sort::SQL->string2array( $self->_which_sort($c) );
+ my $s = join( ' ', map {%$_} @$sp );
+ my $offset = $params->{'cxc-offset'} || $params->{'_offset'};
+ my $page_size = $params->{'cxc-page_size'}
|| $params->{'_page_size'}
|| $c->controller->page_size
|| $self->page_size;
@@ -231,6 +230,9 @@
sub params_to_sql_query {
my ( $self, $field_names ) = @_;
+ croak "field_names ARRAY ref required"
+ unless defined $field_names
+ and ref($field_names) eq 'ARRAY';
my $c = $self->context;
my ( @sql, %pq );
my $ne = $self->ne_sign || '!=';
@@ -281,9 +283,9 @@
grep {s/\+/ /g} @v; # TODO URI + for space -- is this right?
$pq{$_} = \@v;
-
- next unless grep { m/\S/ } @v;
+ next unless grep {m/\S/} @v;
+
# we don't want to "double encode" $like because it will
# be re-parsed as a word not an op, so we have our a modified
# parser for per-field queries.
More information about the Catalyst-commits
mailing list