[Rt-commit] r3536 - in Jifty-DBI/trunk: . lib/Jifty lib/Jifty/DBI lib/Jifty/DBI/Handle lib/Jifty/DBI/Record t

alexmv at bestpractical.com alexmv at bestpractical.com
Mon Jul 25 21:36:24 EDT 2005


Author: alexmv
Date: Mon Jul 25 21:36:24 2005
New Revision: 3536

Added:
   Jifty-DBI/trunk/lib/Jifty/DBI.pm
Modified:
   Jifty-DBI/trunk/   (props changed)
   Jifty-DBI/trunk/Changes
   Jifty-DBI/trunk/README
   Jifty-DBI/trunk/lib/Jifty/DBI/Collection.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle/ODBC.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Sybase.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Handle/mysql.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm
   Jifty-DBI/trunk/lib/Jifty/DBI/Union.pm
   Jifty-DBI/trunk/t/01records.t
   Jifty-DBI/trunk/t/01searches.t
   Jifty-DBI/trunk/t/11schema_records.t
Log:
 r5394 at zoq-fot-pik:  chmrr | 2005-07-25 21:36:09 -0400
  * Fix Changes file to refer to DBIx::SearchBuilder, and the fork
  * perltidy, doc fixes, remove deprecated methods in Collection
  * More doc and capitalization fixes


Modified: Jifty-DBI/trunk/Changes
==============================================================================
--- Jifty-DBI/trunk/Changes	(original)
+++ Jifty-DBI/trunk/Changes	Mon Jul 25 21:36:24 2005
@@ -1,13 +1,15 @@
 Revision history for Perl extension Jifty::DBI.
 
+==> Forked into Jifty::DBI
+
 *  Removed {{{ and  }}} fold markers. Patch from Ruslan
 
 1.30_03 Thu Jun  9 01:35:49 EDT 2005
 * Significant new tests from Ruslan Zakirov and Dave Glasser
 
-* You no longer need to explicitly bless a Jifty::DBI::Handle subclass 
+* You no longer need to explicitly bless a DBIx::SearchBuilder::Handle subclass 
   
-* Start of a major overhaul of the subclass API for Jifty::DBI::Record objects.
+* Start of a major overhaul of the subclass API for DBIx::SearchBuilder::Record objects.
   A new "schema" method will define the data in _ClassAccessible and also generate database
   schema using DBIx::DBSchema. 
 
@@ -126,9 +128,9 @@
       into the database.
     - Started adding lowercase method name aliases
     - Minor refactoring of 'id' method for a stupid, tiny perf improvement
-    - Refactoring of Jifty::DBI::Record::Cachable for performance
+    - Refactoring of DBIx::SearchBuilder::Record::Cachable for performance
       improvement
-    - Added a FlushCache method to Jifty::DBI::Record::Cachable.
+    - Added a FlushCache method to DBIx::SearchBuilder::Record::Cachable.
     - Started to flesh out a...test suite
     - SearchBuilder now truncates strings before inserting them into character
       types in the database as mysql generally does. Additionally, it truncates
@@ -157,7 +159,7 @@
 
 1.10_05
 
-    -   Reworked the _Accessible mechanism in Jifty::DBI::Record to
+    -   Reworked the _Accessible mechanism in DBIx::SearchBuilder::Record to
         remove a horribly crufty old caching mechanism that created a copy
         of the accessible hash for each and every object instantiated,
         sometimes quite slowly.
@@ -183,7 +185,7 @@
 1.10_02 Thu Aug 26 13:31:13 EDT 2004
 
 1.10_01 Thu Aug 26 00:08:31 EDT 2004
-        - Reimplemented Jifty::DBI:::Record::Cachable
+        - Reimplemented DBIx::SearchBuilder:::Record::Cachable
           to use Cache::Simple::TimedExpiry. This should make it faster and more
           memory efficient.
 
@@ -343,7 +345,7 @@
         - No longer attempt to cache (and fail) objects that haven't been database-loaded
 
 0.76 Dec 30 2002
-        - Extra checking for cache misses in Jifty::DBI::Record::Cachable
+        - Extra checking for cache misses in DBIx::SearchBuilder::Record::Cachable
         - The start of support for checking database version, so that we can do
           version-specific SQL
         - A patch from Autrijus Tang that allows utf-8 safe searching
@@ -382,7 +384,7 @@
 
 
 0.30  Fri May 11 14:59:17 EDT 2001
-        - Added Jifty::DBI::Record::Cachable from <mhat at netlag.com>
+        - Added DBIx::SearchBuilder::Record::Cachable from <mhat at netlag.com>
         - Changed SearchBuilder->Count to do the right thing if no
           query has been performed
         - No longer specify a sort order if no sort order was specified ;)

Modified: Jifty-DBI/trunk/README
==============================================================================
--- Jifty-DBI/trunk/README	(original)
+++ Jifty-DBI/trunk/README	Mon Jul 25 21:36:24 2005
@@ -13,7 +13,7 @@
     # make install
 
 TESTING
-    In order to test most of the features of "Jifty::DBI::Collection", you need
+    In order to test most of the features of Jifty::DBI, you need
     to provide "make test" with a test database. For each DBI driver that
     you would like to test, set the environment variables "SB_TEST_FOO",
     "SB_TEST_FOO_USER", and "SB_TEST_FOO_PASS" to a database name, database

Added: Jifty-DBI/trunk/lib/Jifty/DBI.pm
==============================================================================
--- (empty file)
+++ Jifty-DBI/trunk/lib/Jifty/DBI.pm	Mon Jul 25 21:36:24 2005
@@ -0,0 +1,9 @@
+package Jifty::DBI;
+
+use Jifty::DBI::Handle;
+use Jifty::DBI::Record;
+use Jifty::DBI::Collection;
+
+our $VERSION = 0.01;
+
+1;

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	Mon Jul 25 21:36:24 2005
@@ -1,4 +1,3 @@
-
 package Jifty::DBI::Collection;
 
 use strict;
@@ -6,7 +5,8 @@
 
 =head1 NAME
 
-Jifty::DBI::Collection - Encapsulate SQL queries and rows in simple perl objects
+Jifty::DBI::Collection - Encapsulate SQL queries and rows in simple
+perl objects
 
 =head1 SYNOPSIS
 
@@ -43,40 +43,37 @@
 
 =head1 DESCRIPTION
 
-This module provides an object-oriented mechanism for retrieving and updating data in a DBI-accesible database. 
+This module provides an object-oriented mechanism for retrieving and
+updating data in a DBI-accesible database.
 
-In order to use this module, you should create a subclass of C<Jifty::DBI::Collection> and a 
-subclass of C<Jifty::DBI::Record> for each table that you wish to access.  (See
-the documentation of C<Jifty::DBI::Record> for more information on subclassing it.)
-
-Your C<Jifty::DBI::Collection> subclass must override C<new_item>, and probably should override
-at least C<_init> also; at the very least, C<_init> should probably call C<_handle> and C<_Table>
-to set the database handle (a C<Jifty::DBI::Handle> object) and table name for the class.
-You can try to override just about every other method here, as long as you think you know what you
-are doing.
-
-=head1 METHOD NAMING
- 
-Each method has a lower case alias; '_' is used to separate words.
-For example, the method C<redo_search> has the alias C<redo_search>.
+In order to use this module, you should create a subclass of
+L<Jifty::DBI::Collection> and a subclass of L<Jifty::DBI::Record> for
+each table that you wish to access.  (See the documentation of
+L<Jifty::DBI::Record> for more information on subclassing it.)
+
+Your L<Jifty::DBI::Collection> subclass must override L</new_item>,
+and probably should override at least L</_init> also; at the very
+least, L</_init> should probably call L</_handle> and L</_table> to
+set the database handle (a L<Jifty::DBI::Handle> object) and table
+name for the class -- see the L</SYNOPSIS> for an example.
 
 =head1 METHODS
 
-=cut
-
-
 =head2 new
 
-Creates a new SearchBuilder object and immediately calls C<_init> with the same parameters
-that were passed to C<new>.  If you haven't overridden C<_init> in your subclass, this means
-that you should pass in a C<Jifty::DBI::Handle> (or one of its subclasses) like this:
+Creates a new L<Jifty::DBI::Collection> object and immediately calls
+L</_init> with the same parameters that were passed to L</new>.  If
+you haven't overridden L<_init> in your subclass, this means that you
+should pass in a L<Jifty::DBI::Handle> (or one of its subclasses) like
+this:
 
    my $sb = My::Jifty::DBI::Subclass->new( handle => $handle );
 
-However, if your subclass overrides _init you do not need to take a handle argument, as long
-as your subclass returns an appropriate handle object from the C<_handle> method.  This is
-useful if you want all of your SearchBuilder objects to use a shared global handle and don't want
-to have to explicitly pass it in each time, for example.
+However, if your subclass overrides L</_init> you do not need to take
+a handle argument, as long as your subclass takes care of calling the
+L</_handle> method somehow.  This is useful if you want all of your
+L<Jifty::DBI> objects to use a shared global handle and don't want to
+have to explicitly pass it in each time, for example.
 
 =cut
 
@@ -89,33 +86,31 @@
     return ($self);
 }
 
-
-
 =head2 _init
 
-This method is called by C<new> with whatever arguments were passed to C<new>.  
-By default, it takes a C<Jifty::DBI::Handle> object as a C<handle>
-argument, although this is not necessary if your subclass overrides C<_handle>.
+This method is called by L<new> with whatever arguments were passed to
+L</new>.  By default, it takes a C<Jifty::DBI::Handle> object as a
+C<handle> argument and calls L</_handle> with that.
 
 =cut
 
 sub _init {
     my $self = shift;
-    my %args = ( handle => undef,
-                 @_ );
+    my %args = (
+        handle => undef,
+        @_
+    );
     $self->_handle( $args{'handle'} );
 
     $self->clean_slate();
 }
 
-
-
 =head2 clean_slate
 
-This completely erases all the data in the SearchBuilder object. It's
-useful if a subclass is doing funky stuff to keep track of a search and
-wants to reset the SearchBuilder data without losing its own data;
-it's probably cleaner to accomplish that in a different way, though.
+This completely erases all the data in the object. It's useful if a
+subclass is doing funky stuff to keep track of a search and wants to
+reset the object's data without losing its own data; it's probably
+cleaner to accomplish that in a different way, though.
 
 =cut
 
