[Jifty-commit] r3729 - in Jifty-DBI/trunk: lib/Jifty/DBI
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Jul 28 20:27:36 EDT 2007
Author: jesse
Date: Sat Jul 28 20:27:31 2007
New Revision: 3729
Modified:
Jifty-DBI/trunk/ (props changed)
Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
Log:
r64901 at pinglin: jesse | 2007-07-28 18:29:15 -0500
* Added a find_all_rows method which works like 'unlimit' without the side effect of calling _clean_slate and zapping other metadata.
* Clarified unlimit's somewhat brutal nature.
- Thanks to Mikko Lipasti
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm Sat Jul 28 20:27:31 2007
@@ -423,7 +423,11 @@
=head2 _is_limited
If we've limited down this search, return true. Otherwise, return
-false.
+false.
+
+C<1> means "we have limits"
+C<-1> means "we should return all rows. We want no where clause"
+C<0> means "no limits have been applied yet.
=cut
@@ -450,7 +454,7 @@
my $query_string = $self->_build_joins . " ";
- if ( $self->_is_limited ) {
+ if ( $self->_is_limited == 1 ) {
$query_string .= $self->_where_clause . " ";
}
if ( $self->distinct_required ) {
@@ -614,7 +618,7 @@
my $query_string = $self->_build_joins . " ";
- if ( $self->_is_limited ) {
+ if ( $self->_is_limited == 1 ) {
$query_string .= $self->_where_clause . " ";
}
@@ -829,8 +833,11 @@
=head2 unlimit
-Clears all restrictions and causes this object to return all
-rows in the primary table.
+Unlimit clears all restrictions on this collection and resets
+it to a "default" pristine state. Note, in particular, that
+this means C<unlimit> will erase ordering and grouping
+metadata. To find all rows without resetting this metadata,
+use the C<find_all_rows> method.
=cut
@@ -841,6 +848,19 @@
$self->_is_limited(-1);
}
+=head2 find_all_rows
+
+C<find_all_rows> instructs this collection class to return all rows in
+the table. (It removes the WHERE clause from your query).
+
+=cut
+
+
+sub find_all_rows {
+ my $self = shift;
+ $self->_is_limited(-1);
+}
+
=head2 limit
Takes a hash of parameters with the following keys:
More information about the Jifty-commit
mailing list