@@ -135,26 +130,24 @@
     @{ $self->{'aliases'} } = ();
 
     delete $self->{$_} for qw(
-	items
-	left_joins
-	raw_rows
-	count_all
-	subclauses
-	restrictions
-	_open_parens
-	_close_parens
+        items
+        left_joins
+        raw_rows
+        count_all
+        subclauses
+        restrictions
+        _open_parens
+        _close_parens
     );
 
-    #we have no limit statements. DoSearch won't work.
+    # Force ourselves to have no limit statements. do_search won't
+    # work.
     $self->_is_limited(0);
-
 }
 
+=head2 _handle [DBH]
 
-
-=head2 _handle  [DBH]
-
-Get or set this object's Jifty::DBI::Handle object.
+Get or set this object's L<Jifty::DBI::Handle> object.
 
 =cut
 
@@ -166,13 +159,11 @@
     return ( $self->{'DBIxhandle'} );
 }
 
-
-    
 =head2 _do_search
 
-This internal private method actually executes the search on the database;
-it is called automatically the first time that you actually need results
-(such as a call to C<Next>).
+This internal private method actually executes the search on the
+database; it is called automatically the first time that you actually
+need results (such as a call to L</next>).
 
 =cut
 
@@ -188,9 +179,9 @@
     return 0 unless $records;
 
     while ( my $row = $records->fetchrow_hashref() ) {
-	my $item = $self->new_item();
-	$item->load_from_hash($row);
-	$self->add_record($item);
+        my $item = $self->new_item();
+        $item->load_from_hash($row);
+        $self->add_record($item);
     }
     return $self->_record_count if $records->err;
 
@@ -199,7 +190,6 @@
     return $self->_record_count;
 }
 
-
 =head2 add_record RECORD
 
 Adds a record object to this collection.
@@ -207,15 +197,15 @@
 =cut
 
 sub add_record {
-    my $self = shift;
+    my $self   = shift;
     my $record = shift;
-    push @{$self->{'items'}}, $record;
+    push @{ $self->{'items'} }, $record;
 }
 
 =head2 _record_count
 
-This private internal method returns the number of Record objects saved
-as a result of the last query.
+This private internal method returns the number of
+L<Jifty::DBI::Record> objects saved as a result of the last query.
 
 =cut
 
@@ -225,16 +215,13 @@
     return scalar @{ $self->{'items'} };
 }
 
-
-
 =head2 _do_count
 
-This internal private method actually executes a counting operation on the database;
-it is used by C<Count> and C<count_all>.
+This internal private method actually executes a counting operation on
+the database; it is used by L</count> and L</count_all>.
 
 =cut
 
-
 sub _do_count {
     my $self = shift;
     my $all  = shift || 0;
@@ -251,91 +238,83 @@
     return ( $row[0] );
 }
 
-
-
 =head2 _apply_limits STATEMENTREF
 
-This routine takes a reference to a scalar containing an SQL statement. 
-It massages the statement to limit the returned rows to only C<< $self->rows_per_page >>
-rows, skipping C<< $self->first_row >> rows.  (That is, if rows are numbered
-starting from 0, row number C<< $self->first_row >> will be the first row returned.)
-Note that it probably makes no sense to set these variables unless you are also
-enforcing an ordering on the rows (with C<order_by_cols>, say).
+This routine takes a reference to a scalar containing an SQL
+statement.  It massages the statement to limit the returned rows to
+only C<< $self->rows_per_page >> rows, skipping C<< $self->first_row >>
+rows.  (That is, if rows are numbered starting from 0, row number
+C<< $self->first_row >> will be the first row returned.)  Note that it
+probably makes no sense to set these variables unless you are also
+enforcing an ordering on the rows (with L</order_by_cols>, say).
 
 =cut
 
-
 sub _apply_limits {
-    my $self = shift;
+    my $self         = shift;
     my $statementref = shift;
-    $self->_handle->apply_limits($statementref, $self->rows_per_page, $self->first_row);
-    $$statementref =~ s/main\.\*/join(', ', @{$self->{columns}})/eg
-	    if $self->{columns} and @{$self->{columns}};
+    $self->_handle->apply_limits( $statementref, $self->rows_per_page,
+        $self->first_row );
+    $$statementref =~ s/main\.\*/CORE::join(', ', @{$self->{columns}})/eg
+        if $self->{columns}
+        and @{ $self->{columns} };
 }
 
-
 =head2 _distinct_query STATEMENTREF
 
-This routine takes a reference to a scalar containing an SQL statement. 
-It massages the statement to ensure a distinct result set is returned.
-
+This routine takes a reference to a scalar containing an SQL
+statement.  It massages the statement to ensure a distinct result set
+is returned.
 
 =cut
 
 sub _distinct_query {
-    my $self = shift;
+    my $self         = shift;
     my $statementref = shift;
-    my $table = shift;
+    my $table        = shift;
 
     # XXX - Postgres gets unhappy with distinct and order_by aliases
-    if (exists $self->{'order_clause'} && $self->{'order_clause'} =~ /(?<!main)\./) {
+    if ( exists $self->{'order_clause'}
+        && $self->{'order_clause'} =~ /(?<!main)\./ )
+    {
         $$statementref = "SELECT main.* FROM $$statementref";
-    }
-    else {
-	$self->_handle->distinct_query($statementref, $table)
+    } else {
+        $self->_handle->distinct_query( $statementref, $table );
     }
 }
 
-
-
 =head2 _build_joins
 
 Build up all of the joins we need to perform this query.
 
 =cut
 
-
 sub _build_joins {
     my $self = shift;
 
-        return ( $self->_handle->_build_joins($self) );
+    return ( $self->_handle->_build_joins($self) );
 
 }
 
-
 =head2 _is_joined 
 
-Returns true if this SearchBuilder will be joining multiple tables together.
+Returns true if this collection will be joining multiple tables
+together.
 
 =cut
 
 sub _is_joined {
     my $self = shift;
-    if (keys(%{$self->{'left_joins'}})) {
-        return(1);
+    if ( keys( %{ $self->{'left_joins'} } ) ) {
+        return (1);
     } else {
-        return(@{$self->{'aliases'}});
+        return ( @{ $self->{'aliases'} } );
     }
 
 }
 
-
-
-
-# LIMIT clauses are used for restricting ourselves to subsets of the search.
-
-
-
+# LIMIT clauses are used for restricting ourselves to subsets of the
+# search.
 sub _limit_clause {
     my $self = shift;
     my $limit_clause;
@@ -346,18 +325,16 @@
             $limit_clause .= $self->first_row . ", ";
         }
         $limit_clause .= $self->rows_per_page;
-    }
-    else {
+    } else {
         $limit_clause = "";
     }
     return $limit_clause;
 }
 
-
-
 =head2 _is_limited
 
-If we've limited down this search, return true. Otherwise, return false.
+If we've limited down this search, return true. Otherwise, return
+false.
 
 =cut
 
@@ -365,18 +342,15 @@
     my $self = shift;
     if (@_) {
         $self->{'is_limited'} = shift;
-    }
-    else {
+    } else {
         return ( $self->{'is_limited'} );
     }
 }
 
-
-
-
 =head2 build_select_query
 
-Builds a query string for a "SELECT rows from Tables" statement for this SearchBuilder object
+Builds a query string for a "SELECT rows from Tables" statement for
+this collection
 
 =cut
 
@@ -387,11 +361,11 @@
 
     my $QueryString = $self->_build_joins . " ";
     $QueryString .= $self->_where_clause . " "
-      if ( $self->_is_limited > 0 );
+        if ( $self->_is_limited > 0 );
 
     # DISTINCT query only required for multi-table selects
-    if ($self->_is_joined) {
-        $self->_distinct_query(\$QueryString, $self->table);
+    if ( $self->_is_joined ) {
+        $self->_distinct_query( \$QueryString, $self->table );
     } else {
         $QueryString = "SELECT main.* FROM $QueryString";
     }
@@ -400,35 +374,32 @@
 
     $QueryString .= ' ' . $self->_order_clause . ' ';
 
-    $self->_apply_limits(\$QueryString);
+    $self->_apply_limits( \$QueryString );
 
-    return($QueryString)
+    return ($QueryString)
 
 }
 
-
-
 =head2 build_select_count_query
 
-Builds a SELECT statement to find the number of rows this SearchBuilder object would find.
+Builds a SELECT statement to find the number of rows this collection
+ would find.
 
 =cut
 
 sub build_select_count_query {
     my $self = shift;
 
-    #TODO refactor DoSearch and do_count such that we only have
-    # one place where we build most of the querystring
+    # TODO: refactor DoSearch and do_count such that we only have one
+    # place where we build most of the querystring
     my $QueryString = $self->_build_joins . " ";
 
     $QueryString .= $self->_where_clause . " "
-      if ( $self->_is_limited > 0 );
-
-
+        if ( $self->_is_limited > 0 );
 
     # DISTINCT query only required for multi-table selects
-    if ($self->_is_joined) {
-        $QueryString = $self->_handle->distinct_count(\$QueryString);
+    if ( $self->_is_joined ) {
+        $QueryString = $self->_handle->distinct_count( \$QueryString );
     } else {
         $QueryString = "SELECT count(main.id) FROM " . $QueryString;
     }
@@ -436,20 +407,17 @@
     return ($QueryString);
 }
 
+=head2 next
 
-
-
-=head2 Next
-
-Returns the next row from the set as an object of the type defined by sub new_item.
-When the complete set has been iterated through, returns undef and resets the search
-such that the following call to Next will start over with the first item retrieved from the database.
+Returns the next row from the set as an object of the type defined by
+sub new_item.  When the complete set has been iterated through,
+returns undef and resets the search such that the following call to
+L</next> will start over with the first item retrieved from the
+database.
 
 =cut
 
-
-
-sub Next {
+sub next {
     my $self = shift;
     my @row;
 
@@ -457,41 +425,34 @@
 
     $self->_do_search() if $self->{'must_redo_search'};
 
-    if ( $self->{'itemscount'} < $self->_record_count ) {    #return the next item
+    if ( $self->{'itemscount'} < $self->_record_count )
+    {    #return the next item
         my $item = ( $self->{'items'}[ $self->{'itemscount'} ] );
         $self->{'itemscount'}++;
         return ($item);
-    }
-    else {    #we've gone through the whole list. reset the count.
+    } else {    #we've gone through the whole list. reset the count.
         $self->goto_first_item();
         return (undef);
     }
 }
 
-
-
 =head2 goto_first_item
 
-Starts the recordset counter over from the first item. The next time you call Next,
-you'll get the first item returned by the database, as if you'd just started iterating
-through the result set.
+Starts the recordset counter over from the first item. The next time
+you call L</next>, you'll get the first item returned by the database,
+as if you'd just started iterating through the result set.
 
 =cut
 
-
 sub goto_first_item {
     my $self = shift;
     $self->goto_item(0);
 }
 
-
-
-
 =head2 goto_item
 
-Takes an integer, n.
-Sets the record counter to n. the next time you call Next,
-you'll get the nth item.
+Takes an integer, n.  Sets the record counter to n. the next time you
+call L</next>, you'll get the nth item.
 
 =cut
 
@@ -501,9 +462,7 @@
     $self->{'itemscount'} = $item;
 }
 
-
-
-=head2 First
+=head2 first
 
 Returns the first item
 
@@ -515,9 +474,7 @@
     return ( $self->next );
 }
 
-
-
-=head2 Last
+=head2 last
 
 Returns the last item
 
@@ -529,51 +486,44 @@
     return ( $self->next );
 }
 
-
-
 =head2 items_array_ref
 
-Return a refernece to an array containing all objects found by this search.
+Return a refernece to an array containing all objects found by this
+search.
 
 =cut
 
 sub items_array_ref {
     my $self = shift;
 
-    #If we're not limited, return an empty array
+    # If we're not limited, return an empty array
     return [] unless $self->_is_limited;
 
-    #Do a search if we need to.
+    # Do a search if we need to.
     $self->_do_search() if $self->{'must_redo_search'};
 
-    #If we've got any items in the array, return them.
-    # Otherwise, return an empty array
+    # If we've got any items in the array, return them.  Otherwise,
+    # return an empty array
     return ( $self->{'items'} || [] );
 }
 
-
-
-
 =head2 new_item
 
-new_item must be subclassed. It is used by Jifty::DBI::Collection to create record 
-objects for each row returned from the database.
+new_item must be subclassed. It is used by Jifty::DBI::Collection to
+create record objects for each row returned from the database.
 
 =cut
 
 sub new_item {
     my $self = shift;
 
-    die
-"Jifty::DBI::Collection needs to be subclassed. you can't use it directly.\n";
+    die "Jifty::DBI::Collection needs to be subclassed; override new_item\n";
 }
 
-
-
 =head2 redo_search
 
-Takes no arguments.  Tells Jifty::DBI::Collection that the next time it's asked
-for a record, it should requery the database
+Takes no arguments.  Tells Jifty::DBI::Collection that the next time
+it's asked for a record, it should requery the database
 
 =cut
 
@@ -582,9 +532,6 @@
     $self->{'must_redo_search'} = 1;
 }
 
-
-
-
 =head2 unlimit
 
 unlimit clears all restrictions and causes this object to return all
@@ -597,8 +544,6 @@
     $self->_is_limited(-1);
 }
 
-
-
 =head2 Limit
 
 Limit takes a hash of parameters with the following keys:
@@ -689,12 +634,10 @@
         #If it's a like, we supply the %s around the search term
         if ( $args{'OPERATOR'} =~ /LIKE/i ) {
             $args{'VALUE'} = "%" . $args{'VALUE'} . "%";
-        }
-        elsif ( $args{'OPERATOR'} =~ /STARTSWITH/i ) {
+        } elsif ( $args{'OPERATOR'} =~ /STARTSWITH/i ) {
             $args{'VALUE'}    = $args{'VALUE'} . "%";
             $args{'OPERATOR'} = "LIKE";
-        }
-        elsif ( $args{'OPERATOR'} =~ /ENDSWITH/i ) {
+        } elsif ( $args{'OPERATOR'} =~ /ENDSWITH/i ) {
             $args{'VALUE'}    = "%" . $args{'VALUE'};
             $args{'OPERATOR'} = "LIKE";
         }
@@ -706,20 +649,20 @@
             my $tmp = $self->_handle->dbh->quote( $args{'VALUE'} );
 
             # Accomodate DBI drivers that don't understand UTF8
-	    if ($] >= 5.007) {
-	        require Encode;
-	        if( Encode::is_utf8( $args{'VALUE'} ) ) {
-	            Encode::_utf8_on( $tmp );
-	        }
+            if ( $] >= 5.007 ) {
+                require Encode;
+                if ( Encode::is_utf8( $args{'VALUE'} ) ) {
+                    Encode::_utf8_on($tmp);
+                }
             }
-	    $args{'VALUE'} = $tmp;
+            $args{'VALUE'} = $tmp;
         }
     }
 
     $Alias = $self->_generic_restriction(%args);
 
     warn "No table alias set!"
-      unless $Alias;
+        unless $Alias;
 
     # We're now limited. people can do searches.
 
@@ -727,61 +670,26 @@
 
     if ( defined($Alias) ) {
         return ($Alias);
-    }
-    else {
+    } else {
         return (1);
     }
 }
 
-
-
-=head2 show_restrictions
-
-Returns the current object's proposed WHERE clause. 
-
-Deprecated.
-
-=cut
-
-sub show_restrictions {
-    my $self = shift;
-    $self->_compile_generic_restrictions();
-    $self->_compile_sub_clauses();
-    return ( $self->{'where_clause'} );
-
-}
-
-
-
-=head2 ImportRestrictions
-
-Replaces the current object's WHERE clause with the string passed as its argument.
-
-Deprecated
-
-=cut
-
-#import a restrictions clause
-sub ImportRestrictions {
-    my $self = shift;
-    $self->{'where_clause'} = shift;
-}
-
-
-
 sub _generic_restriction {
     my $self = shift;
-    my %args = ( TABLE           => $self->table,
-                 FIELD           => undef,
-                 VALUE           => undef,
-                 ALIAS           => undef,
-                 LEFTJOIN        => undef,
-                 ENTRYAGGREGATOR => undef,
-                 OPERATOR        => '=',
-                 SUBCLAUSE       => undef,
-                 CASESENSITIVE   => undef,
-                 QUOTEVALUE     => undef,
-                 @_ );
+    my %args = (
+        TABLE           => $self->table,
+        FIELD           => undef,
+        VALUE           => undef,
+        ALIAS           => undef,
+        LEFTJOIN        => undef,
+        ENTRYAGGREGATOR => undef,
+        OPERATOR        => '=',
+        SUBCLAUSE       => undef,
+        CASESENSITIVE   => undef,
+        QUOTEVALUE      => undef,
+        @_
+    );
 
     my ( $Clause, $QualifiedField );
 
@@ -791,8 +699,9 @@
     #If we're performing a left join, we really want the alias to be the
     #left join criterion.
 
-    if (    ( defined $args{'LEFTJOIN'} )
-         && ( !defined $args{'ALIAS'} ) ) {
+    if (   ( defined $args{'LEFTJOIN'} )
+        && ( !defined $args{'ALIAS'} ) )
+    {
         $args{'ALIAS'} = $args{'LEFTJOIN'};
     }
 
@@ -828,13 +737,13 @@
 
     if ( $args{'SUBCLAUSE'} ) {
         $Clause = $args{'SUBCLAUSE'};
-    }
-    else {
+    } else {
         $Clause = $QualifiedField;
     }
 
-    print STDERR "$self->_generic_restriction QualifiedField=$QualifiedField\n"
-      if ( $self->DEBUG );
+    print STDERR
+        "$self->_generic_restriction QualifiedField=$QualifiedField\n"
+        if ( $self->DEBUG );
 
     my ($restriction);
 
@@ -842,21 +751,25 @@
     # $restriction to point htere. otherwise, lets construct normally
 
     if ( $args{'LEFTJOIN'} ) {
-        $restriction =
-          \$self->{'left_joins'}{ $args{'LEFTJOIN'} }{'criteria'}{"$Clause"};
-    }
-    else {
+        $restriction = \$self->{'left_joins'}{ $args{'LEFTJOIN'} }{'criteria'}
+            {"$Clause"};
+    } else {
         $restriction = \$self->{'restrictions'}{"$Clause"};
     }
 
     # If it's a new value or we're overwriting this sort of restriction,
 
-    if ( $self->_handle->case_sensitive && defined $args{'VALUE'} && $args{'VALUE'} ne ''  && $args{'VALUE'} ne "''" && ($args{'OPERATOR'} !~/IS/ && $args{'VALUE'} !~ /^null$/i)) {
+    if (   $self->_handle->case_sensitive
+        && defined $args{'VALUE'}
+        && $args{'VALUE'} ne ''
+        && $args{'VALUE'} ne "''"
+        && ( $args{'OPERATOR'} !~ /IS/ && $args{'VALUE'} !~ /^null$/i ) )
+    {
 
         unless ( $args{'CASESENSITIVE'} || !$args{'QUOTEVALUE'} ) {
-               ( $QualifiedField, $args{'OPERATOR'}, $args{'VALUE'} ) =
-                 $self->_handle->_make_clause_case_insensitive( $QualifiedField,
-                $args{'OPERATOR'}, $args{'VALUE'} );
+            ( $QualifiedField, $args{'OPERATOR'}, $args{'VALUE'} )
+                = $self->_handle->_make_clause_case_insensitive(
+                $QualifiedField, $args{'OPERATOR'}, $args{'VALUE'} );
         }
 
     }
@@ -870,15 +783,16 @@
         delete $self->{_open_parens}{$Clause};
     }
 
-    if ( (     ( exists $args{'ENTRYAGGREGATOR'} )
-           and ( $args{'ENTRYAGGREGATOR'} || "" ) eq 'none' )
-         or ( !$$restriction )
-      ) {
+    if ((       ( exists $args{'ENTRYAGGREGATOR'} )
+            and ( $args{'ENTRYAGGREGATOR'} || "" ) eq 'none'
+        )
+        or ( !$$restriction )
+        )
+    {
 
         $$restriction = $prefix . $clause;
 
-    }
-    else {
+    } else {
         $$restriction .= $args{'ENTRYAGGREGATOR'} . $prefix . $clause;
     }
 
@@ -886,7 +800,6 @@
 
 }
 
-
 sub _open_paren {
     my ( $self, $clause ) = @_;
     $self->{_open_parens}{$clause}++;
@@ -898,13 +811,11 @@
     my $restriction = \$self->{'restrictions'}{"$clause"};
     if ( !$$restriction ) {
         $$restriction = " ) ";
-    }
-    else {
+    } else {
         $$restriction .= " ) ";
     }
 }
 
-
 sub _add_sub_clause {
     my $self      = shift;
     my $clauseid  = shift;
@@ -914,27 +825,27 @@
 
 }
 
-
-
 sub _where_clause {
     my $self = shift;
     my ( $subclause, $where_clause );
 
-    #Go through all the generic restrictions and build up the "generic_restrictions" subclause
-    # That's the only one that SearchBuilder builds itself.
-    # Arguably, the abstraction should be better, but I don't really see where to put it.
+# Go through all the generic restrictions and build up the
+# "generic_restrictions" subclause.  That's the only one that the
+# collection builds itself.  Arguably, the abstraction should be
+# better, but I don't really see where to put it.
     $self->_compile_generic_restrictions();
 
     #Go through all restriction types. Build the where clause from the
     #Various subclauses.
     foreach $subclause ( keys %{ $self->{'subclauses'} } ) {
+
         # Now, build up the where clause
         if ( defined($where_clause) ) {
             $where_clause .= " AND ";
         }
 
         warn "$self $subclause doesn't exist"
-          if ( !defined $self->{'subclauses'}{"$subclause"} );
+            if ( !defined $self->{'subclauses'}{"$subclause"} );
         $where_clause .= $self->{'subclauses'}{"$subclause"};
     }
 
@@ -944,8 +855,6 @@
 
 }
 
-
-
 #Compile the restrictions to a WHERE Clause
 
 sub _compile_generic_restrictions {
@@ -954,21 +863,17 @@
 
     delete $self->{'subclauses'}{'generic_restrictions'};
 
-    #Go through all the restrictions of this type. Buld up the generic subclause
+  #Go through all the restrictions of this type. Buld up the generic subclause
     foreach $restriction ( sort keys %{ $self->{'restrictions'} } ) {
         if ( defined $self->{'subclauses'}{'generic_restrictions'} ) {
             $self->{'subclauses'}{'generic_restrictions'} .= " AND ";
         }
-        $self->{'subclauses'}{'generic_restrictions'} .=
-          "(" . $self->{'restrictions'}{"$restriction"} . ")";
+        $self->{'subclauses'}{'generic_restrictions'}
+            .= "(" . $self->{'restrictions'}{"$restriction"} . ")";
     }
 }
 
-
-
-
-
-=head2 Orderby PARAMHASH
+=head2 order_by PARAMHASH
 
 Orders the returned results by ALIAS.FIELD ORDER. (by default 'main.id ASC')
 
@@ -982,15 +887,15 @@
 
 sub order_by {
     my $self = shift;
-    my %args = ( @_ );
+    my %args = (@_);
 
     $self->order_by_cols( \%args );
 }
 
 =head2 order_by_cols ARRAY
 
-order_by_cols takes an array of paramhashes of the form passed to order_by.
-The result set is ordered by the items in the array.
+order_by_cols takes an array of paramhashes of the form passed to
+order_by.  The result set is ordered by the items in the array.
 
 =cut
 
@@ -1000,31 +905,33 @@
     my $row;
     my $clause;
 
-    foreach $row ( @args ) {
+    foreach $row (@args) {
 
-        my %rowhash = ( ALIAS => 'main',
-			FIELD => undef,
-			ORDER => 'ASC',
-			%$row
-		      );
-        if ($rowhash{'ORDER'} =~ /^des/i) {
-	    $rowhash{'ORDER'} = "DESC";
-        }
-        else {
-	    $rowhash{'ORDER'} = "ASC";
+        my %rowhash = (
+            ALIAS => 'main',
+            FIELD => undef,
+            ORDER => 'ASC',
+            %$row
+        );
+        if ( $rowhash{'ORDER'} =~ /^des/i ) {
+            $rowhash{'ORDER'} = "DESC";
+        } else {
+            $rowhash{'ORDER'} = "ASC";
         }
 
-        if ( ($rowhash{'ALIAS'}) and
-	     ($rowhash{'FIELD'}) and
-             ($rowhash{'ORDER'}) ) {
-
-	    if ($rowhash{'FIELD'} =~ /^(\w+\()(.*\))$/) {
-		# handle 'FUNCTION(FIELD)' formatted fields
-		$rowhash{'ALIAS'} = $1 . $rowhash{'ALIAS'};
-		$rowhash{'FIELD'} = $2;
-	    }
+        if (    ( $rowhash{'ALIAS'} )
+            and ( $rowhash{'FIELD'} )
+            and ( $rowhash{'ORDER'} ) )
+        {
+
+            if ( $rowhash{'FIELD'} =~ /^(\w+\()(.*\))$/ ) {
+
+                # handle 'FUNCTION(FIELD)' formatted fields
+                $rowhash{'ALIAS'} = $1 . $rowhash{'ALIAS'};
+                $rowhash{'FIELD'} = $2;
+            }
 
-            $clause .= ($clause ? ", " : " ");
+            $clause .= ( $clause ? ", " : " " );
             $clause .= $rowhash{'ALIAS'} . ".";
             $clause .= $rowhash{'FIELD'} . " ";
             $clause .= $rowhash{'ORDER'};
@@ -1032,16 +939,13 @@
     }
 
     if ($clause) {
-	$self->{'order_clause'} = "ORDER BY" . $clause;
-    }
-    else {
-	$self->{'order_clause'} = "";
+        $self->{'order_clause'} = "ORDER BY" . $clause;
+    } else {
+        $self->{'order_clause'} = "";
     }
     $self->redo_search();
 }
 
-
-
 =head2 _order_clause
 
 returns the ORDER BY clause for the search.
@@ -1052,26 +956,13 @@
     my $self = shift;
 
     return '' unless $self->{'order_clause'};
-    return ($self->{'order_clause'});
+    return ( $self->{'order_clause'} );
 }
 
-
-
-
-
-=head2 group_by  (DEPRECATED)
-
-Alias for the group_by_cols method.
-
-=cut
-
-sub group_by { (shift)->group_by_cols( @_ ) }
-
-
-
 =head2 group_by_cols ARRAY_OF_HASHES
 
-Each hash contains the keys ALIAS and FIELD. ALIAS defaults to 'main' if ignored.
+Each hash contains the keys ALIAS and FIELD. ALIAS defaults to 'main'
+if ignored.
 
 =cut
 
@@ -1081,35 +972,34 @@
     my $row;
     my $clause;
 
-    foreach $row ( @args ) {
-        my %rowhash = ( ALIAS => 'main',
-			FIELD => undef,
-			%$row
-		      );
-        if ($rowhash{'FUNCTION'} ) {
-            $clause .= ($clause ? ", " : " ");
+    foreach $row (@args) {
+        my %rowhash = (
+            ALIAS => 'main',
+            FIELD => undef,
+            %$row
+        );
+        if ( $rowhash{'FUNCTION'} ) {
+            $clause .= ( $clause ? ", " : " " );
             $clause .= $rowhash{'FUNCTION'};
 
-        }
-        elsif ( ($rowhash{'ALIAS'}) and
-             ($rowhash{'FIELD'}) ) {
+        } elsif ( ( $rowhash{'ALIAS'} )
+            and ( $rowhash{'FIELD'} ) )
+        {
 
-            $clause .= ($clause ? ", " : " ");
+            $clause .= ( $clause ? ", " : " " );
             $clause .= $rowhash{'ALIAS'} . ".";
             $clause .= $rowhash{'FIELD'};
         }
     }
 
     if ($clause) {
-	$self->{'group_clause'} = "GROUP BY" . $clause;
-    }
-    else {
-	$self->{'group_clause'} = "";
+        $self->{'group_clause'} = "GROUP BY" . $clause;
+    } else {
+        $self->{'group_clause'} = "";
     }
     $self->redo_search();
 }
 
-
 =head2 _group_clause
 
 Private function to return the "GROUP BY" clause for this query.
@@ -1120,18 +1010,14 @@
     my $self = shift;
 
     return '' unless $self->{'group_clause'};
-    return ($self->{'group_clause'});
+    return ( $self->{'group_clause'} );
 }
 
-
-
-
-
 =head2 new_alias
 
-Takes the name of a table.
-Returns the string of a new Alias for that table, which can be used to Join tables
-or to Limit what gets found by a search.
+Takes the name of a table.  Returns the string of a new Alias for that
+table, which can be used to Join tables or to Limit what gets found by
+a search.
 
 =cut
 
@@ -1143,13 +1029,11 @@
 
     my $subclause = "$table $alias";
 
-    push ( @{ $self->{'aliases'} }, $subclause );
+    push( @{ $self->{'aliases'} }, $subclause );
 
     return $alias;
 }
 
-
-
 # _get_alias is a private function which takes an tablename and
 # returns a new alias for that table without adding something
 # to self->{'aliases'}.  This function is used by new_alias
@@ -1166,29 +1050,28 @@
 
 }
 
-
-
-=head2 Join
+=head2 join
 
 Join instructs Jifty::DBI::Collection to join two tables.  
 
-The standard form takes a param hash with keys ALIAS1, FIELD1, ALIAS2 and 
-FIELD2. ALIAS1 and ALIAS2 are column aliases obtained from $self->new_alias or
-a $self->Limit. FIELD1 and FIELD2 are the fields in ALIAS1 and ALIAS2 that 
-should be linked, respectively.  For this type of join, this method
-has no return value.
+The standard form takes a param hash with keys ALIAS1, FIELD1, ALIAS2
+and FIELD2. ALIAS1 and ALIAS2 are column aliases obtained from
+$self->new_alias or a $self->Limit. FIELD1 and FIELD2 are the fields
+in ALIAS1 and ALIAS2 that should be linked, respectively.  For this
+type of join, this method has no return value.
 
-Supplying the parameter TYPE => 'left' causes Join to preform a left join.
-in this case, it takes ALIAS1, FIELD1, TABLE2 and FIELD2. Because of the way
-that left joins work, this method needs a TABLE for the second field
-rather than merely an alias.  For this type of join, it will return
-the alias generated by the join.
+Supplying the parameter TYPE => 'left' causes Join to preform a left
+join.  in this case, it takes ALIAS1, FIELD1, TABLE2 and
+FIELD2. Because of the way that left joins work, this method needs a
+TABLE for the second field rather than merely an alias.  For this type
+of join, it will return the alias generated by the join.
 
-Instead of ALIAS1/FIELD1, it's possible to specify EXPRESSION, to join ALIAS2/TABLE2 on an arbitrary expression.
+Instead of ALIAS1/FIELD1, it's possible to specify EXPRESSION, to join
+ALIAS2/TABLE2 on an arbitrary expression.
 
 =cut
 
-sub Join {
+sub join {
     my $self = shift;
     my %args = (
         TYPE   => 'normal',
@@ -1200,59 +1083,45 @@
         @_
     );
 
-    $self->_handle->Join( SearchBuilder => $self, %args );
+    $self->_handle->join( collection => $self, %args );
 
 }
 
-
-
-
-
-sub NextPage {
+sub next_page {
     my $self = shift;
     $self->first_row( $self->first_row + $self->rows_per_page );
 }
 
-
-sub FirstPage {
+sub first_page {
     my $self = shift;
     $self->first_row(1);
 }
 
-
-
-
-
 sub prev_page {
     my $self = shift;
     if ( ( $self->first_row - $self->rows_per_page ) > 1 ) {
         $self->first_row( $self->first_row - $self->rows_per_page );
-    }
-    else {
+    } else {
         $self->first_row(1);
     }
 }
 
-
-
 sub goto_page {
     my $self = shift;
     my $page = shift;
 
     if ( $self->rows_per_page ) {
-    	$self->first_row( 1 + ( $self->rows_per_page * $page ) );
+        $self->first_row( 1 + ( $self->rows_per_page * $page ) );
     } else {
         $self->first_row(1);
     }
 }
 
-
-
 =head2 rows_per_page
 
-Limits the number of rows returned by the database.
-Optionally, takes an integer which restricts the # of rows returned in a result
-Returns the number of rows the database should display.
+Limits the number of rows returned by the database.  Optionally, takes
+an integer which restricts the # of rows returned in a result Returns
+the number of rows the database should display.
 
 =cut
 
@@ -1263,13 +1132,11 @@
     return ( $self->{'show_rows'} );
 }
 
-
-
 =head2 first_row
 
 Get or set the first row of the result set the database should return.
-Takes an optional single integer argrument. Returns the currently set integer
-first row that the database should return.
+Takes an optional single integer argrument. Returns the currently set
+integer first row that the database should return.
 
 
 =cut
@@ -1289,10 +1156,6 @@
     return ( $self->{'first_row'} );
 }
 
-
-
-
-
 =head2 _items_counter
 
 Returns the current position in the record set.
@@ -1304,22 +1167,17 @@
     return $self->{'itemscount'};
 }
 
-
-
-=head2 Count
+=head2 count
 
 Returns the number of records in the set.
 
 =cut
 
-
-
-sub Count {
+sub count {
     my $self = shift;
 
-    # An unlimited search returns no tickets    
-    return 0 unless ($self->_is_limited);
-
+    # An unlimited search returns no tickets
+    return 0 unless ( $self->_is_limited );
 
     # If we haven't actually got all objects loaded in memory, we
     # really just want to do a quick count from the database.
@@ -1339,8 +1197,6 @@
     }
 }
 
-
-
 =head2 count_all
 
 Returns the total number of potential records in the set, ignoring any
@@ -1359,7 +1215,7 @@
 # 22:27 [msg(Robrt)] (given that every time we try to explain it, we get it Wrong)
 # 22:27 [Robrt(500 at outer.space)] Because Count can return a different number than actual NumberOfResults
 # 22:28 [msg(Robrt)] in what case?
-# 22:28 [Robrt(500 at outer.space)] count_all _always_ used the return value of _do_count(), as opposed to Count which would return the cached number of 
+# 22:28 [Robrt(500 at outer.space)] count_all _always_ used the return value of _do_count(), as opposed to Count which would return the cached number of
 #           results returned.
 # 22:28 [Robrt(500 at outer.space)] IIRC, if you do a search with a Limit, then raw_rows will == Limit.
 # 22:31 [msg(Robrt)] ah.
@@ -1368,16 +1224,16 @@
 # 22:31 [msg(Robrt)] perhaps I'll create a new method that _actually_ do that.
 # 22:32 [msg(Robrt)] since I'm not convinced it's been doing that correctly
 
-
 sub count_all {
     my $self = shift;
 
-    # An unlimited search returns no tickets    
-    return 0 unless ($self->_is_limited);
+    # An unlimited search returns no tickets
+    return 0 unless ( $self->_is_limited );
 
     # If we haven't actually got all objects loaded in memory, we
     # really just want to do a quick count from the database.
-    if ( $self->{'must_redo_search'} || !$self->{'count_all'}) {
+    if ( $self->{'must_redo_search'} || !$self->{'count_all'} ) {
+
         # If we haven't already asked the database for the row count, do that
         $self->_do_count(1) unless ( $self->{'count_all'} );
 
@@ -1392,30 +1248,24 @@
     }
 }
 
-
-
-
-=head2 IsLast
+=head2 is_last
 
 Returns true if the current row is the last record in the set.
 
 =cut
 
-sub IsLast {
+sub is_last {
     my $self = shift;
 
     return undef unless $self->count;
 
     if ( $self->_items_counter == $self->count ) {
         return (1);
-    }
-    else {
+    } else {
         return (0);
     }
 }
 
-
-
 sub DEBUG {
     my $self = shift;
     if (@_) {
@@ -1424,13 +1274,7 @@
     return ( $self->{'DEBUG'} );
 }
 
-
-
-
-
-
-
-=head2 Column { FIELD => undef } 
+=head2 column { FIELD => undef } 
 
 Specify that we want to load the column  FIELD. 
 
@@ -1440,20 +1284,21 @@
 
 =cut
 
-sub Column {
+sub column {
     my $self = shift;
-    my %args = ( TABLE => undef,
-               ALIAS => undef,
-               FIELD => undef,
-               FUNCTION => undef,
-               @_);
+    my %args = (
+        TABLE    => undef,
+        ALIAS    => undef,
+        FIELD    => undef,
+        FUNCTION => undef,
+        @_
+    );
 
     my $table = $args{TABLE} || do {
         if ( my $alias = $args{ALIAS} ) {
             $alias =~ s/_\d+$//;
             $alias;
-        }
-        else {
+        } else {
             $self->table;
         }
     };
@@ -1463,17 +1308,19 @@
         if ( $func =~ /^DISTINCT\s*COUNT$/i ) {
             $name = "COUNT(DISTINCT $name)";
         }
-        # If we want to substitute 
-        elsif ($func =~ /\?/) {
-            $name = join($name,split(/\?/,$func));
+
+        # If we want to substitute
+        elsif ( $func =~ /\?/ ) {
+            $name = CORE::join( $name, split( /\?/, $func ) );
         }
+
         # If we want to call a simple function on the column
-        elsif ($func !~ /\(/)  {
+        elsif ( $func !~ /\(/ ) {
             $name = "\U$func\E($name)";
         } else {
             $name = $func;
         }
-        
+
     }
 
     my $column = "col" . @{ $self->{columns} ||= [] };
@@ -1482,24 +1329,19 @@
     return $column;
 }
 
-
-
-
-=head2 Columns LIST
+=head2 columns LIST
 
 Specify that we want to load only the columns in LIST
 
 =cut
 
-sub Columns {
+sub columns {
     my $self = shift;
-    $self->Column( FIELD => $_ ) for @_;
+    $self->column( FIELD => $_ ) for @_;
 }
 
-
-
 =head2 fields TABLE
- 
+
 Return a list of fields in TABLE, lowercased.
 
 TODO: Why are they lowercased?
@@ -1517,16 +1359,13 @@
     return map lc( $_->[0] ), @{
         eval {
             $dbh->column_info( '', '', $table, '' )->fetchall_arrayref( [3] );
-          }
-          || $dbh->selectall_arrayref("DESCRIBE $table;")
-          || $dbh->selectall_arrayref("DESCRIBE \u$table;")
-          || []
-      };
+            }
+            || $dbh->selectall_arrayref("DESCRIBE $table;")
+            || $dbh->selectall_arrayref("DESCRIBE \u$table;")
+            || []
+        };
 }
 
-
-
-
 =head2 has_field  { TABLE => undef, FIELD => undef }
 
 Returns true if TABLE has field FIELD.
@@ -1536,18 +1375,18 @@
 
 sub has_field {
     my $self = shift;
-    my %args = ( FIELD => undef,
-                 TABLE => undef,
-                 @_);
+    my %args = (
+        FIELD => undef,
+        TABLE => undef,
+        @_
+    );
 
     my $table = $args{TABLE} or die;
     my $field = $args{FIELD} or die;
     return grep { $_ eq $field } $self->fields($table);
 }
 
-
-
-=head2 Table [TABLE]
+=head2 table [TABLE]
 
 If called with an argument, sets this collection's table.
 
@@ -1566,9 +1405,8 @@
     return $self->{table};
 }
 
-
-if( eval { require capitalization } ) {
-	capitalization->unimport( __PACKAGE__ );
+if ( eval { require capitalization } ) {
+    capitalization->unimport(__PACKAGE__);
 }
 
 1;
@@ -1578,14 +1416,16 @@
 
 =head1 TESTING
 
-In order to test most of the features of C<Jifty::DBI::Collection>, you need
-to provide C<make test> with a test database.  For each DBI driver that you
-would like to test, set the environment variables C<SB_TEST_FOO>, C<SB_TEST_FOO_USER>,
-and C<SB_TEST_FOO_PASS> to a database name, database username, and database password,
-where "FOO" is the driver name in all uppercase.  You can test as many drivers
-as you like.  (The appropriate C<DBD::> module needs to be installed in order for
-the test to work.)  Note that the C<SQLite> driver will automatically be tested if C<DBD::Sqlite>
-is installed, using a temporary file as the database.  For example:
+In order to test most of the features of C<Jifty::DBI::Collection>,
+you need to provide C<make test> with a test database.  For each DBI
+driver that you would like to test, set the environment variables
+C<SB_TEST_FOO>, C<SB_TEST_FOO_USER>, and C<SB_TEST_FOO_PASS> to a
+database name, database username, and database password, where "FOO"
+is the driver name in all uppercase.  You can test as many drivers as
+you like.  (The appropriate C<DBD::> module needs to be installed in
+order for the test to work.)  Note that the C<SQLite> driver will
+automatically be tested if C<DBD::Sqlite> is installed, using a
+temporary file as the database.  For example:
 
   SB_TEST_MYSQL=test SB_TEST_MYSQL_USER=root SB_TEST_MYSQL_PASS=foo \
     SB_TEST_PG=test SB_TEST_PG_USER=postgres  make test

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle.pm	Mon Jul 25 21:36:24 2005
@@ -207,7 +207,7 @@
 
 =head2 log_sql_statements BOOL
 
-Takes a boolean argument. If the boolean is true, SearchBuilder will log all SQL
+Takes a boolean argument. If the boolean is true, it will log all SQL
 statements, as well as their invocation times and execution times.
 
 Returns whether we're currently logging or not as a boolean
@@ -725,9 +725,9 @@
 
 =head2 join { Paramhash }
 
-Takes a paramhash of everything Searchbuildler::Record does 
-plus a parameter called 'SearchBuilder' that contains a ref 
-to a SearchBuilder object'.
+Takes a paramhash of everything Searchbuildler::Record does plus a
+parameter called 'collection' that contains a ref to a
+L<Jifty::DBI::Collection> object'.
 
 This performs the join.
 
@@ -738,14 +738,14 @@
 
     my $self = shift;
     my %args = (
-        SearchBuilder => undef,
-        TYPE          => 'normal',
-        FIELD1        => 'main',
-        ALIAS1        => undef,
-        TABLE2        => undef,
-        FIELD2        => undef,
-        ALIAS2        => undef,
-        EXPRESSION    => undef,
+        collection => undef,
+        TYPE       => 'normal',
+        FIELD1     => 'main',
+        ALIAS1     => undef,
+        TABLE2     => undef,
+        FIELD2     => undef,
+        ALIAS2     => undef,
+        EXPRESSION => undef,
         @_
     );
 
@@ -753,13 +753,15 @@
 
     my $alias;
 
-#If we're handed in an ALIAS2, we need to go remove it from the Aliases array.
-# Basically, if anyone generates an alias and then tries to use it in a join later, we want to be smart about
-# creating joins, so we need to go rip it out of the old aliases table and drop it in as an explicit join
+#If we're handed in an ALIAS2, we need to go remove it from the
+# Aliases array.  Basically, if anyone generates an alias and then
+# tries to use it in a join later, we want to be smart about creating
+# joins, so we need to go rip it out of the old aliases table and drop
+# it in as an explicit join
     if ( $args{'ALIAS2'} ) {
 
         # this code is slow and wasteful, but it's clear.
-        my @aliases = @{ $args{'SearchBuilder'}->{'aliases'} };
+        my @aliases = @{ $args{'collection'}->{'aliases'} };
         my @new_aliases;
         foreach my $old_alias (@aliases) {
             if ( $old_alias =~ /^(.*?) ($args{'ALIAS2'})$/ ) {
@@ -783,7 +785,7 @@
             $args{'ALIAS2'} = $a1;
             $args{'FIELD2'} = $f1;
 
-            @aliases     = @{ $args{'SearchBuilder'}->{'aliases'} };
+            @aliases     = @{ $args{'collection'}->{'aliases'} };
             @new_aliases = ();
             foreach my $old_alias (@aliases) {
                 if ( $old_alias =~ /^(.*?) ($args{'ALIAS2'})$/ ) {
@@ -802,11 +804,11 @@
             return ( $self->_Normaljoin(%args) );
         }
 
-        $args{'SearchBuilder'}->{'aliases'} = \@new_aliases;
+        $args{'collection'}->{'aliases'} = \@new_aliases;
     }
 
     else {
-        $alias = $args{'SearchBuilder'}->_GetAlias( $args{'TABLE2'} );
+        $alias = $args{'collection'}->_GetAlias( $args{'TABLE2'} );
 
     }
 
@@ -829,12 +831,12 @@
         $criterion = $args{'ALIAS1'} . "." . $args{'FIELD1'};
     }
 
-    $args{'SearchBuilder'}->{'left_joins'}{"$alias"}{'alias_string'}
+    $args{'collection'}->{'left_joins'}{"$alias"}{'alias_string'}
         = $string;
-    $args{'SearchBuilder'}->{'left_joins'}{"$alias"}{'depends_on'}
+    $args{'collection'}->{'left_joins'}{"$alias"}{'depends_on'}
         = $args{'ALIAS1'};
-    $args{'SearchBuilder'}->{'left_joins'}{"$alias"}{'criteria'}
-        { 'criterion' . $args{'SearchBuilder'}->{'criteria_count'}++ }
+    $args{'collection'}->{'left_joins'}{"$alias"}{'criteria'}
+        { 'criterion' . $args{'collection'}->{'criteria_count'}++ }
         = " $alias.$args{'FIELD2'} = $criterion";
 
     return ($alias);
@@ -844,17 +846,17 @@
 
     my $self = shift;
     my %args = (
-        SearchBuilder => undef,
-        TYPE          => 'normal',
-        FIELD1        => undef,
-        ALIAS1        => undef,
-        TABLE2        => undef,
-        FIELD2        => undef,
-        ALIAS2        => undef,
+        collection => undef,
+        TYPE       => 'normal',
+        FIELD1     => undef,
+        ALIAS1     => undef,
+        TABLE2     => undef,
+        FIELD2     => undef,
+        ALIAS2     => undef,
         @_
     );
 
-    my $sb = $args{'SearchBuilder'};
+    my $sb = $args{'collection'};
 
     if ( $args{'TYPE'} =~ /LEFT/i ) {
         my $alias = $sb->_GetAlias( $args{'TABLE2'} );
@@ -967,7 +969,7 @@
 
 =cut
 
-sub Log {
+sub log {
     my $self = shift;
     my $msg  = shift;
     warn $msg . "\n";
@@ -976,7 +978,8 @@
 
 =head2 DESTROY
 
-When we get rid of the Searchbuilder::Handle, we need to disconnect from the database
+When we get rid of the L<Jifty::DBI::Handle>, we need to disconnect
+from the database
 
 =cut
 

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle/ODBC.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle/ODBC.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle/ODBC.pm	Mon Jul 25 21:36:24 2005
@@ -1,5 +1,3 @@
-# $Header: /home/jesse/DBIx-SearchBuilder/history/SearchBuilder/Handle/ODBC.pm,v 1.8 2001/10/12 05:27:05 jesse Exp $
-
 package Jifty::DBI::Handle::ODBC;
 use Jifty::DBI::Handle;
 @ISA = qw(Jifty::DBI::Handle);
@@ -16,7 +14,7 @@
 
 =head1 DESCRIPTION
 
-This module provides a subclass of Jifty::DBI::Handle that 
+This module provides a subclass of L<Jifty::DBI::Handle> that
 compensates for some of the idiosyncrasies of ODBC.
 
 =head1 METHODS
@@ -96,6 +94,6 @@
 
 =head1 SEE ALSO
 
-Jifty::DBI, Jifty::DBI::Handle
+L<Jifty::DBI>, L<Jifty::DBI::Handle>, L<DBD::ODBC>
 
 =cut

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Oracle.pm	Mon Jul 25 21:36:24 2005
@@ -1,7 +1,3 @@
-# $Header: /home/jesse/DBIx-SearchBuilder/history/SearchBuilder/Handle/Oracle.pm,v 1.14 2002/01/28 06:11:37 jesse Exp $
-
-use strict;
-
 package Jifty::DBI::Handle::Oracle;
 use base qw/Jifty::DBI::Handle/;
 use DBD::Oracle qw(:ora_types);
@@ -14,16 +10,13 @@
 
 =head1 SYNOPSIS
 
-
 =head1 DESCRIPTION
 
-This module provides a subclass of Jifty::DBI::Handle that 
+This module provides a subclass of L<Jifty::DBI::Handle> that
 compensates for some of the idiosyncrasies of Oracle.
 
 =head1 METHODS
 
-=cut
-
 =head2 connect PARAMHASH: Driver, Database, Host, User, Password
 
 Takes a paramhash and connects to your DBI datasource. 
@@ -56,8 +49,8 @@
 
 =head2 insert
 
-Takes a table name as the first argument and assumes that the rest of the arguments
-are an array of key-value pairs to be inserted.
+Takes a table name as the first argument and assumes that the rest of
+the arguments are an array of key-value pairs to be inserted.
 
 =cut
 
@@ -161,8 +154,9 @@
 
 =head2 knows_blobs     
 
-Returns 1 if the current database supports inserts of BLOBs automatically.      
-Returns undef if the current database must be informed of BLOBs for inserts.    
+Returns 1 if the current database supports inserts of BLOBs
+automatically.  Returns undef if the current database must be informed
+of BLOBs for inserts.
 
 =cut
 
@@ -173,9 +167,9 @@
 
 =head2 blob_params FIELD_NAME FIELD_TYPE
 
-Returns a hash ref for the bind_param call to identify BLOB types used by 
-the current database for a particular column type.
-The current Oracle implementation only supports ORA_CLOB types (112).
+Returns a hash ref for the bind_param call to identify BLOB types used
+by the current database for a particular column type.  The current
+Oracle implementation only supports ORA_CLOB types (112).
 
 =cut
 
@@ -194,8 +188,8 @@
 
 =head2 apply_limits STATEMENTREF ROWS_PER_PAGE FIRST_ROW
 
-takes an SQL SELECT statement and massages it to return ROWS_PER_PAGE starting with FIRST_ROW;
-
+takes an SQL SELECT statement and massages it to return ROWS_PER_PAGE
+starting with FIRST_ROW;
 
 =cut
 
@@ -244,8 +238,8 @@
 
 =head2 distinct_query STATEMENTREF
 
-takes an incomplete SQL SELECT statement and massages it to return a DISTINCT result set.
-
+takes an incomplete SQL SELECT statement and massages it to return a
+DISTINCT result set.
 
 =cut
 
@@ -265,7 +259,6 @@
 
 Return undef, as Oracle doesn't support binary-safe CLOBS
 
-
 =cut
 
 sub binary_safe_blobs {
@@ -283,6 +276,6 @@
 
 =head1 SEE ALSO
 
-perl(1), Jifty::DBI
+L<Jifty::DBI>, L<Jifty::DBI::Handle>, L<DBD::Oracle>
 
 =cut

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Pg.pm	Mon Jul 25 21:36:24 2005
@@ -1,6 +1,3 @@
-#$Header: /home/jesse/DBIx-SearchBuilder/history/SearchBuilder/Handle/Pg.pm,v 1.8 2001/07/27 05:23:29 jesse Exp $
-# Copyright 1999-2001 Jesse Vincent <jesse at fsck.com>
-
 package Jifty::DBI::Handle::Pg;
 use strict;
 
@@ -19,7 +16,7 @@
 
 =head1 DESCRIPTION
 
-This module provides a subclass of Jifty::DBI::Handle that 
+This module provides a subclass of L<Jifty::DBI::Handle> that
 compensates for some of the idiosyncrasies of Postgres.
 
 =head1 METHODS
@@ -28,9 +25,8 @@
 
 =head2 connect
 
-connect takes a hashref and passes it off to SUPER::connect;
-Forces the timezone to GMT
-it returns a database handle.
+connect takes a hashref and passes it off to SUPER::connect; Forces
+the timezone to GMT, returns a database handle.
 
 =cut
 
@@ -46,11 +42,11 @@
 
 =head2 insert
 
-Takes a table name as the first argument and assumes that the rest of the arguments
-are an array of key-value pairs to be inserted.
+Takes a table name as the first argument and assumes that the rest of
+the arguments are an array of key-value pairs to be inserted.
 
-In case of isnert failure, returns a Class::ReturnValue object preloaded
-with error info
+In case of isnert failure, returns a L<Class::ReturnValue> object
+preloaded with error info
 
 =cut
 
@@ -81,7 +77,8 @@
 
 =head2 binary_safe_blobs
 
-Return undef, as no current version of postgres supports binary-safe blobs
+Return undef, as no current version of postgres supports binary-safe
+blobs
 
 =cut
 
@@ -92,8 +89,8 @@
 
 =head2 apply_limits STATEMENTREF ROWS_PER_PAGE FIRST_ROW
 
-takes an SQL SELECT statement and massages it to return ROWS_PER_PAGE starting with FIRST_ROW;
-
+takes an SQL SELECT statement and massages it to return ROWS_PER_PAGE
+starting with FIRST_ROW;
 
 =cut
 
@@ -166,7 +163,7 @@
 
 =head1 SEE ALSO
 
-Jifty::DBI, Jifty::DBI::Handle
+L<Jifty::DBI>, L<Jifty::DBI::Handle>, L<DBD::Pg>
 
 =cut
 

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Sybase.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Sybase.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle/Sybase.pm	Mon Jul 25 21:36:24 2005
@@ -1,5 +1,3 @@
-# $Header: /home/jesse/DBIx-SearchBuilder/history/SearchBuilder/Handle/Sybase.pm,v 1.8 2001/10/12 05:27:05 jesse Exp $
-
 package Jifty::DBI::Handle::Sybase;
 use Jifty::DBI::Handle;
 @ISA = qw(Jifty::DBI::Handle);
@@ -13,23 +11,20 @@
 
 =head1 SYNOPSIS
 
-
 =head1 DESCRIPTION
 
-This module provides a subclass of Jifty::DBI::Handle that 
+This module provides a subclass of L<Jifty::DBI::Handle> that
 compensates for some of the idiosyncrasies of Sybase.
 
 =head1 METHODS
 
-=cut
-
 =head2 insert
 
-Takes a table name as the first argument and assumes that the rest of the arguments
-are an array of key-value pairs to be inserted.
+Takes a table name as the first argument and assumes that the rest of
+the arguments are an array of key-value pairs to be inserted.
 
-If the insert succeeds, returns the id of the insert, otherwise, returns
-a Class::ReturnValue object with the error reported.
+If the insert succeeds, returns the id of the insert, otherwise,
+returns a L<Class::ReturnValue> object with the error reported.
 
 =cut
 
@@ -90,8 +85,10 @@
 
 }
 
-=head2 distinct_query STATEMENTREFtakes an incomplete SQL SELECT statement and massages it to return a DISTINCT result set.
+=head2 distinct_query STATEMENTREF
 
+Takes an incomplete SQL SELECT statement and massages it to return a
+DISTINCT result set.
 
 =cut
 
@@ -129,6 +126,6 @@
 
 =head1 SEE ALSO
 
-Jifty::DBI, Jifty::DBI::Handle
+L<Jifty::DBI>, L<Jifty::DBI::Handle>, L<DBD::Sybase>
 
 =cut

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Handle/mysql.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Handle/mysql.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Handle/mysql.pm	Mon Jul 25 21:36:24 2005
@@ -1,5 +1,3 @@
-# $Header: /home/jesse/DBIx-SearchBuilder/history/SearchBuilder/Handle/mysql.pm,v 1.8 2001/10/12 05:27:05 jesse Exp $
-
 package Jifty::DBI::Handle::mysql;
 use Jifty::DBI::Handle;
 @ISA = qw(Jifty::DBI::Handle);
@@ -16,7 +14,7 @@
 
 =head1 DESCRIPTION
 
-This module provides a subclass of Jifty::DBI::Handle that 
+This module provides a subclass of L<Jifty::DBI::Handle> that
 compensates for some of the idiosyncrasies of MySQL.
 
 =head1 METHODS
@@ -25,10 +23,11 @@
 
 =head2 insert
 
-Takes a table name as the first argument and assumes that the rest of the arguments are an array of key-value pairs to be inserted.
+Takes a table name as the first argument and assumes that the rest of
+the arguments are an array of key-value pairs to be inserted.
 
-If the insert succeeds, returns the id of the insert, otherwise, returns
-a Class::ReturnValue object with the error reported.
+If the insert succeeds, returns the id of the insert, otherwise,
+returns a L<Class::ReturnValue> object with the error reported.
 
 =cut
 
@@ -86,7 +85,7 @@
 
 =head1 SEE ALSO
 
-Jifty::DBI, Jifty::DBI::Handle
+L<Jifty::DBI>, L<Jifty::DBI::Handle>, L<DBD::mysql>
 
 =cut
 

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm	Mon Jul 25 21:36:24 2005
@@ -1,4 +1,3 @@
-#$Header/cvsroot/DBIx/DBIx-SearchBuilder/SearchBuilder/Record.pm,v 1.21 2001/02/28 21:36:27 jesse Exp $
 package Jifty::DBI::Record;
 
 use strict;
@@ -9,7 +8,7 @@
 
 =head1 NAME
 
-Jifty::DBI::Record - Superclass for records loaded by SearchBuilder
+Jifty::DBI::Record - Superclass for records loaded by Jifty::DBI::Collection
 
 =head1 SYNOPSIS
 
@@ -245,11 +244,12 @@
   011: 
   012: $s->load_by_id(1); 
 
-load_by_id is one of four 'LoadBy' methods,  as the name suggests it searches
-for an row in the database that has id='0'.  ::SearchBuilder has, what I 
-think is a bug, in that it current requires there to be an id field. More 
-reasonably it also assumes that the id field is unique. load_by_id($id) will 
-do undefined things if there is >1 row with the same id.  
+load_by_id is one of four 'load_by_*' methods, as the name suggests it
+searches for an row in the database that has id='0'.  This causes,
+what I think is a bug, in that it current requires there to be an id
+field. More reasonably it also assumes that the id field is
+unique. load_by_id($id) will do undefined things if there is >1 row
+with the same id.
 
 In addition to load_by_id, we also have:
 
@@ -333,15 +333,8 @@
 this HowTo to discuss using container classes,  overloading, and what 
 ever else I think of.
 
-=head1 METHOD NAMING
- 
-Each method has a lower case alias; '_' is used to separate words.
-For example, the method C<_primary_keys> has the alias C<_primary_keys>.
-
 =head1 METHODS
 
-=cut
-
 =head2  new 
 
 Instantiate a new record object.
@@ -892,10 +885,11 @@
 
 =head2 truncate_value  KEY VALUE
 
-Truncate a value that's about to be set so that it will fit inside the database'
-s idea of how big the column is. 
+Truncate a value that's about to be set so that it will fit inside the
+database' s idea of how big the column is.
 
-(Actually, it looks at SearchBuilder's concept of the database, not directly into the db).
+(Actually, it looks at L<Jifty::DBI>'s concept of the database, not
+directly into the db).
 
 =cut
 

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Record/Cachable.pm	Mon Jul 25 21:36:24 2005
@@ -1,6 +1,3 @@
-# $Header: /home/jesse/DBIx-SearchBuilder/history/SearchBuilder/Record/Cachable.pm,v 1.6 2001/06/19 04:22:32 jesse Exp $
-# by Matt Knopp <mhat at netlag.com>
-
 package Jifty::DBI::Record::Cachable;
 
 use Jifty::DBI::Record;
@@ -22,9 +19,12 @@
 
 =head1 DESCRIPTION
 
-This module subclasses the main Jifty::DBI::Record package to add a caching layer. 
+This module subclasses the main L<Jifty::DBI::Record> package to add a
+caching layer.
 
-The public interface remains the same, except that records which have been loaded in the last few seconds may be reused by subsequent fetch or load methods without retrieving them from the database.
+The public interface remains the same, except that records which have
+been loaded in the last few seconds may be reused by subsequent fetch
+or load methods without retrieving them from the database.
 
 =head1 METHODS
 
@@ -95,11 +95,6 @@
 
 }
 
-# Function: LoadFromHash
-# Type    : (overloaded) public instance
-# Args    : See Jifty::DBI::Record::LoadFromHash
-# Lvalue  : array(boolean, message)
-
 sub load_from_hash {
     my $self = shift;
 
@@ -117,11 +112,6 @@
     return ( $rvalue, $msg );
 }
 
-# Function: LoadByCols
-# Type    : (overloaded) public instance
-# Args    : see Jifty::DBI::Record::LoadByCols
-# Lvalue  : array(boolean, message)
-
 sub load_by_cols {
     my ( $self, %attr ) = @_;
 
@@ -325,13 +315,15 @@
 
 }
 
-=head2 _CacheConfig 
+=head2 _cache_config 
 
-You can override this method to change the duration of the caching from the default of 5 seconds. 
+You can override this method to change the duration of the caching
+from the default of 5 seconds.
 
-For example, to cache records for up to 30 seconds, add the following method to your class:
+For example, to cache records for up to 30 seconds, add the following
+method to your class:
 
-  sub _CacheConfig {
+  sub _cache_config {
       { 'cache_for_sec' => 30 }
   }
 

Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Union.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Union.pm	(original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Union.pm	Mon Jul 25 21:36:24 2005
@@ -14,7 +14,8 @@
 
 =head1 NAME
 
-Jifty::DBI::Union - Deal with multiple SearchBuilder result sets as one
+Jifty::DBI::Union - Deal with multiple L<Jifty::DBI::Collection>
+result sets as one
 
 =head1 SYNOPSIS
 
@@ -34,7 +35,7 @@
 
 =head1 DESCRIPTION
 
-Implements a subset of the Jifty::DBI collection methods, but
+Implements a subset of the L<Jifty::DBI::Collection> methods, but
 enough to do iteration over a bunch of results.  Useful for displaying
 the results of two unrelated searches (for the same kind of objects)
 in a single list.
@@ -43,7 +44,7 @@
 
 =head2 new
 
-Create a new Jifty::DBI::Union object.  No arguments.
+Create a new L<Jifty::DBI::Union> object.  No arguments.
 
 =cut
 
@@ -57,9 +58,10 @@
         shift;
 }
 
-=head2 add $sb
+=head2 add COLLECTION
 
-Add a searchbuilder result (collection) to the Union object.
+Add L<Jifty::DBI::Collection> object I<COLLECTION> to the Union
+object.
 
 It must be the same type as the first object added.
 
@@ -81,7 +83,7 @@
     push @{ $self->{data} }, $newobj;
 }
 
-=head2 First
+=head2 first
 
 Return the very first element of the Union (which is the first element
 of the first Collection).  Also reset the current pointer to that
@@ -89,7 +91,7 @@
 
 =cut
 
-sub First {
+sub first {
     my $self = shift;
 
     die "No elements in Jifty::DBI::Union"
@@ -100,77 +102,77 @@
     $self->{data}[0]->First;
 }
 
-=head2 Next
+=head2 next
 
 Return the next element in the Union.
 
 =cut
 
-sub Next {
+sub next {
     my $self = shift;
 
     return undef unless defined $self->{data}[ $self->{curp} ];
 
     my $cur = $self->{data}[ $self->{curp} ];
-    if ( $cur->_ItemsCounter == $cur->Count ) {
+    if ( $cur->_items_counter == $cur->count ) {
 
         # move to the next element
         $self->{curp}++;
         return undef unless defined $self->{data}[ $self->{curp} ];
         $cur = $self->{data}[ $self->{curp} ];
-        $self->{data}[ $self->{curp} ]->GotoFirstItem;
+        $self->{data}[ $self->{curp} ]->goto_first_item;
     }
     $self->{item}++;
-    $cur->Next;
+    $cur->next;
 }
 
-=head2 Last
+=head2 last
 
 Returns the last item
 
 =cut
 
-sub Last {
+sub last {
     die "Last doesn't work right now";
     my $self = shift;
-    $self->GotoItem( ( $self->Count ) - 1 );
-    return ( $self->Next );
+    $self->goto_item( ( $self->count ) - 1 );
+    return ( $self->next );
 }
 
-=head2 Count
+=head2 count
 
 Returns the total number of elements in the Union'ed Collection
 
 =cut
 
-sub Count {
+sub count {
     my $self = shift;
     my $sum  = 0;
 
     # cache the results
     return $self->{count} if defined $self->{count};
 
-    $sum += $_->Count for ( @{ $self->{data} } );
+    $sum += $_->count for ( @{ $self->{data} } );
 
     $self->{count} = $sum;
 
     return $sum;
 }
 
-=head2 GotoFirstItem
+=head2 goto_first_item
 
 Starts the recordset counter over from the first item. the next time
-you call Next, you'll get the first item returned by the database, as
-if you'd just started iterating through the result set.
+you call L</next>, you'll get the first item returned by the database,
+as if you'd just started iterating through the result set.
 
 =cut
 
-sub GotoFirstItem {
+sub goto_first_item {
     my $self = shift;
-    $self->GotoItem(0);
+    $self->goto_item(0);
 }
 
-sub GotoItem {
+sub goto_item {
     my $self = shift;
     my $item = shift;
 
@@ -179,24 +181,24 @@
 
     $self->{curp} = 0;
     $self->{item} = 0;
-    $self->{data}[0]->GotoItem(0);
+    $self->{data}[0]->goto_item(0);
 
     return $item;
 }
 
-=head2 IsLast
+=head2 is_last
 
 Returns true if the current row is the last record in the set.
 
 =cut
 
-sub IsLast {
+sub is_last {
     my $self = shift;
 
-    $self->{item} == $self->Count ? 1 : undef;
+    $self->{item} == $self->count ? 1 : undef;
 }
 
-=head2 ItemsArrayRef
+=head2 items_array_ref
 
 Return a refernece to an array containing all objects found by this search.
 
@@ -204,14 +206,14 @@
 
 =cut
 
-sub ItemsArrayRef {
+sub items_array_ref {
     my $self = shift;
 
-    return [] unless $self->Count;
+    return [] unless $self->count;
 
-    $self->GotoFirstItem();
+    $self->goto_first_item();
     my @ret;
-    while ( my $r = $self->Next ) {
+    while ( my $r = $self->next ) {
         push @ret, $r;
     }
 
@@ -229,7 +231,7 @@
 
 =head1 SEE ALSO
 
-Jifty::DBI
+L<Jifty::DBI>, L<Jifty::DBI::Collection>
 
 =cut
 

Modified: Jifty-DBI/trunk/t/01records.t
==============================================================================
--- Jifty-DBI/trunk/t/01records.t	(original)
+++ Jifty-DBI/trunk/t/01records.t	Mon Jul 25 21:36:24 2005
@@ -32,7 +32,7 @@
 	my $rec = TestApp::Address->new($handle);
 	isa_ok($rec, 'Jifty::DBI::Record');
 
-# _Accessible testings
+# _accessible testings
 	is( $rec->_accessible('id' => 'read'), 1, 'id is accessible for read' );
 	is( $rec->_accessible('id' => 'write'), undef, 'id is not accessible for write' );
 	is( $rec->_accessible('id'), undef, "any field is not accessible in undefined mode" );
@@ -107,20 +107,20 @@
 	is($newrec->name, '12345678901234', "Truncated on create");
 	is($newrec->employee_id, '1234567890', "Did not truncate id on create");
 
-# no prefetch feature and _LoadFromSQL sub checks
+# no prefetch feature and _load_from_sql sub checks
 	$newrec = TestApp::Address->new($handle);
 	($val, $msg) = $newrec->_load_from_sql('SELECT id FROM address WHERE id = ?', $newid);
 	is($val, 1, 'found object');
 	is($newrec->name, '12345678901234', "autoloaded not prefetched field");
 	is($newrec->employee_id, '1234567890', "autoloaded not prefetched field");
 
-# _LoadFromSQL and missing PK
+# _load_from_sql and missing PK
 	$newrec = TestApp::Address->new($handle);
 	($val, $msg) = $newrec->_load_from_sql('SELECT name FROM address WHERE name = ?', '12345678901234');
 	is($val, 0, "didn't find object");
 	is($msg, "Missing a primary key?", "reason is missing PK");
 
-# _LoadFromSQL and not existant row
+# _load_from_sql and not existant row
 	$newrec = TestApp::Address->new($handle);
 	($val, $msg) = $newrec->_load_from_sql('SELECT id FROM address WHERE id = ?', 0);
 	is($val, 0, "didn't find object");
@@ -135,7 +135,7 @@
 	is($val, 0, "didn't find object");
 	is($msg, "Couldn't execute query", "reason is bad SQL");
 
-# test Load* methods
+# test load_* methods
 	$newrec = TestApp::Address->new($handle);
 	$newrec->load();
 	is( $newrec->id, undef, "can't load record with undef id");
@@ -144,13 +144,13 @@
 	$newrec->load_by_col( name => '12345678901234' );
 	is( $newrec->id, $newid, "load record by 'name' column value");
 
-# LoadByCol with operator
+# load_by_col with operator
 	$newrec = TestApp::Address->new($handle);
 	$newrec->load_by_col( name => { value => '%45678%',
 				      operator => 'LIKE' } );
 	is( $newrec->id, $newid, "load record by 'name' with LIKE");
 
-# LoadByPrimaryKeys
+# load_by_primary_keys
 	$newrec = TestApp::Address->new($handle);
 	($val, $msg) = $newrec->load_by_primary_keys( id => $newid );
 	ok( $val, "load record by PK");
@@ -164,7 +164,7 @@
 	ok( !$val, "couldn't load, missing PK field");
 	is( $msg, "Missing PK field: 'id'", "right error message" );
 
-# LoadByCols and empty or NULL values
+# load_by_cols and empty or NULL values
 	$rec = TestApp::Address->new($handle);
 	$id = $rec->create( name => 'Obra', phone => undef );
 	ok( $id, "new record");
@@ -172,7 +172,7 @@
 	$rec->load_by_cols( name => 'Obra', phone => undef, employee_id => '' );
     is( $rec->id, $id, "loaded record by empty value" );
 
-# __Set error paths
+# __set error paths
 	$rec = TestApp::Address->new($handle);
 	$rec->load( $id );
 	$val = $rec->set_name( 'Obra' );

Modified: Jifty-DBI/trunk/t/01searches.t
==============================================================================
--- Jifty-DBI/trunk/t/01searches.t	(original)
+++ Jifty-DBI/trunk/t/01searches.t	Mon Jul 25 21:36:24 2005
@@ -41,12 +41,12 @@
 	is( $users_obj->count, 0, 'count returns 0 on not limited obj' );
 	is( $users_obj->is_last, undef, 'is_last returns undef on not limited obj after count' );
 	is( $users_obj->first, undef, 'first returns undef on not limited obj' );
-	is( $users_obj->is_last, undef, 'is_last returns undef on not limited obj after First' );
+	is( $users_obj->is_last, undef, 'is_last returns undef on not limited obj after first' );
 	is( $users_obj->last, undef, 'last returns undef on not limited obj' );
-	is( $users_obj->is_last, undef, 'is_last returns undef on not limited obj after Last' );
+	is( $users_obj->is_last, undef, 'is_last returns undef on not limited obj after last' );
 	$users_obj->goto_first_item;
 	is( $users_obj->next, undef, 'next returns undef on not limited obj' );
-	is( $users_obj->is_last, undef, 'is_last returns undef on not limited obj after Next' );
+	is( $users_obj->is_last, undef, 'is_last returns undef on not limited obj after next' );
 	# XXX TODO FIXME: may be this methods should be implemented
 	# $users_obj->goto_last_item;
 	# is( $users_obj->prev, undef, 'prev returns undef on not limited obj' );

Modified: Jifty-DBI/trunk/t/11schema_records.t
==============================================================================
--- Jifty-DBI/trunk/t/11schema_records.t	(original)
+++ Jifty-DBI/trunk/t/11schema_records.t	Mon Jul 25 21:36:24 2005
@@ -40,7 +40,7 @@
 	isa_ok($phone_collection, 'TestApp::PhoneCollection');
 	
 	{
-	    my $ph = $phone_collection->Next;
+	    my $ph = $phone_collection->next;
 	    is($ph, undef, "No phones yet");
 	}
 	


More information about the Rt-commit mailing list