[Bps-public-commit] dbix-searchbuilder branch master updated. 1.71-28-gdbdf928

BPS Git Server git at git.bestpractical.com
Thu Dec 8 18:45:09 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "dbix-searchbuilder".

The branch, master has been updated
       via  dbdf928321ede1e4eca425d0eb9fd8ef17b915f5 (commit)
       via  d5a790776fbb68539ae0f0a46d30d8fd4b2d806a (commit)
       via  b31eec67d336aa1b8f697a4c3c79e770c2fd4dbd (commit)
      from  203f48d152934b8d278bbe8de42439e34d5ea8d3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit dbdf928321ede1e4eca425d0eb9fd8ef17b915f5
Merge: 203f48d d5a7907
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Thu Dec 8 13:44:53 2022 -0500

    Merge branch 'misc-cleanup'


commit d5a790776fbb68539ae0f0a46d30d8fd4b2d806a
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Apr 25 12:34:10 2014 -0400

    Remove CVS headers

diff --git a/lib/DBIx/SearchBuilder/Handle.pm b/lib/DBIx/SearchBuilder/Handle.pm
index 249cbf1..7a25876 100755
--- a/lib/DBIx/SearchBuilder/Handle.pm
+++ b/lib/DBIx/SearchBuilder/Handle.pm
@@ -1,4 +1,3 @@
-# $Header: /home/jesse/DBIx-SearchBuilder/history/SearchBuilder/Handle.pm,v 1.21 2002/01/28 06:11:37 jesse Exp $
 package DBIx::SearchBuilder::Handle;
 
 use strict;
diff --git a/lib/DBIx/SearchBuilder/Handle/Informix.pm b/lib/DBIx/SearchBuilder/Handle/Informix.pm
index a9c3209..31e5241 100644
--- a/lib/DBIx/SearchBuilder/Handle/Informix.pm
+++ b/lib/DBIx/SearchBuilder/Handle/Informix.pm
@@ -1,5 +1,3 @@
-# $Header:  $
-
 package DBIx::SearchBuilder::Handle::Informix;
 
 use strict;
diff --git a/lib/DBIx/SearchBuilder/Handle/ODBC.pm b/lib/DBIx/SearchBuilder/Handle/ODBC.pm
index 4801a01..ae0617d 100644
--- a/lib/DBIx/SearchBuilder/Handle/ODBC.pm
+++ b/lib/DBIx/SearchBuilder/Handle/ODBC.pm
@@ -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 DBIx::SearchBuilder::Handle::ODBC;
 
 use strict;
diff --git a/lib/DBIx/SearchBuilder/Handle/Oracle.pm b/lib/DBIx/SearchBuilder/Handle/Oracle.pm
index 8025c5e..b848f10 100755
--- a/lib/DBIx/SearchBuilder/Handle/Oracle.pm
+++ b/lib/DBIx/SearchBuilder/Handle/Oracle.pm
@@ -1,5 +1,3 @@
-# $Header: /home/jesse/DBIx-SearchBuilder/history/SearchBuilder/Handle/Oracle.pm,v 1.14 2002/01/28 06:11:37 jesse Exp $
-
 package DBIx::SearchBuilder::Handle::Oracle;
 
 use strict;
diff --git a/lib/DBIx/SearchBuilder/Handle/Pg.pm b/lib/DBIx/SearchBuilder/Handle/Pg.pm
index c09259b..34ad424 100755
--- a/lib/DBIx/SearchBuilder/Handle/Pg.pm
+++ b/lib/DBIx/SearchBuilder/Handle/Pg.pm
@@ -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 DBIx::SearchBuilder::Handle::Pg;
 
 use strict;
@@ -367,6 +364,10 @@ sub HasSupportForNullsOrder {
 
 __END__
 
+=head1 AUTHOR
+
+Jesse Vincent, jesse at fsck.com
+
 =head1 SEE ALSO
 
 DBIx::SearchBuilder, DBIx::SearchBuilder::Handle
diff --git a/lib/DBIx/SearchBuilder/Handle/Sybase.pm b/lib/DBIx/SearchBuilder/Handle/Sybase.pm
index 1561d33..c777993 100644
--- a/lib/DBIx/SearchBuilder/Handle/Sybase.pm
+++ b/lib/DBIx/SearchBuilder/Handle/Sybase.pm
@@ -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 DBIx::SearchBuilder::Handle::Sybase;
 
 use strict;
diff --git a/lib/DBIx/SearchBuilder/Handle/mysql.pm b/lib/DBIx/SearchBuilder/Handle/mysql.pm
index 2548a94..b89db19 100755
--- a/lib/DBIx/SearchBuilder/Handle/mysql.pm
+++ b/lib/DBIx/SearchBuilder/Handle/mysql.pm
@@ -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 DBIx::SearchBuilder::Handle::mysql;
 
 use strict;
diff --git a/lib/DBIx/SearchBuilder/Record/Cachable.pm b/lib/DBIx/SearchBuilder/Record/Cachable.pm
index 94ea1a7..4ac4565 100755
--- a/lib/DBIx/SearchBuilder/Record/Cachable.pm
+++ b/lib/DBIx/SearchBuilder/Record/Cachable.pm
@@ -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 DBIx::SearchBuilder::Record::Cachable;
 
 use strict;

commit b31eec67d336aa1b8f697a4c3c79e770c2fd4dbd
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Apr 25 12:14:04 2014 -0400

    Whitespace cleanup

diff --git a/lib/DBIx/SearchBuilder.pm b/lib/DBIx/SearchBuilder.pm
index 4287022..ccc82a0 100755
--- a/lib/DBIx/SearchBuilder.pm
+++ b/lib/DBIx/SearchBuilder.pm
@@ -19,22 +19,22 @@ DBIx::SearchBuilder - Encapsulate SQL queries and rows in simple perl objects
 =head1 SYNOPSIS
 
   use DBIx::SearchBuilder;
-  
+
   package My::Things;
   use base qw/DBIx::SearchBuilder/;
-  
+
   sub _Init {
       my $self = shift;
       $self->Table('Things');
       return $self->SUPER::_Init(@_);
   }
-  
+
   sub NewItem {
       my $self = shift;
       # MyThing is a subclass of DBIx::SearchBuilder::Record
       return(MyThing->new);
   }
-  
+
   package main;
 
   use DBIx::SearchBuilder::Handle;
@@ -51,9 +51,9 @@ DBIx::SearchBuilder - Encapsulate SQL queries and rows in simple perl objects
 
 =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<DBIx::SearchBuilder> and a 
+In order to use this module, you should create a subclass of C<DBIx::SearchBuilder> and a
 subclass of C<DBIx::SearchBuilder::Record> for each table that you wish to access.  (See
 the documentation of C<DBIx::SearchBuilder::Record> for more information on subclassing it.)
 
@@ -101,7 +101,7 @@ sub new {
 
 =head2 _Init
 
-This method is called by C<new> with whatever arguments were passed to C<new>.  
+This method is called by C<new> with whatever arguments were passed to C<new>.
 By default, it takes a C<DBIx::SearchBuilder::Handle> object as a C<Handle>
 argument, although this is not necessary if your subclass overrides C<_Handle>.
 
@@ -178,7 +178,7 @@ sub Clone
     );
     $obj->{'must_redo_search'} = 1;
     $obj->{'itemscount'}       = 0;
-    
+
     $obj->{ $_ } = Clone::clone( $obj->{ $_ } )
         foreach grep exists $self->{ $_ }, $self->_ClonedAttributes;
     return $obj;
@@ -256,10 +256,12 @@ sub __DoSearch {
     return 0 unless $records;
 
     while ( my $row = $records->fetchrow_hashref() ) {
+
         # search_builder_count_all is from combine search
         if ( !$self->{count_all} && $row->{search_builder_count_all} ) {
             $self->{count_all} = $row->{search_builder_count_all};
         }
+
         my $item = $self->NewItem();
         $item->LoadFromHash($row);
         $self->AddRecord($item);
@@ -347,7 +349,7 @@ sub _DoSearchAndCount {
 
 =head2 _ApplyLimits STATEMENTREF
 
-This routine takes a reference to a scalar containing an SQL statement. 
+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->RowsPerPage >>
 rows, skipping C<< $self->FirstRow >> rows.  (That is, if rows are numbered
 starting from 0, row number C<< $self->FirstRow >> will be the first row returned.)
@@ -362,13 +364,13 @@ sub _ApplyLimits {
     my $statementref = shift;
     $self->_Handle->ApplyLimits($statementref, $self->RowsPerPage, $self->FirstRow, $self);
     $$statementref =~ s/main\.\*/join(', ', @{$self->{columns}})/eg
-	    if $self->{columns} and @{$self->{columns}};
+        if $self->{columns} and @{$self->{columns}};
 }
 
 
 =head2 _DistinctQuery STATEMENTREF
 
-This routine takes a reference to a scalar containing an SQL statement. 
+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
@@ -406,12 +408,11 @@ Build up all of the joins we need to perform this query.
 sub _BuildJoins {
     my $self = shift;
 
-        return ( $self->_Handle->_BuildJoins($self) );
-
+    return ( $self->_Handle->_BuildJoins($self) );
 }
 
 
-=head2 _isJoined 
+=head2 _isJoined
 
 Returns true if this SearchBuilder will be joining multiple tables together.
 
@@ -495,7 +496,7 @@ sub BuildSelectQuery {
 
     my $QueryString = $self->_BuildJoins . " ";
     $QueryString .= $self->_WhereClause . " "
-      if ( $self->_isLimited > 0 );
+        if ( $self->_isLimited > 0 );
 
     $self->_OptimizeQuery(\$QueryString, @_);
 
@@ -540,7 +541,7 @@ sub BuildSelectCountQuery {
     my $QueryString = $self->_BuildJoins . " ";
 
     $QueryString .= $self->_WhereClause . " "
-      if ( $self->_isLimited > 0 );
+        if ( $self->_isLimited > 0 );
 
     $self->_OptimizeQuery(\$QueryString, @_);
 
@@ -772,7 +773,7 @@ sub ItemsArrayRef {
 
 =head2 NewItem
 
-NewItem must be subclassed. It is used by DBIx::SearchBuilder to create record 
+NewItem must be subclassed. It is used by DBIx::SearchBuilder to create record
 objects for each row returned from the database.
 
 =cut
@@ -840,10 +841,10 @@ Limit takes a hash of parameters with the following keys:
 
 =over 4
 
-=item TABLE 
+=item TABLE
 
 Can be set to something different than this table if a join is
-wanted (that means we can't do recursive joins as for now).  
+wanted (that means we can't do recursive joins as for now).
 
 =item ALIAS
 
@@ -870,7 +871,7 @@ check. See L</CombineFunctionWithField> for rules.
 
 =item VALUE
 
-Should always be set and will always be quoted. 
+Should always be set and will always be quoted.
 
 =item OPERATOR
 
@@ -914,7 +915,7 @@ and first column is used.
 
 =back
 
-=item ENTRYAGGREGATOR 
+=item ENTRYAGGREGATOR
 
 Can be C<AND> or C<OR> (or anything else valid to aggregate two clauses in SQL).
 Special value is C<none> which means that no entry aggregator should be used.
@@ -1104,7 +1105,7 @@ sub _GenericRestriction {
     my $restriction;
     if ( $args{'LEFTJOIN'} ) {
         if ( $args{'ENTRYAGGREGATOR'} ) {
-            $self->{'left_joins'}{ $args{'LEFTJOIN'} }{'entry_aggregator'} = 
+            $self->{'left_joins'}{ $args{'LEFTJOIN'} }{'entry_aggregator'} =
                 $args{'ENTRYAGGREGATOR'};
         }
         $restriction = $self->{'left_joins'}{ $args{'LEFTJOIN'} }{'criteria'}{ $ClauseId } ||= [];
@@ -1225,7 +1226,7 @@ sub _CompileGenericRestrictions {
 
 Orders the returned results by ALIAS.FIELD ORDER.
 
-Takes a paramhash of ALIAS, FIELD and ORDER.  
+Takes a paramhash of ALIAS, FIELD and ORDER.
 ALIAS defaults to C<main>.
 FIELD has no default value.
 ORDER defaults to ASC(ending). DESC(ending) is also a valid value for OrderBy.
@@ -1275,29 +1276,29 @@ sub _OrderClause {
     foreach my $row ( @{$self->{'order_by'}} ) {
 
         my %rowhash = ( ALIAS => 'main',
-			FIELD => undef,
-			ORDER => 'ASC',
-			%$row
-		      );
+                        FIELD => undef,
+                        ORDER => 'ASC',
+                        %$row
+                      );
         if ($rowhash{'ORDER'} && $rowhash{'ORDER'} =~ /^des/i) {
-	    $rowhash{'ORDER'} = "DESC";
+            $rowhash{'ORDER'} = "DESC";
             $rowhash{'ORDER'} .= ' '. $nulls_order->{'DESC'} if $nulls_order;
         }
         else {
-	    $rowhash{'ORDER'} = "ASC";
+            $rowhash{'ORDER'} = "ASC";
             $rowhash{'ORDER'} .= ' '. $nulls_order->{'ASC'} if $nulls_order;
         }
         $rowhash{'ALIAS'} = 'main' unless defined $rowhash{'ALIAS'};
 
         if ( defined $rowhash{'ALIAS'} and
-	     $rowhash{'FIELD'} and
+             $rowhash{'FIELD'} and
              $rowhash{'ORDER'} ) {
 
-	    if ( length $rowhash{'ALIAS'} && $rowhash{'FIELD'} =~ /^(.*\()(.*\))$/ ) {
-		# handle 'FUNCTION(FIELD)' formatted fields
-		$rowhash{'ALIAS'} = $1 . $rowhash{'ALIAS'};
-		$rowhash{'FIELD'} = $2;
-	    }
+            if ( length $rowhash{'ALIAS'} && $rowhash{'FIELD'} =~ /^(.*\()(.*\))$/ ) {
+                # handle 'FUNCTION(FIELD)' formatted fields
+                $rowhash{'ALIAS'} = $1 . $rowhash{'ALIAS'};
+                $rowhash{'FIELD'} = $2;
+            }
 
             $clause .= ($clause ? ", " : " ");
             $clause .= $rowhash{'ALIAS'} . "." if length $rowhash{'ALIAS'};
@@ -1422,11 +1423,11 @@ sub _GetAlias {
 
 =head2 Join
 
-Join instructs DBIx::SearchBuilder to join two tables.  
+Join instructs DBIx::SearchBuilder to join two tables.
 
-The standard form takes a param hash with keys ALIAS1, FIELD1, ALIAS2 and 
+The standard form takes a param hash with keys ALIAS1, FIELD1, ALIAS2 and
 FIELD2. ALIAS1 and ALIAS2 are column aliases obtained from $self->NewAlias or
-a $self->Limit. FIELD1 and FIELD2 are the fields in ALIAS1 and ALIAS2 that 
+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.
 
@@ -1598,7 +1599,7 @@ L</CountAll>.
 sub Count {
     my $self = shift;
 
-    # An unlimited search returns no tickets    
+    # An unlimited search returns no tickets
     return 0 unless ($self->_isLimited);
 
     if ( $self->{'must_redo_search'} ) {
@@ -1626,7 +1627,7 @@ L</RowsPerPage> settings.
 sub CountAll {
     my $self = shift;
 
-    # An unlimited search returns no tickets    
+    # An unlimited search returns no tickets
     return 0 unless ($self->_isLimited);
 
     # If we haven't actually got all objects loaded in memory, we
@@ -1639,7 +1640,7 @@ sub CountAll {
         #Report back the raw # of rows in the database
         return ( $self->{'count_all'} );
     }
-    
+
     # if we have paging enabled and have count_all then return it
     elsif ( $self->RowsPerPage ) {
         return ( $self->{'count_all'} );
@@ -2032,7 +2033,7 @@ sub DEBUG { warn "DEBUG is deprecated" }
 
 
 if( eval { require capitalization } ) {
-	capitalization->unimport( __PACKAGE__ );
+    capitalization->unimport( __PACKAGE__ );
 }
 
 1;
diff --git a/lib/DBIx/SearchBuilder/Handle.pm b/lib/DBIx/SearchBuilder/Handle.pm
index 33a4f60..249cbf1 100755
--- a/lib/DBIx/SearchBuilder/Handle.pm
+++ b/lib/DBIx/SearchBuilder/Handle.pm
@@ -28,12 +28,12 @@ DBIx::SearchBuilder::Handle - Perl extension which is a generic DBI handle
                     Host => 'hostname',
                     User => 'dbuser',
                     Password => 'dbpassword');
-  # now $handle isa DBIx::SearchBuilder::Handle::mysql                    
- 
+  # now $handle isa DBIx::SearchBuilder::Handle::mysql
+
 =head1 DESCRIPTION
 
 This class provides a wrapper for DBI handles that can also perform a number of additional functions.
- 
+
 =cut
 
 
@@ -62,15 +62,15 @@ sub new  {
 
 =head2 Connect PARAMHASH: Driver, Database, Host, User, Password, QuoteTableNames
 
-Takes a paramhash and connects to your DBI datasource. 
+Takes a paramhash and connects to your DBI datasource.
 
 You should _always_ set
 
-     DisconnectHandleOnDestroy => 1 
+     DisconnectHandleOnDestroy => 1
 
 unless you have a legacy app like RT2 or RT 3.0.{0,1,2} that depends on the broken behaviour.
 
-If you created the handle with 
+If you created the handle with
      DBIx::SearchBuilder::Handle->new
 and there is a DBIx::SearchBuilder::Handle::(Driver) subclass for the driver you have chosen,
 the handle will be automatically "upgraded" into that subclass.
@@ -143,7 +143,7 @@ of the standard driver-specific subclasses.
 
 sub _UpgradeHandle {
     my $self = shift;
-    
+
     my $driver = shift;
     my $class = 'DBIx::SearchBuilder::Handle::' . $driver;
     local $@;
@@ -157,7 +157,7 @@ sub _UpgradeHandle {
 
 =head2 BuildDSN PARAMHASH
 
-Takes a bunch of parameters:  
+Takes a bunch of parameters:
 
 Required: Driver, Database,
 Optional: Host, Port and RequireSSL
@@ -209,7 +209,7 @@ Turns on the Database Handle's RaiseError attribute.
 sub RaiseError {
     my $self = shift;
 
-    my $mode = 1; 
+    my $mode = 1;
     $mode = shift if (@_);
 
     $self->dbh->{RaiseError}=$mode;
@@ -227,7 +227,7 @@ Turns on the Database Handle's PrintError attribute.
 sub PrintError {
     my $self = shift;
 
-    my $mode = 1; 
+    my $mode = 1;
     $mode = shift if (@_);
 
     $self->dbh->{PrintError}=$mode;
@@ -270,7 +270,7 @@ sub _LogSQLStatement {
 
 =head2 ClearSQLStatementLog
 
-Clears out the SQL statement log. 
+Clears out the SQL statement log.
 
 
 =cut
@@ -278,12 +278,12 @@ Clears out the SQL statement log.
 sub ClearSQLStatementLog {
     my $self = shift;
     @{$self->{'StatementLog'}} = ();
-}   
+}
 
 
 =head2 SQLStatementLog
 
-Returns the current SQL statement log as an array of arrays. Each entry is a triple of 
+Returns the current SQL statement log as an array of arrays. Each entry is a triple of
 
 (Time,  Statement, Duration)
 
@@ -306,7 +306,7 @@ Turns on the Database Handle's AutoCommit attribute.
 sub AutoCommit {
     my $self = shift;
 
-    my $mode = 1; 
+    my $mode = 1;
     $mode = shift if (@_);
 
     $self->dbh->{AutoCommit}=$mode;
@@ -356,7 +356,7 @@ Return the current DBI handle. If we're handed a parameter, make the database ha
 
 sub dbh {
   my $self=shift;
-  
+
   #If we are setting the database handle, set it.
   if ( @_ ) {
       $DBIHandle{$self} = $PrevHandle = shift;
@@ -441,15 +441,15 @@ sub InsertFromSelect {
     return $rows == 0? '0E0' : $rows;
 }
 
-=head2 UpdateRecordValue 
+=head2 UpdateRecordValue
 
-Takes a hash with fields: Table, Column, Value PrimaryKeys, and 
-IsSQLFunction.  Table, and Column should be obvious, Value is where you 
-set the new value you want the column to have. The primary_keys field should 
-be the lvalue of DBIx::SearchBuilder::Record::PrimaryKeys().  Finally 
-IsSQLFunction is set when the Value is a SQL function.  For example, you 
-might have ('Value'=>'PASSWORD(string)'), by setting IsSQLFunction that 
-string will be inserted into the query directly rather then as a binding. 
+Takes a hash with fields: Table, Column, Value PrimaryKeys, and
+IsSQLFunction.  Table, and Column should be obvious, Value is where you
+set the new value you want the column to have. The primary_keys field should
+be the lvalue of DBIx::SearchBuilder::Record::PrimaryKeys().  Finally
+IsSQLFunction is set when the Value is a SQL function.  For example, you
+might have ('Value'=>'PASSWORD(string)'), by setting IsSQLFunction that
+string will be inserted into the query directly rather then as a binding.
 
 =cut
 
@@ -466,25 +466,25 @@ sub UpdateRecordValue {
     my $query = 'UPDATE ' . $args{'Table'} . ' ';
      $query .= 'SET '    . $args{'Column'} . '=';
 
-  ## Look and see if the field is being updated via a SQL function. 
-  if ($args{'IsSQLFunction'}) {
-     $query .= $args{'Value'} . ' ';
-  }
-  else {
-     $query .= '? ';
-     push (@bind, $args{'Value'});
-  }
+    ## Look and see if the field is being updated via a SQL function.
+    if ($args{'IsSQLFunction'}) {
+       $query .= $args{'Value'} . ' ';
+    }
+    else {
+       $query .= '? ';
+       push (@bind, $args{'Value'});
+    }
 
-  ## Constructs the where clause.
-  my $where  = 'WHERE ';
-  foreach my $key (sort keys %{$args{'PrimaryKeys'}}) {
-     $where .= $key . "=?" . " AND ";
-     push (@bind, $args{'PrimaryKeys'}{$key});
-  }
-     $where =~ s/AND\s$//;
-  
-  my $query_str = $query . $where;
-  return ($self->SimpleQuery($query_str, @bind));
+    ## Constructs the where clause.
+    my $where  = 'WHERE ';
+    foreach my $key (sort keys %{$args{'PrimaryKeys'}}) {
+       $where .= $key . "=?" . " AND ";
+       push (@bind, $args{'PrimaryKeys'}{$key});
+    }
+    $where =~ s/AND\s$//;
+
+    my $query_str = $query . $where;
+    return ($self->SimpleQuery($query_str, @bind));
 }
 
 
@@ -500,12 +500,12 @@ don\'t quote the NEW_VALUE
 sub UpdateTableValue  {
     my $self = shift;
 
-    ## This is just a wrapper to UpdateRecordValue().     
-    my %args = (); 
+    ## This is just a wrapper to UpdateRecordValue().
+    my %args = ();
     $args{'Table'}  = shift;
     $args{'Column'} = shift;
     $args{'Value'}  = shift;
-    $args{'PrimaryKeys'}   = shift; 
+    $args{'PrimaryKeys'}   = shift;
     $args{'IsSQLFunction'} = shift;
 
     return $self->UpdateRecordValue(%args)
@@ -658,19 +658,19 @@ If the select succeeds, returns the first row as an array.
 Otherwise, returns a Class::ResturnValue object with the failure loaded
 up.
 
-=cut 
+=cut
 
 sub FetchResult {
-  my $self = shift;
-  my $query = shift;
-  my @bind_values = @_;
-  my $sth = $self->SimpleQuery($query, @bind_values);
-  if ($sth) {
-    return ($sth->fetchrow);
-  }
-  else {
-   return($sth);
-  }
+    my $self = shift;
+    my $query = shift;
+    my @bind_values = @_;
+    my $sth = $self->SimpleQuery($query, @bind_values);
+    if ($sth) {
+        return ($sth->fetchrow);
+    }
+    else {
+        return($sth);
+    }
 }
 
 
@@ -704,14 +704,14 @@ sub KnowsBLOBs {
 
 =head2 BLOBParams 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.                 
+Returns a hash ref for the bind_param call to identify BLOB types used by
+the current database for a particular column type.
 
 =cut
 
 sub BLOBParams {
     my $self = shift;
-    # Don't assign to key 'value' as it is defined later. 
+    # Don't assign to key 'value' as it is defined later.
     return ( {} );
 }
 
@@ -1001,8 +1001,7 @@ sub ApplyLimits {
         $limit_clause .= $per_page;
     }
 
-   $$statementref .= $limit_clause; 
-
+    $$statementref .= $limit_clause;
 }
 
 
@@ -1011,8 +1010,8 @@ sub ApplyLimits {
 
 =head2 Join { Paramhash }
 
-Takes a paramhash of everything Searchbuildler::Record does 
-plus a parameter called 'SearchBuilder' that contains a ref 
+Takes a paramhash of everything Searchbuildler::Record does
+plus a parameter called 'SearchBuilder' that contains a ref
 to a SearchBuilder object'.
 
 This performs the join.
@@ -1223,7 +1222,7 @@ sub _NormalJoin {
     }
 }
 
-# this code is all hacky and evil. but people desperately want _something_ and I'm 
+# this code is all hacky and evil. but people desperately want _something_ and I'm
 # super tired. refactoring gratefully appreciated.
 
 sub _BuildJoins {
@@ -1348,7 +1347,7 @@ sub MayBeNull {
 
     # replace conditions with boolean result: 1 - allows nulls, 0 - not
     # all restrictions on that don't act on required alias allow nulls
-    # otherwise only IS NULL operator 
+    # otherwise only IS NULL operator
     foreach ( splice @conditions ) {
         unless ( ref $_ ) {
             push @conditions, $_;
@@ -1443,7 +1442,7 @@ sub MayBeNull {
     return 1;
 }
 
-=head2 DistinctQuery STATEMENTREF 
+=head2 DistinctQuery STATEMENTREF
 
 takes an incomplete SQL SELECT statement and massages it to return a DISTINCT result set.
 
@@ -1492,7 +1491,7 @@ sub DistinctQueryAndCount {
 
 
 
-=head2 DistinctCount STATEMENTREF 
+=head2 DistinctCount STATEMENTREF
 
 takes an incomplete SQL SELECT statement and massages it to return a DISTINCT result set.
 
@@ -1539,10 +1538,9 @@ Currently prints that message to STDERR
 =cut
 
 sub Log {
-	my $self = shift;
-	my $msg = shift;
-	warn $msg."\n";
-
+    my $self = shift;
+    my $msg = shift;
+    warn $msg."\n";
 }
 
 =head2 SimpleDateTimeFunctions
@@ -1935,9 +1933,9 @@ When we get rid of the Searchbuilder::Handle, we need to disconnect from the dat
 =cut
 
 sub DESTROY {
-  my $self = shift;
-  $self->Disconnect if $self->{'DisconnectHandleOnDestroy'};
-  delete $DBIHandle{$self};
+    my $self = shift;
+    $self->Disconnect if $self->{'DisconnectHandleOnDestroy'};
+    delete $DBIHandle{$self};
 }
 
 
diff --git a/lib/DBIx/SearchBuilder/Handle/Informix.pm b/lib/DBIx/SearchBuilder/Handle/Informix.pm
index 3941e8e..a9c3209 100644
--- a/lib/DBIx/SearchBuilder/Handle/Informix.pm
+++ b/lib/DBIx/SearchBuilder/Handle/Informix.pm
@@ -16,7 +16,7 @@ use base qw(DBIx::SearchBuilder::Handle);
 
 =head1 DESCRIPTION
 
-This module provides a subclass of DBIx::SearchBuilder::Handle that 
+This module provides a subclass of DBIx::SearchBuilder::Handle that
 compensates for some of the idiosyncrasies of Informix.
 
 =head1 METHODS
@@ -38,9 +38,9 @@ sub Insert  {
 
     my $sth = $self->SUPER::Insert(@_);
     if (!$sth) {
-            print "no sth! (".$self->dbh->{ix_sqlerrd}[1].")\n";
-	    return ($sth);
-     }
+        print "no sth! (".$self->dbh->{ix_sqlerrd}[1].")\n";
+        return ($sth);
+    }
 
 
     $self->{id}=$self->dbh->{ix_sqlerrd}[1];
@@ -49,9 +49,9 @@ sub Insert  {
   }
 
 
-=head2 CaseSensitive 
+=head2 CaseSensitive
 
-Returns 1, since Informix's searches are case sensitive by default 
+Returns 1, since Informix's searches are case sensitive by default
 
 =cut
 
@@ -69,19 +69,21 @@ Builder for Informix DSNs.
 
 sub BuildDSN {
     my $self = shift;
-  my %args = ( Driver => undef,
-               Database => undef,
-               Host => undef,
-               Port => undef,
-           SID => undef,
-               RequireSSL => undef,
-               @_);
+    my %args = (
+        Driver => undef,
+        Database => undef,
+        Host => undef,
+        Port => undef,
+        SID => undef,
+        RequireSSL => undef,
+        @_
+    );
 
-  my $dsn = "dbi:$args{'Driver'}:";
+    my $dsn = "dbi:$args{'Driver'}:";
 
-  $dsn .= "$args{'Database'}" if (defined $args{'Database'} && $args{'Database'});
+    $dsn .= "$args{'Database'}" if (defined $args{'Database'} && $args{'Database'});
 
-  $self->{'dsn'}= $dsn;
+    $self->{'dsn'}= $dsn;
 }
 
 
@@ -100,20 +102,20 @@ sub ApplyLimits {
 
     # XXX TODO THIS only works on the FIRST page of results. that's a bug
     if ($per_page) {
-	$$statementref =~ s[^\s*SELECT][SELECT FIRST $per_page]i;
+        $$statementref =~ s[^\s*SELECT][SELECT FIRST $per_page]i;
     }
 }
 
 
 sub Disconnect  {
-  my $self = shift;
-  if ($self->dbh) {
-      my $status = $self->dbh->disconnect();
-      $self->dbh( undef);
-      return $status;
-  } else {
-      return;
-  }
+    my $self = shift;
+    if ($self->dbh) {
+        my $status = $self->dbh->disconnect();
+        $self->dbh( undef);
+        return $status;
+    } else {
+        return;
+    }
 }
 
 
diff --git a/lib/DBIx/SearchBuilder/Handle/ODBC.pm b/lib/DBIx/SearchBuilder/Handle/ODBC.pm
index 9fb9349..4801a01 100644
--- a/lib/DBIx/SearchBuilder/Handle/ODBC.pm
+++ b/lib/DBIx/SearchBuilder/Handle/ODBC.pm
@@ -16,7 +16,7 @@ use base qw(DBIx::SearchBuilder::Handle);
 
 =head1 DESCRIPTION
 
-This module provides a subclass of DBIx::SearchBuilder::Handle that 
+This module provides a subclass of DBIx::SearchBuilder::Handle that
 compensates for some of the idiosyncrasies of ODBC.
 
 =head1 METHODS
diff --git a/lib/DBIx/SearchBuilder/Handle/Oracle.pm b/lib/DBIx/SearchBuilder/Handle/Oracle.pm
index 8e5b02a..8025c5e 100755
--- a/lib/DBIx/SearchBuilder/Handle/Oracle.pm
+++ b/lib/DBIx/SearchBuilder/Handle/Oracle.pm
@@ -8,7 +8,7 @@ use warnings;
 use base qw/DBIx::SearchBuilder::Handle/;
 
 use DBD::Oracle qw(:ora_types ORA_OCI);
-         
+
 =head1 NAME
 
   DBIx::SearchBuilder::Handle::Oracle - An oracle specific Handle object
@@ -18,7 +18,7 @@ use DBD::Oracle qw(:ora_types ORA_OCI);
 
 =head1 DESCRIPTION
 
-This module provides a subclass of DBIx::SearchBuilder::Handle that 
+This module provides a subclass of DBIx::SearchBuilder::Handle that
 compensates for some of the idiosyncrasies of Oracle.
 
 =head1 METHODS
@@ -28,21 +28,23 @@ compensates for some of the idiosyncrasies of Oracle.
 
 =head2 Connect PARAMHASH: Driver, Database, Host, User, Password
 
-Takes a paramhash and connects to your DBI datasource. 
+Takes a paramhash and connects to your DBI datasource.
 
 =cut
 
 sub Connect  {
-  my $self = shift;
-  
-  my %args = ( Driver => undef,
-	       Database => undef,
-	       User => undef,
-	       Password => undef, 
-	       SID => undef,
-	       Host => undef,
-	       @_);
-  
+    my $self = shift;
+
+    my %args = (
+        Driver   => undef,
+        Database => undef,
+        User     => undef,
+        Password => undef,
+        SID      => undef,
+        Host     => undef,
+        @_
+    );
+
     my $rv = $self->SUPER::Connect(%args);
     
     $self->dbh->{LongTruncOk}=1;
@@ -53,8 +55,8 @@ sub Connect  {
             "ALTER SESSION set NLS_${setting}_FORMAT = 'YYYY-MM-DD HH24:MI:SS'"
         );
     }
-    
-    return ($rv); 
+
+    return ($rv);
 }
 
 =head2 BuildDSN
@@ -111,39 +113,32 @@ are an array of key-value pairs to be inserted.
 =cut
 
 sub Insert  {
-	my $self = shift;
-	my $table = shift;
+    my $self = shift;
+    my $table = shift;
     my ($sth);
 
-
-
-  # Oracle Hack to replace non-supported mysql_rowid call
+    # Oracle Hack to replace non-supported mysql_rowid call
 
     my %attribs = @_;
     my ($unique_id, $QueryString);
 
     if ($attribs{'Id'} || $attribs{'id'}) {
         $unique_id = ($attribs{'Id'} ? $attribs{'Id'} : $attribs{'id'} );
-    }
-    else {
- 
-    $QueryString = "SELECT ".$table."_seq.nextval FROM DUAL";
- 
-    $sth = $self->SimpleQuery($QueryString);
-    if (!$sth) {
-       if ($main::debug) {
-    	die "Error with $QueryString";
-      }
-       else {
-	 return (undef);
-       }
-     }
-
-     #needs error checking
-    my @row = $sth->fetchrow_array;
-
-    $unique_id = $row[0];
+    } else {
+        $QueryString = "SELECT ".$table."_seq.nextval FROM DUAL";
+        $sth = $self->SimpleQuery($QueryString);
+        if (!$sth) {
+            if ($main::debug) {
+                die "Error with $QueryString";
+            } else {
+                return (undef);
+            }
+        }
 
+        #needs error checking
+        my @row = $sth->fetchrow_array;
+
+        $unique_id = $row[0];
     }
 
     #TODO: don't hardcode this to id pull it from somewhere else
@@ -153,18 +148,17 @@ sub Insert  {
     delete $attribs{'Id'};
     $sth =  $self->SUPER::Insert( $table, %attribs);
 
-   unless ($sth) {
-     if ($main::debug) {
-        die "Error with $QueryString: ". $self->dbh->errstr;
+    unless ($sth) {
+        if ($main::debug) {
+            die "Error with $QueryString: ". $self->dbh->errstr;
+        } else {
+            return (undef);
+        }
     }
-     else {
-         return (undef);
-     }
-   }
 
     $self->{'id'} = $unique_id;
     return( $self->{'id'}); #Add Succeded. return the id
-  }
+}
 
 =head2 InsertFromSelect
 
@@ -202,14 +196,14 @@ sub InsertFromSelect {
     return $self->SUPER::InsertFromSelect( $table, $columns, "($query)", @binds);
 }
 
-=head2 KnowsBLOBs     
+=head2 KnowsBLOBs
 
-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
 
-sub KnowsBLOBs {     
+sub KnowsBLOBs {
     my $self = shift;
     return(undef);
 }
@@ -218,19 +212,20 @@ sub KnowsBLOBs {
 
 =head2 BLOBParams FIELD_NAME FIELD_TYPE
 
-Returns a hash ref for the bind_param call to identify BLOB types used by 
+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
 
-sub BLOBParams { 
+sub BLOBParams {
     my $self = shift;
     my $field = shift;
     #my $type = shift;
     # Don't assign to key 'value' as it is defined later.
-    return ( { ora_field => $field, ora_type => ORA_CLOB,
-});    
+    return (
+        { ora_field => $field, ora_type => ORA_CLOB, }
+    );
 }
 
 
@@ -239,7 +234,6 @@ sub BLOBParams {
 
 takes an SQL SELECT statement and massages it to return ROWS_PER_PAGE starting with FIRST_ROW;
 
-
 =cut
 
 sub ApplyLimits {
@@ -251,30 +245,30 @@ sub ApplyLimits {
 
     # Transform an SQL query from:
     #
-    # SELECT main.* 
-    #   FROM Tickets main   
-    #  WHERE ((main.EffectiveId = main.id)) 
-    #    AND ((main.Type = 'ticket')) 
-    #    AND ( ( (main.Status = 'new')OR(main.Status = 'open') ) 
-    #    AND ( (main.Queue = '1') ) )  
+    # SELECT main.*
+    #   FROM Tickets main
+    #  WHERE ((main.EffectiveId = main.id))
+    #    AND ((main.Type = 'ticket'))
+    #    AND ( ( (main.Status = 'new')OR(main.Status = 'open') )
+    #    AND ( (main.Queue = '1') ) )
     #
-    # to: 
+    # to:
     #
     # SELECT * FROM (
     #     SELECT limitquery.*,rownum limitrownum FROM (
-    #             SELECT main.* 
-    #               FROM Tickets main   
-    #              WHERE ((main.EffectiveId = main.id)) 
-    #                AND ((main.Type = 'ticket')) 
-    #                AND ( ( (main.Status = 'new')OR(main.Status = 'open') ) 
-    #                AND ( (main.Queue = '1') ) )  
+    #             SELECT main.*
+    #               FROM Tickets main
+    #              WHERE ((main.EffectiveId = main.id))
+    #                AND ((main.Type = 'ticket'))
+    #                AND ( ( (main.Status = 'new')OR(main.Status = 'open') )
+    #                AND ( (main.Queue = '1') ) )
     #     ) limitquery WHERE rownum <= 50
     # ) WHERE limitrownum >= 1
     #
 
     if ($per_page) {
         # Oracle orders from 1 not zero
-        $first++; 
+        $first++;
         # Make current query a sub select
         my $last = $first + $per_page - 1;
         if ( $sb->{_bind_values} ) {
diff --git a/lib/DBIx/SearchBuilder/Handle/Pg.pm b/lib/DBIx/SearchBuilder/Handle/Pg.pm
index a29f192..c09259b 100755
--- a/lib/DBIx/SearchBuilder/Handle/Pg.pm
+++ b/lib/DBIx/SearchBuilder/Handle/Pg.pm
@@ -19,7 +19,7 @@ use Want qw(howmany);
 
 =head1 DESCRIPTION
 
-This module provides a subclass of DBIx::SearchBuilder::Handle that 
+This module provides a subclass of DBIx::SearchBuilder::Handle that
 compensates for some of the idiosyncrasies of Postgres.
 
 =head1 METHODS
@@ -34,15 +34,15 @@ Forces the timezone to GMT
 it returns a database handle.
 
 =cut
-  
+
 sub Connect {
     my $self = shift;
-    
+
     my $rv = $self->SUPER::Connect(@_);
     $self->SimpleQuery("SET TIME ZONE 'GMT'");
     $self->SimpleQuery("SET DATESTYLE TO 'ISO'");
     $self->AutoCommit(1);
-    return ($rv); 
+    return ($rv);
 }
 
 =head2 BuildDSN
@@ -136,14 +136,14 @@ sub IdSequenceName {
         }
 
     }
-            my $ret = Class::ReturnValue->new();
-            $ret->as_error(
-                errno   => '-1',
-                message => "Found no sequence for $table",
-                do_backtrace => undef
-            );
-            return ( $ret->return_value );
 
+    my $ret = Class::ReturnValue->new();
+    $ret->as_error(
+        errno   => '-1',
+        message => "Found no sequence for $table",
+        do_backtrace => undef
+    );
+    return ( $ret->return_value );
 }
 
 
@@ -191,8 +191,7 @@ sub ApplyLimits {
         }
     }
 
-   $$statementref .= $limit_clause; 
-
+    $$statementref .= $limit_clause;
 }
 
 
@@ -213,7 +212,7 @@ sub _MakeClauseCaseInsensitive {
 
     # we don't need to downcase numeric values and dates
     if ($value =~ /^$DBIx::SearchBuilder::Handle::RE_CASE_INSENSITIVE_CHARS+$/o) {
-        	return ( $field, $operator, $value);
+        return ( $field, $operator, $value);
     }
 
     if ( $operator =~ /LIKE/i ) {
@@ -221,16 +220,15 @@ sub _MakeClauseCaseInsensitive {
         return ( $field, $operator, $value );
     }
     elsif ( $operator =~ /=/ ) {
-	if (howmany() >= 4) {
-        	return ( "LOWER($field)", $operator, $value, "LOWER(?)"); 
-	} 
-	# RT 3.0.x and earlier  don't know how to cope with a "LOWER" function 
-	# on the value. they only expect field, operator, value.
-	# 
-	else {
-		return ( "LOWER($field)", $operator, lc($value));
-
-	}
+        if (howmany() >= 4) {
+            return ( "LOWER($field)", $operator, $value, "LOWER(?)");
+        }
+        # RT 3.0.x and earlier  don't know how to cope with a "LOWER" function
+        # on the value. they only expect field, operator, value.
+        #
+        else {
+            return ( "LOWER($field)", $operator, lc($value));
+        }
     }
     else {
         $self->SUPER::_MakeClauseCaseInsensitive( $field, $operator, $value );
diff --git a/lib/DBIx/SearchBuilder/Handle/SQLite.pm b/lib/DBIx/SearchBuilder/Handle/SQLite.pm
index c172974..9a0c08a 100644
--- a/lib/DBIx/SearchBuilder/Handle/SQLite.pm
+++ b/lib/DBIx/SearchBuilder/Handle/SQLite.pm
@@ -15,7 +15,7 @@ use base qw(DBIx::SearchBuilder::Handle);
 
 =head1 DESCRIPTION
 
-This module provides a subclass of DBIx::SearchBuilder::Handle that 
+This module provides a subclass of DBIx::SearchBuilder::Handle that
 compensates for some of the idiosyncrasies of SQLite.
 
 =head1 METHODS
@@ -77,13 +77,13 @@ sub Insert  {
 
     warn "$self no row id returned on row creation" unless ($self->{'id'});
     return( $self->{'id'}); #Add Succeded. return the id
-  }
+}
 
 
 
-=head2 CaseSensitive 
+=head2 CaseSensitive
 
-Returns undef, since SQLite's searches are not case sensitive by default 
+Returns undef, since SQLite's searches are not case sensitive by default
 
 =cut
 
@@ -92,7 +92,7 @@ sub CaseSensitive {
     return(1);
 }
 
-sub BinarySafeBLOBs { 
+sub BinarySafeBLOBs {
     return undef;
 }
 
diff --git a/lib/DBIx/SearchBuilder/Handle/Sybase.pm b/lib/DBIx/SearchBuilder/Handle/Sybase.pm
index f4e0f06..1561d33 100644
--- a/lib/DBIx/SearchBuilder/Handle/Sybase.pm
+++ b/lib/DBIx/SearchBuilder/Handle/Sybase.pm
@@ -16,7 +16,7 @@ use base qw(DBIx::SearchBuilder::Handle);
 
 =head1 DESCRIPTION
 
-This module provides a subclass of DBIx::SearchBuilder::Handle that 
+This module provides a subclass of DBIx::SearchBuilder::Handle that
 compensates for some of the idiosyncrasies of Sybase.
 
 =head1 METHODS
@@ -43,7 +43,7 @@ sub Insert {
     if ( !$sth ) {
         return ($sth);
     }
-    
+
     # Can't select identity column if we're inserting the id by hand.
     unless ($pairs{'id'}) {
         my @row = $self->FetchResult('SELECT @@identity');
@@ -71,14 +71,13 @@ sub DatabaseVersion {
     my $self = shift;
     my $v = $self->SUPER::DatabaseVersion();
 
-   $v =~ s/\-(.*)$//;
-   return ($v);
-
+    $v =~ s/\-(.*)$//;
+    return ($v);
 }
 
-=head2 CaseSensitive 
+=head2 CaseSensitive
 
-Returns undef, since Sybase's searches are not case sensitive by default 
+Returns undef, since Sybase's searches are not case sensitive by default
 
 =cut
 
diff --git a/lib/DBIx/SearchBuilder/Handle/mysql.pm b/lib/DBIx/SearchBuilder/Handle/mysql.pm
index 09720ce..2548a94 100755
--- a/lib/DBIx/SearchBuilder/Handle/mysql.pm
+++ b/lib/DBIx/SearchBuilder/Handle/mysql.pm
@@ -35,19 +35,19 @@ sub Insert  {
 
     my $sth = $self->SUPER::Insert(@_);
     if (!$sth) {
-	    return ($sth);
-     }
+        return ($sth);
+    }
 
     $self->{'id'}=$self->dbh->{'mysql_insertid'};
- 
+
     # Yay. we get to work around mysql_insertid being null some of the time :/
     unless ($self->{'id'}) {
 	$self->{'id'} =  $self->FetchResult('SELECT LAST_INSERT_ID()');
     }
     warn "$self no row id returned on row creation" unless ($self->{'id'});
-    
+
     return( $self->{'id'}); #Add Succeded. return the id
-  }
+}
 
 
 =head2 SimpleUpdateFromSelect
@@ -143,13 +143,13 @@ sub DatabaseVersion {
     my $self = shift;
     my $v = $self->SUPER::DatabaseVersion();
 
-   $v =~ s/\-.*$//;
-   return ($v);
+    $v =~ s/\-.*$//;
+    return ($v);
 }
 
-=head2 CaseSensitive 
+=head2 CaseSensitive
 
-Returns undef, since mysql's searches are not case sensitive by default 
+Returns undef, since mysql's searches are not case sensitive by default
 
 =cut
 
diff --git a/lib/DBIx/SearchBuilder/Record.pm b/lib/DBIx/SearchBuilder/Record.pm
index 02058be..582c8ba 100755
--- a/lib/DBIx/SearchBuilder/Record.pm
+++ b/lib/DBIx/SearchBuilder/Record.pm
@@ -17,73 +17,72 @@ DBIx::SearchBuilder::Record - Superclass for records loaded by SearchBuilder
 
   package MyRecord;
   use base qw/DBIx::SearchBuilder::Record/;
-  
+
   sub _Init {
       my $self       = shift;
-      my $DBIxHandle =
-	shift;    # A DBIx::SearchBuilder::Handle::foo object for your database
-  
+      my $DBIxHandle = shift;  # A DBIx::SearchBuilder::Handle::foo object for your database
+
       $self->_Handle($DBIxHandle);
       $self->Table("Users");
   }
-  
+
   # Tell Record what the primary keys are
   sub _PrimaryKeys {
       return ['id'];
   }
-  
+
   # Preferred and most efficient way to specify fields attributes in a derived
   # class, used by the autoloader to construct Attrib and SetAttrib methods.
 
-  # read: calling $Object->Foo will return the value of this record's Foo column  
+  # read: calling $Object->Foo will return the value of this record's Foo column
   # write: calling $Object->SetFoo with a single value will set Foo's value in
-  #        both the loaded object and the database  
+  #        both the loaded object and the database
   sub _ClassAccessible {
       {
-	  Tofu => { 'read' => 1, 'write' => 1 },
-	  Maz  => { 'auto' => 1, },
-	  Roo => { 'read' => 1, 'auto' => 1, 'public' => 1, },
+          Tofu => { 'read' => 1, 'write' => 1 },
+          Maz  => { 'auto' => 1, },
+          Roo => { 'read' => 1, 'auto' => 1, 'public' => 1, },
       };
   }
-  
+
   # A subroutine to check a user's password without returning the current value
   # For security purposes, we didn't expose the Password method above
   sub IsPassword {
       my $self = shift;
       my $try  = shift;
-  
+
       # note two __s in __Value.  Subclasses may muck with _Value, but
       # they should never touch __Value
-  
+
       if ( $try eq $self->__Value('Password') ) {
-	  return (1);
+          return (1);
       }
       else {
-	  return (undef);
+          return (undef);
       }
   }
-  
+
   # Override DBIx::SearchBuilder::Create to do some checking on create
   sub Create {
       my $self   = shift;
       my %fields = (
-	  UserId   => undef,
-	  Password => 'default',    #Set a default password
-	  @_
+          UserId   => undef,
+          Password => 'default',    #Set a default password
+          @_
       );
-  
+
       # Make sure a userid is specified
       unless ( $fields{'UserId'} ) {
-	  die "No userid specified.";
+          die "No userid specified.";
       }
-  
+
       # Get DBIx::SearchBuilder::Record->Create to do the real work
       return (
-	  $self->SUPER::Create(
-	      UserId   => $fields{'UserId'},
-	      Password => $fields{'Password'},
-	      Created  => time
-	  )
+          $self->SUPER::Create(
+              UserId   => $fields{'UserId'},
+              Password => $fields{'Password'},
+              Created  => time
+          )
       );
   }
 
@@ -92,25 +91,25 @@ DBIx::SearchBuilder::Record - Superclass for records loaded by SearchBuilder
 DBIx::SearchBuilder::Record is designed to work with DBIx::SearchBuilder.
 
 
-=head2 What is it trying to do. 
+=head2 What is it trying to do.
 
-DBIx::SearchBuilder::Record abstracts the agony of writing the common and generally 
+DBIx::SearchBuilder::Record abstracts the agony of writing the common and generally
 simple SQL statements needed to serialize and De-serialize an object to the
-database.  In a traditional system, you would define various methods on 
-your object 'create', 'find', 'modify', and 'delete' being the most common. 
-In each method you would have a SQL statement like: 
+database.  In a traditional system, you would define various methods on
+your object 'create', 'find', 'modify', and 'delete' being the most common.
+In each method you would have a SQL statement like:
 
   select * from table where value='blah';
 
-If you wanted to control what data a user could modify, you would have to 
-do some special magic to make accessors do the right thing. Etc.  The 
-problem with this approach is that in a majority of the cases, the SQL is 
-incredibly simple and the code from one method/object to the next was 
-basically the same.  
+If you wanted to control what data a user could modify, you would have to
+do some special magic to make accessors do the right thing. Etc.  The
+problem with this approach is that in a majority of the cases, the SQL is
+incredibly simple and the code from one method/object to the next was
+basically the same.
 
 <trumpets>
 
-Enter, DBIx::SearchBuilder::Record. 
+Enter, DBIx::SearchBuilder::Record.
 
 With Record, you can in the simple case, remove all of that code and
 replace it by defining two methods and inheriting some code.  It's pretty
@@ -125,17 +124,17 @@ They will get called by your record object's constructor.
 
 =over 4
 
-=item '_Init' 
+=item '_Init'
 
-Defines what table we are talking about, and set a variable to store 
-the database handle. 
+Defines what table we are talking about, and set a variable to store
+the database handle.
 
 =item '_ClassAccessible
 
-Defines what operations may be performed on various data selected 
+Defines what operations may be performed on various data selected
 from the database.  For example you can define fields to be mutable,
-or immutable, there are a few other options but I don't understand 
-what they do at this time. 
+or immutable, there are a few other options but I don't understand
+what they do at this time.
 
 =back
 
@@ -143,7 +142,7 @@ And really, that's it.  So let's have some sample code.
 
 =head2 An Annotated Example
 
-The example code below makes the following assumptions: 
+The example code below makes the following assumptions:
 
 =over 4
 
@@ -161,15 +160,15 @@ The login name is 'mhat',
 
 =item *
 
-The database is called 'example', 
+The database is called 'example',
 
 =item *
 
-The table is called 'simple', 
+The table is called 'simple',
 
 =item *
 
-The table looks like so: 
+The table looks like so:
 
       id     integer     not NULL,   primary_key(id),
       foo    varchar(10),
@@ -179,106 +178,106 @@ The table looks like so:
 
 First, let's define our record class in a new module named "Simple.pm".
 
-  000: package Simple; 
+  000: package Simple;
   001: use DBIx::SearchBuilder::Record;
   002: @ISA = (DBIx::SearchBuilder::Record);
 
-This should be pretty obvious, name the package, import ::Record and then 
-define ourself as a subclass of ::Record. 
+This should be pretty obvious, name the package, import ::Record and then
+define ourself as a subclass of ::Record.
 
-  003: 
+  003:
   004: sub _Init {
-  005:   my $this   = shift; 
+  005:   my $this   = shift;
   006:   my $handle = shift;
-  007: 
-  008:   $this->_Handle($handle); 
-  009:   $this->Table("Simple"); 
-  010:   
+  007:
+  008:   $this->_Handle($handle);
+  009:   $this->Table("Simple");
+  010:
   011:   return ($this);
   012: }
 
-Here we set our handle and table name, while its not obvious so far, we'll 
-see later that $handle (line: 006) gets passed via ::Record::new when a 
+Here we set our handle and table name. While it's not obvious so far, we'll 
+see later that $handle (line: 006) gets passed via C<::Record::new> when a 
 new instance is created.  That's actually an important concept: the DB handle
 is not bound to a single object but rather, it is shared across objects.
 
-  013: 
+  013:
   014: sub _ClassAccessible {
-  015:   {  
+  015:   {
   016:     Foo => { 'read'  => 1 },
   017:     Bar => { 'read'  => 1, 'write' => 1  },
   018:     Id  => { 'read'  => 1 }
   019:   };
   020: }
 
-What's happening might be obvious, but just in case this method is going to 
-return a reference to a hash. That hash is where our columns are defined, 
-as well as what type of operations are acceptable.  
+What's happening might be obvious, but just in case this method is going to
+return a reference to a hash. That hash is where our columns are defined,
+as well as what type of operations are acceptable.
 
-  021: 
-  022: 1;             
+  021:
+  022: 1;
 
-Like all perl modules, this needs to end with a true value. 
+Like all perl modules, this needs to end with a true value.
 
-Now, on to the code that will actually *do* something with this object. 
+Now, on to the code that will actually *do* something with this object.
 This code would be placed in your Perl script.
 
   000: use DBIx::SearchBuilder::Handle;
   001: use Simple;
 
-Use two packages, the first is where I get the DB handle from, the latter 
-is the object I just created. 
+Use two packages, the first is where I get the DB handle from, the latter
+is the object I just created.
 
-  002: 
+  002:
   003: my $handle = DBIx::SearchBuilder::Handle->new();
   004:    $handle->Connect( 'Driver'   => 'Pg',
-  005: 		          'Database' => 'test', 
-  006: 		          'Host'     => 'reason',
-  007: 		          'User'     => 'mhat',
-  008: 		          'Password' => '');
-
-Creates a new DBIx::SearchBuilder::Handle, and then connects to the database using 
-that handle.  Pretty straight forward, the password '' is what I use 
-when there is no password.  I could probably leave it blank, but I find 
+  005:                    'Database' => 'test',
+  006:                    'Host'     => 'reason',
+  007:                    'User'     => 'mhat',
+  008:                    'Password' => '');
+
+Creates a new DBIx::SearchBuilder::Handle, and then connects to the database using
+that handle.  Pretty straight forward, the password '' is what I use
+when there is no password.  I could probably leave it blank, but I find
 it to be more clear to define it.
 
-  009: 
+  009:
   010: my $s = Simple->new($handle);
-  011: 
-  012: $s->LoadById(1); 
+  011:
+  012: $s->LoadById(1);
 
 LoadById 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. LoadById($id) will 
-do undefined things if there is >1 row with the same id.  
+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. LoadById($id) will
+do undefined things if there is >1 row with the same id.
 
 In addition to LoadById, we also have:
 
 =over 4
 
-=item LoadByCol 
+=item LoadByCol
 
-Takes two arguments, a column name and a value.  Again, it will do 
-undefined things if you use non-unique things.  
+Takes two arguments, a column name and a value.  Again, it will do
+undefined things if you use non-unique things.
 
 =item LoadByCols
 
-Takes a hash of columns=>values and returns the *first* to match. 
-First is probably lossy across databases vendors. 
+Takes a hash of columns=>values and returns the *first* to match.
+First is probably lossy across databases vendors.
 
 =item LoadFromHash
 
-Populates this record with data from a DBIx::SearchBuilder.  I'm 
-currently assuming that DBIx::SearchBuilder is what we use in 
+Populates this record with data from a DBIx::SearchBuilder.  I'm
+currently assuming that DBIx::SearchBuilder is what we use in
 cases where we expect > 1 record.  More on this later.
 
 =back
 
 Now that we have a populated object, we should do something with it! ::Record
-automagically generates accessos and mutators for us, so all we need to do 
-is call the methods.  Accessors are named <Field>(), and Mutators are named 
-Set<Field>($).  On to the example, just appending this to the code from 
+automagically generates accessos and mutators for us, so all we need to do
+is call the methods.  Accessors are named <Field>(), and Mutators are named
+Set<Field>($).  On to the example, just appending this to the code from
 the last example.
 
   013:
@@ -300,7 +299,7 @@ read only.
   020: if (! $res) {
   021:   ## Print the error!
   022:   print "$str\n";
-  023: } 
+  023: }
 
 The output will be:
 
@@ -310,15 +309,15 @@ Currently Set<Field> updates the data in the database as soon as you call
 it.  In the future I hope to extend ::Record to better support transactional
 operations, such that updates will only happen when "you" say so.
 
-Finally, adding a removing records from the database.  ::Record provides a 
-Create method which simply takes a hash of key=>value pairs.  The keys 
-exactly	map to database fields. 
+Finally, adding a removing records from the database.  ::Record provides a
+Create method which simply takes a hash of key=>value pairs.  The keys
+exactly	map to database fields.
 
   023: ## Get a new record object.
   024: $s1 = Simple->new($handle);
   025: $s1->Create('Id'  => 4,
-  026: 	           'Foo' => 'Foooooo', 
-  027: 	           'Bar' => 'Barrrrr');
+  026:             'Foo' => 'Foooooo',
+  027:             'Bar' => 'Barrrrr');
 
 Poof! A new row in the database has been created!  Now let's delete the
 object! 
@@ -346,7 +345,7 @@ For example, the method C<_PrimaryKeys> has the alias C<_primary_keys>.
 
 
 
-=head2  new 
+=head2  new
 
 Instantiate a new record object.
 
@@ -355,14 +354,14 @@ Instantiate a new record object.
 
 sub new  {
     my $proto = shift;
-   
+
     my $class = ref($proto) || $proto;
     my $self  = {};
     bless ($self, $class);
     $self->_Init(@_);
 
     return $self;
-  }
+}
 
 
 # Not yet documented here.  Should almost certainly be overloaded.
@@ -400,8 +399,8 @@ Return a hash of the values of our primary keys for this function.
 
 
 
-sub PrimaryKeys { 
-    my $self = shift; 
+sub PrimaryKeys {
+    my $self = shift;
     return map { $_ => $self->{'values'}->{lc $_} } @{$self->_PrimaryKeys};
 }
 
@@ -425,7 +424,7 @@ sub AUTOLOAD {
     }
     elsif ( $self->_Accessible( $Attrib, 'record-read') ) {
         *{$AUTOLOAD} = sub { $_[0]->_ToRecord( $Attrib, $_[0]->__Value($Attrib) ) };
-        goto &$AUTOLOAD;        
+        goto &$AUTOLOAD;
     }
     elsif ( $self->_Accessible( $Attrib, 'foreign-collection') ) {
         *{$AUTOLOAD} = sub { $_[0]->_CollectionValue( $Attrib ) };
@@ -447,7 +446,7 @@ sub AUTOLOAD {
                 $val = $val->id if UNIVERSAL::isa($val, 'DBIx::SearchBuilder::Record');
                 return ( $self->_Set( Field => $Attrib, Value => $val ) );
             };
-            goto &$AUTOLOAD;            
+            goto &$AUTOLOAD;
         }
         elsif ( $self->_Accessible( $Attrib, 'read' ) ) {
             *{$AUTOLOAD} = sub { return ( 0, 'Immutable field' ) };
@@ -540,7 +539,7 @@ sub _PrimaryKey {
 }
 
 
-=head2 _ClassAccessible 
+=head2 _ClassAccessible
 
 An older way to specify fields attributes in a derived class.
 (The current preferred method is by overriding C<Schema>; if you do
@@ -550,8 +549,8 @@ an appropriate C<_ClassAccessible> based on your C<Schema>.)
 Here's an example declaration:
 
   sub _ClassAccessible {
-    { 
-	 Tofu  => { 'read'=>1, 'write'=>1 },
+    {
+         Tofu  => { 'read'=>1, 'write'=>1 },
          Maz   => { 'auto'=>1, },
          Roo   => { 'read'=>1, 'auto'=>1, 'public'=>1, },
     };
@@ -561,51 +560,51 @@ Here's an example declaration:
 
 
 sub _ClassAccessible {
-  my $self = shift;
-  
-  return $self->_ClassAccessibleFromSchema if $self->can('Schema');
-  
-  # XXX This is stub code to deal with the old way we used to do _Accessible
-  # It should never be called by modern code
-  
-  my %accessible;
-  while ( my $col = shift ) {
-    $accessible{$col}->{lc($_)} = 1
-      foreach split(/[\/,]/, shift);
-  }
-  return(\%accessible);
+    my $self = shift;
+
+    return $self->_ClassAccessibleFromSchema if $self->can('Schema');
+
+    # XXX This is stub code to deal with the old way we used to do _Accessible
+    # It should never be called by modern code
+
+    my %accessible;
+    while ( my $col = shift ) {
+        $accessible{$col}->{lc($_)} = 1
+            foreach split(/[\/,]/, shift);
+    }
+    return(\%accessible);
 }
 
 sub _ClassAccessibleFromSchema {
-  my $self = shift;
-  
-  my $accessible = {};
-  foreach my $key ($self->_PrimaryKeys) {
-   $accessible->{$key} = { 'read' => 1 };
-  };
-  
-  my $schema = $self->Schema;
-  
-  for my $field (keys %$schema) {
-    if ($schema->{$field}{'TYPE'}) {
-        $accessible->{$field} = { 'read' => 1, 'write' => 1 };
-    } elsif (my $refclass = $schema->{$field}{'REFERENCES'}) {
-        if (UNIVERSAL::isa($refclass, 'DBIx::SearchBuilder::Record')) {
-            if ($field =~ /(.*)_id$/) {
-                $accessible->{$field} = { 'read' => 1, 'write' => 1 };
-                $accessible->{$1}     = { 'record-read' => 1, 'column' => $field };
+    my $self = shift;
+
+    my $accessible = {};
+    foreach my $key ($self->_PrimaryKeys) {
+        $accessible->{$key} = { 'read' => 1 };
+    };
+
+    my $schema = $self->Schema;
+
+    for my $field (keys %$schema) {
+        if ($schema->{$field}{'TYPE'}) {
+            $accessible->{$field} = { 'read' => 1, 'write' => 1 };
+        } elsif (my $refclass = $schema->{$field}{'REFERENCES'}) {
+            if (UNIVERSAL::isa($refclass, 'DBIx::SearchBuilder::Record')) {
+                if ($field =~ /(.*)_id$/) {
+                    $accessible->{$field} = { 'read' => 1, 'write' => 1 };
+                    $accessible->{$1}     = { 'record-read' => 1, 'column' => $field };
+                } else {
+                    $accessible->{$field} = { 'record-read' => 1, 'record-write' => 1 };
+                }
+            } elsif (UNIVERSAL::isa($refclass, 'DBIx::SearchBuilder')) {
+                $accessible->{$field} = { 'foreign-collection' => 1 };
             } else {
-                $accessible->{$field} = { 'record-read' => 1, 'record-write' => 1 };
+                warn "Error: $refclass neither Record nor Collection";
             }
-        } elsif (UNIVERSAL::isa($refclass, 'DBIx::SearchBuilder')) {
-            $accessible->{$field} = { 'foreign-collection' => 1 };
-        } else {
-            warn "Error: $refclass neither Record nor Collection";
         }
     }
-  }
-  
-  return $accessible;  
+
+    return $accessible;
 }
 
 
@@ -615,20 +614,20 @@ sub _ToRecord {
     my $value = shift;
 
     return unless defined $value;
-    
+
     my $schema = $self->Schema;
     my $description = $schema->{$field} || $schema->{$field . "_id"};
-    
+
     die "Can't get schema for $field on $self" unless $description;
 
     return unless $description;
-    
+
     return $value unless $description->{'REFERENCES'};
-    
+
     my $classname = $description->{'REFERENCES'};
 
     return unless UNIVERSAL::isa($classname, 'DBIx::SearchBuilder::Record');
-    
+
     # XXX TODO FIXME perhaps this is not what should be passed to new, but it needs it
     my $object = $classname->new( $self->_Handle );
     $object->LoadById( $value );
@@ -637,22 +636,22 @@ sub _ToRecord {
 
 sub _CollectionValue {
     my $self = shift;
-    
+
     my $method_name =  shift;
     return unless defined $method_name;
-    
+
     my $schema = $self->Schema;
     my $description = $schema->{$method_name};
     return unless $description;
-    
+
     my $classname = $description->{'REFERENCES'};
 
     return unless UNIVERSAL::isa($classname, 'DBIx::SearchBuilder');
-    
+
     my $coll = $classname->new( Handle => $self->_Handle );
-    
+
     $coll->Limit( FIELD => $description->{'KEY'}, VALUE => $self->id);
-    
+
     return $coll;
 }
 
@@ -691,7 +690,7 @@ sub WritableAttributes {
 
 =head2 __Value
 
-Takes a field name and returns that field's value. Subclasses should never 
+Takes a field name and returns that field's value. Subclasses should never
 override __Value.
 
 =cut
@@ -705,7 +704,7 @@ sub __Value {
 
     return $self->{'values'}{$field} if $self->{'fetched'}{$field};
     $self->{'fetched'}{$field} = 1;
-    
+
     my %pk = $self->PrimaryKeys;
     return undef if grep !defined, values %pk;
 
@@ -724,8 +723,8 @@ Subclasses can override _Value to insert custom access control.
 
 
 sub _Value  {
-  my $self = shift;
-  return ($self->__Value(@_));
+    my $self = shift;
+    return ($self->__Value(@_));
 }
 
 
@@ -854,12 +853,12 @@ sub __Set {
         # Support for databases which don't deal with LOBs automatically
         my $ca = $self->_ClassAccessible();
         my $key = $args{'Column'};
-            if ( $ca->{$key}->{'type'} =~ /^(text|longtext|clob|blob|lob)$/i ) {
-                my $bhash = $self->_Handle->BLOBParams( $key, $ca->{$key}->{'type'} );
-                $bhash->{'value'} = $args{'Value'};
-                $args{'Value'} = $bhash;
-            }
+        if ( $ca->{$key}->{'type'} =~ /^(text|longtext|clob|blob|lob)$/i ) {
+            my $bhash = $self->_Handle->BLOBParams( $key, $ca->{$key}->{'type'} );
+            $bhash->{'value'} = $args{'Value'};
+            $args{'Value'} = $bhash;
         }
+    }
 
 
     my $val = $self->_Handle->UpdateRecordValue(%args);
@@ -891,7 +890,7 @@ sub __Set {
 
 =head2 _Canonicalize PARAMHASH
 
-This routine massages an input value (VALUE) for FIELD into something that's 
+This routine massages an input value (VALUE) for FIELD into something that's
 going to be acceptable.
 
 Takes
@@ -919,14 +918,14 @@ Takes:
 
 =back
 
-Returns a replacement VALUE. 
+Returns a replacement VALUE.
 
 =cut
 
 sub _Canonicalize {
     my $self = shift;
     my $field = shift;
-    
+
 
 
 }
@@ -934,9 +933,9 @@ sub _Canonicalize {
 
 =head2 _Validate FIELD VALUE
 
-Validate that VALUE will be an acceptable value for FIELD. 
+Validate that VALUE will be an acceptable value for FIELD.
 
-Currently, this routine does nothing whatsoever. 
+Currently, this routine does nothing whatsoever.
 
 If it succeeds (which is always the case right now), returns true. Otherwise returns false.
 
@@ -949,24 +948,24 @@ sub _Validate  {
     my $self = shift;
     my $field = shift;
     my $value = shift;
-        
+
     #Check type of input
     #If it's null, are nulls permitted?
     #If it's an int, check the # of bits
-    #If it's a string, 
+    #If it's a string,
     #check length
     #check for nonprintables
     #If it's a blob, check for length
     #In an ideal world, if this is a link to another table, check the dependency.
-   return(1); 
-  }	
+    return(1);
+}
 
 
 
 =head2 TruncateValue  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. 
+s idea of how big the column is.
 
 (Actually, it looks at SearchBuilder's concept of the database, not directly into the db).
 
@@ -1020,7 +1019,7 @@ the object constructor's arguments.
 Subclasses can override _Object to insert custom access control or
 define default constructor arguments.
 
-Note that if you are using a C<Schema> with a C<REFERENCES> field, 
+Note that if you are using a C<Schema> with a C<REFERENCES> field,
 this is unnecessary: the method to access the column's value will
 automatically turn it into the appropriate object.
 
@@ -1055,7 +1054,7 @@ sub __Object {
     return $object;
 }
 
-  
+
 
 
 # load should do a bit of overloading
@@ -1112,34 +1111,33 @@ sub LoadByCols  {
     my %hash  = (@_);
     my (@bind, @phrases);
     foreach my $key (sort keys %hash) {
-	if (defined $hash{$key} &&  $hash{$key} ne '') {
-        my $op;
-        my $value;
-	my $function = "?";
-        if (ref $hash{$key} eq 'HASH') {
-            $op = $hash{$key}->{operator};
-            $value = $hash{$key}->{value};
-            $function = $hash{$key}->{function} || "?";
-       } else {
-            $op = '=';
-            $value = $hash{$key};
-        }
+        if (defined $hash{$key} &&  $hash{$key} ne '') {
+            my $op;
+            my $value;
+            my $function = "?";
+            if (ref $hash{$key} eq 'HASH') {
+                $op = $hash{$key}->{operator};
+                $value = $hash{$key}->{value};
+                $function = $hash{$key}->{function} || "?";
+            } else {
+                $op = '=';
+                $value = $hash{$key};
+            }
 
-		push @phrases, "$key $op $function"; 
-		push @bind, $value;
-	}
-	else {
-       push @phrases, "($key IS NULL OR $key = ?)";
-       my $meta = $self->_ClassAccessible->{$key};
-       $meta->{'type'} ||= '';
-       # TODO: type checking should be done in generic way
-       if ( $meta->{'is_numeric'} || $meta->{'type'} =~ /INT|NUMERIC|DECIMAL|REAL|DOUBLE|FLOAT/i  ) {
-            push @bind, 0;
-       } else {
-            push @bind, '';
-       }
-
-	}
+            push @phrases, "$key $op $function";
+            push @bind, $value;
+        }
+        else {
+            push @phrases, "($key IS NULL OR $key = ?)";
+            my $meta = $self->_ClassAccessible->{$key};
+            $meta->{'type'} ||= '';
+            # TODO: type checking should be done in generic way
+            if ( $meta->{'is_numeric'} || $meta->{'type'} =~ /INT|NUMERIC|DECIMAL|REAL|DOUBLE|FLOAT/i  ) {
+                 push @bind, 0;
+            } else {
+                 push @bind, '';
+            }
+        }
     }
 
     my $QueryString = "SELECT  * FROM ".$self->QuotedTableName." WHERE ".
@@ -1165,7 +1163,7 @@ sub LoadById  {
 
 
 
-=head2 LoadByPrimaryKeys 
+=head2 LoadByPrimaryKeys
 
 Like LoadById with basic support for compound primary keys.
 
@@ -1179,8 +1177,8 @@ sub LoadByPrimaryKeys {
 
     my %cols=();
     foreach (@{$self->_PrimaryKeys}) {
-	return (0, "Missing PK field: '$_'") unless defined $data->{$_};
-	$cols{$_}=$data->{$_};
+        return (0, "Missing PK field: '$_'") unless defined $data->{$_};
+        $cols{$_}=$data->{$_};
     }
     return ($self->LoadByCols(%cols));
 }
@@ -1198,15 +1196,15 @@ loaded values hash.
 
 
 sub LoadFromHash {
-  my $self = shift;
-  my $hashref = shift;
+    my $self = shift;
+    my $hashref = shift;
 
-  foreach my $f ( keys %$hashref ) {
-      $self->{'fetched'}{lc $f} = 1;
-  }
+    foreach my $f ( keys %$hashref ) {
+        $self->{'fetched'}{lc $f} = 1;
+    }
 
-  $self->{'values'} = $hashref;
-  return $self->id();
+    $self->{'values'} = $hashref;
+    return $self->id();
 }
 
 
@@ -1241,13 +1239,13 @@ sub _LoadFromSQL {
         return ( 0, "Couldn't find row" );
     }
 
-    ## I guess to be consistant with the old code, make sure the primary  
+    ## I guess to be consistant with the old code, make sure the primary
     ## keys exist.
 
     if( grep { not defined } $self->PrimaryKeys ) {
         return ( 0, "Missing a primary key?" );
     }
-    
+
     foreach my $f ( keys %{$self->{'values'}} ) {
         $self->{'fetched'}{lc $f} = 1;
     }
@@ -1264,7 +1262,7 @@ sub _LoadFromSQL {
 Takes an array of key-value pairs and drops any keys that aren't known
 as columns for this recordtype
 
-=cut 
+=cut
 
 
 
@@ -1329,7 +1327,7 @@ sub Delete {
 
 sub __Delete {
     my $self = shift;
-    
+
     #TODO Check to make sure the key's not already listed.
     #TODO Update internal data structure
 
@@ -1338,19 +1336,19 @@ sub __Delete {
     my %pkeys=$self->PrimaryKeys();
     my $where  = 'WHERE ';
     foreach my $key (sort keys %pkeys) {
-       $where .= $key . "=?" . " AND ";
-       push (@bind, $pkeys{$key});
+        $where .= $key . "=?" . " AND ";
+        push (@bind, $pkeys{$key});
     }
 
     $where =~ s/AND\s$//;
     my $QueryString = "DELETE FROM ". $self->QuotedTableName . ' ' . $where;
-   my $return = $self->_Handle->SimpleQuery($QueryString, @bind);
+    my $return = $self->_Handle->SimpleQuery($QueryString, @bind);
 
     if (UNIVERSAL::isa($return, 'Class::ReturnValue')) {
         return ($return);
     } else {
-        return(1); 
-    } 
+        return(1);
+    }
 }
 
 
@@ -1368,7 +1366,7 @@ Returns or sets the name of the current Table
 sub Table {
     my $self = shift;
     if (@_) {
-          $self->{'table'} = shift;
+        $self->{'table'} = shift;
     }
     return ($self->{'table'});
 }
@@ -1401,14 +1399,14 @@ Returns or sets the current DBIx::SearchBuilder::Handle object
 sub _Handle  {
     my $self = shift;
     if (@_) {
-      $self->{'DBIxHandle'} = shift;
+        $self->{'DBIxHandle'} = shift;
     }
     return ($self->{'DBIxHandle'});
-  }
+}
 
 
 if( eval { require capitalization } ) {
-	capitalization->unimport( __PACKAGE__ );
+    capitalization->unimport( __PACKAGE__ );
 }
 
 1;
@@ -1419,7 +1417,7 @@ __END__
 
 =head1 AUTHOR
 
-Jesse Vincent, <jesse at fsck.com> 
+Jesse Vincent, <jesse at fsck.com>
 
 Enhancements by Ivan Kohler, <ivan-rt at 420.am>
 
diff --git a/lib/DBIx/SearchBuilder/Record/Cachable.pm b/lib/DBIx/SearchBuilder/Record/Cachable.pm
index a2f455f..94ea1a7 100755
--- a/lib/DBIx/SearchBuilder/Record/Cachable.pm
+++ b/lib/DBIx/SearchBuilder/Record/Cachable.pm
@@ -46,7 +46,7 @@ sub _SetupCache {
 
 =head2 FlushCache
 
-This class method flushes the _global_ DBIx::SearchBuilder::Record::Cachable 
+This class method flushes the _global_ DBIx::SearchBuilder::Record::Cachable
 cache. All caches are immediately expired.
 
 =cut
@@ -267,9 +267,9 @@ sub _lookup_primary_RecordCache_key {
     return $self->_KeyCache->fetch($key) || $key;
 }
 
-=head2 _CacheConfig 
+=head2 _CacheConfig
 
-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:
 
diff --git a/lib/DBIx/SearchBuilder/SchemaGenerator.pm b/lib/DBIx/SearchBuilder/SchemaGenerator.pm
index 1ed99d9..f4a1eba 100644
--- a/lib/DBIx/SearchBuilder/SchemaGenerator.pm
+++ b/lib/DBIx/SearchBuilder/SchemaGenerator.pm
@@ -20,21 +20,21 @@ required argument is a C<DBIx::SearchBuilder::Handle>.
 =cut
 
 sub new {
-  my $class = shift;
-  my $handle = shift;
-  my $self = $class->SUPER::new();
-  
-  $self->handle($handle);
-  
-  my $schema = DBIx::DBSchema->new;
-  $self->_db_schema($schema);
-  
-  return $self;
+    my $class = shift;
+    my $handle = shift;
+    my $self = $class->SUPER::new();
+
+    $self->handle($handle);
+
+    my $schema = DBIx::DBSchema->new;
+    $self->_db_schema($schema);
+
+    return $self;
 }
 
 =for public_doc AddModel MODEL
 
-Adds a new model class to the SchemaGenerator.  Model should either be an object 
+Adds a new model class to the SchemaGenerator.  Model should either be an object
 of a subclass of C<DBIx::SearchBuilder::Record>, or the name of such a subclass; in the
 latter case, C<AddModel> will instantiate an object of the subclass.
 
@@ -46,31 +46,31 @@ otherwise.
 =cut
 
 sub AddModel {
-  my $self = shift;
-  my $model = shift;
-  
-  # $model could either be a (presumably unfilled) object of a subclass of
-  # DBIx::SearchBuilder::Record, or it could be the name of such a subclass.
-  
-  unless (ref $model and UNIVERSAL::isa($model, 'DBIx::SearchBuilder::Record')) {
-    my $new_model;
-    eval { $new_model = $model->new; };
-    
-    if ($@) {
-      return $self->_error("Error making new object from $model: $@");
+    my $self = shift;
+    my $model = shift;
+
+    # $model could either be a (presumably unfilled) object of a subclass of
+    # DBIx::SearchBuilder::Record, or it could be the name of such a subclass.
+
+    unless (ref $model and UNIVERSAL::isa($model, 'DBIx::SearchBuilder::Record')) {
+        my $new_model;
+        eval { $new_model = $model->new; };
+
+        if ($@) {
+            return $self->_error("Error making new object from $model: $@");
+        }
+
+        return $self->_error("Didn't get a DBIx::SearchBuilder::Record from $model, got $new_model")
+            unless UNIVERSAL::isa($new_model, 'DBIx::SearchBuilder::Record');
+
+        $model = $new_model;
     }
-    
-    return $self->_error("Didn't get a DBIx::SearchBuilder::Record from $model, got $new_model")
-      unless UNIVERSAL::isa($new_model, 'DBIx::SearchBuilder::Record');
-      
-    $model = $new_model;
-  }
-  
-  my $table_obj = $self->_DBSchemaTableFromModel($model);
-  
-  $self->_db_schema->addtable($table_obj);
-  
-  1;
+
+    my $table_obj = $self->_DBSchemaTableFromModel($model);
+
+    $self->_db_schema->addtable($table_obj);
+
+    1;
 }
 
 =for public_doc CreateTableSQLStatements
@@ -81,9 +81,9 @@ the models added to the SchemaGenerator.
 =cut
 
 sub CreateTableSQLStatements {
-  my $self = shift;
-  # The sort here is to make it predictable, so that we can write tests.
-  return sort $self->_db_schema->sql($self->handle->dbh);
+    my $self = shift;
+    # The sort here is to make it predictable, so that we can write tests.
+    return sort $self->_db_schema->sql($self->handle->dbh);
 }
 
 =for public_doc CreateTableSQLText
@@ -94,9 +94,9 @@ all of the models added to the SchemaGenerator.
 =cut
 
 sub CreateTableSQLText {
-  my $self = shift;
+    my $self = shift;
 
-  return join "\n", map { "$_ ;\n" } $self->CreateTableSQLStatements;
+    return join "\n", map { "$_ ;\n" } $self->CreateTableSQLStatements;
 }
 
 =for private_doc _DBSchemaTableFromModel MODEL
@@ -107,46 +107,46 @@ C<DBIx::DBSchema::Table> object corresponding to the model.
 =cut
 
 sub _DBSchemaTableFromModel {
-  my $self = shift;
-  my $model = shift;
-  
-  my $table_name = $model->Table;
-  my $schema     = $model->Schema;
-  
-  my $primary = "id"; # TODO allow override
-  my $primary_col = DBIx::DBSchema::Column->new({
-    name => $primary,
-    type => 'serial',
-    null => 'NOT NULL',
-  });
-  
-  my @cols = ($primary_col);
-  
-  # The sort here is to make it predictable, so that we can write tests.
-  for my $field (sort keys %$schema) {
-    # Skip foreign keys
-    
-    next if defined $schema->{$field}->{'REFERENCES'} and defined $schema->{$field}->{'KEY'};
-    
-    # TODO XXX FIXME
-    # In lieu of real reference support, make references just integers
-    $schema->{$field}{'TYPE'} = 'integer' if $schema->{$field}{'REFERENCES'};
-    
-    push @cols, DBIx::DBSchema::Column->new({
-      name    => $field,
-      type    => $schema->{$field}{'TYPE'},
-      null    => 'NULL',
-      default => $schema->{$field}{'DEFAULT'},
+    my $self = shift;
+    my $model = shift;
+
+    my $table_name = $model->Table;
+    my $schema     = $model->Schema;
+
+    my $primary = "id"; # TODO allow override
+    my $primary_col = DBIx::DBSchema::Column->new({
+        name => $primary,
+        type => 'serial',
+        null => 'NOT NULL',
     });
-  }
-  
-  my $table = DBIx::DBSchema::Table->new({
-    name => $table_name,
-    primary_key => $primary,
-    columns => \@cols,
-  });
-  
-  return $table;
+
+    my @cols = ($primary_col);
+
+    # The sort here is to make it predictable, so that we can write tests.
+    for my $field (sort keys %$schema) {
+        # Skip foreign keys
+
+        next if defined $schema->{$field}->{'REFERENCES'} and defined $schema->{$field}->{'KEY'};
+
+        # TODO XXX FIXME
+        # In lieu of real reference support, make references just integers
+        $schema->{$field}{'TYPE'} = 'integer' if $schema->{$field}{'REFERENCES'};
+
+        push @cols, DBIx::DBSchema::Column->new({
+            name    => $field,
+            type    => $schema->{$field}{'TYPE'},
+            null    => 'NULL',
+            default => $schema->{$field}{'DEFAULT'},
+        });
+    }
+
+    my $table = DBIx::DBSchema::Table->new({
+        name => $table_name,
+        primary_key => $primary,
+        columns => \@cols,
+    });
+
+    return $table;
 }
 
 =for private_doc _error STRING
@@ -156,12 +156,12 @@ Takes in a string and returns it as a Class::ReturnValue error object.
 =cut
 
 sub _error {
-  my $self = shift;
-  my $message = shift;
-  
-  my $ret = Class::ReturnValue->new;
-  $ret->as_error(errno => 1, message => $message);
-  return $ret->return_value;
+    my $self = shift;
+    my $message = shift;
+
+    my $ret = Class::ReturnValue->new;
+    $ret->as_error(errno => 1, message => $message);
+    return $ret->return_value;
 }
 
 
@@ -184,7 +184,7 @@ DBIx::SearchBuilder::SchemaGenerator - Generate table schemas from DBIx::SearchB
     Use subsections (=head2, =head3) as appropriate.
 
 
-=head1 INTERFACE 
+=head1 INTERFACE
 
 =for author to fill in:
     Write a separate section listing the public components of the modules
diff --git a/lib/DBIx/SearchBuilder/Union.pm b/lib/DBIx/SearchBuilder/Union.pm
index 04c1a57..be54345 100644
--- a/lib/DBIx/SearchBuilder/Union.pm
+++ b/lib/DBIx/SearchBuilder/Union.pm
@@ -49,11 +49,11 @@ Create a new DBIx::SearchBuilder::Union object.  No arguments.
 
 sub new {
   bless {
-		 data => [],
-		 curp => 0,				# current offset in data
-		 item => 0,				# number of indiv items from First
-		 count => undef,
-		}, shift;
+      data => [],
+      curp => 0,				# current offset in data
+      item => 0,				# number of indiv items from First
+      count => undef,
+  }, shift;
 }
 
 =head2 add $sb
@@ -66,14 +66,14 @@ It must be the same type as the first object added.
 
 sub add {
     my $self   = shift;
-	my $newobj = shift;
+    my $newobj = shift;
 
-	unless ( @{$self->{data}} == 0
-			 || ref($newobj) eq ref($self->{data}[0]) ) {
-	  die "All elements of a DBIx::SearchBuilder::Union must be of the same type.  Looking for a " . ref($self->{data}[0]) .".";
-	}
+    unless ( @{$self->{data}} == 0
+                 || ref($newobj) eq ref($self->{data}[0]) ) {
+        die "All elements of a DBIx::SearchBuilder::Union must be of the same type.  Looking for a " . ref($self->{data}[0]) .".";
+    }
 
-	$self->{count} = undef;
+    $self->{count} = undef;
     push @{$self->{data}}, $newobj;
 }
 
@@ -88,11 +88,11 @@ element.
 sub First {
     my $self = shift;
 
-	die "No elements in DBIx::SearchBuilder::Union"
-	  unless @{$self->{data}};
+    die "No elements in DBIx::SearchBuilder::Union"
+        unless @{$self->{data}};
 
     $self->{curp} = 0;
-	$self->{item} = 0;
+    $self->{item} = 0;
     $self->{data}[0]->First;
 }
 
@@ -128,10 +128,10 @@ Returns the last item
 =cut
 
 sub Last {
-  die "Last doesn't work right now";
-  my $self = shift;
-  $self->GotoItem( ( $self->Count ) - 1 );
-  return ( $self->Next );
+    die "Last doesn't work right now";
+    my $self = shift;
+    $self->GotoItem( ( $self->Count ) - 1 );
+    return ( $self->Next );
 }
 
 =head2 Count
@@ -164,22 +164,22 @@ if you'd just started iterating through the result set.
 =cut
 
 sub GotoFirstItem {
-  my $self = shift;
-  $self->GotoItem(0);
+    my $self = shift;
+    $self->GotoItem(0);
 }
 
 sub GotoItem {
-  my $self = shift;
-  my $item = shift;
+    my $self = shift;
+    my $item = shift;
 
-  die "We currently only support going to the First item"
-	unless $item == 0;
+    die "We currently only support going to the First item"
+        unless $item == 0;
 
-  $self->{curp} = 0;
-  $self->{item} = 0;
-  $self->{data}[0]->GotoItem(0);
+    $self->{curp} = 0;
+    $self->{item} = 0;
+    $self->{data}[0]->GotoItem(0);
 
-  return $item;
+    return $item;
 }
 
 =head2 IsLast
@@ -191,7 +191,7 @@ Returns true if the current row is the last record in the set.
 sub IsLast {
     my $self = shift;
 
-	$self->{item} == $self->Count ? 1 : undef;
+    $self->{item} == $self->Count ? 1 : undef;
 }
 
 =head2 ItemsArrayRef
@@ -207,13 +207,13 @@ sub ItemsArrayRef {
 
     return [] unless $self->Count;
 
-	$self->GotoFirstItem();
-	my @ret;
-	while( my $r = $self->Next ) {
-	  push @ret, $r;
-	}
+    $self->GotoFirstItem();
+    my @ret;
+    while( my $r = $self->Next ) {
+        push @ret, $r;
+    }
 
-	return \@ret;
+    return \@ret;
 }
 
 =head1 AUTHOR
diff --git a/lib/DBIx/SearchBuilder/Unique.pm b/lib/DBIx/SearchBuilder/Unique.pm
index 75bd48e..8447a4d 100644
--- a/lib/DBIx/SearchBuilder/Unique.pm
+++ b/lib/DBIx/SearchBuilder/Unique.pm
@@ -35,7 +35,7 @@ DBIx::SearchBuilder::Unique - Ensure uniqueness of records in a collection
     my $collection = Foo::Collection->New();
     $collection->SetupComplicatedJoins;
     $collection->OrderByMagic;
-    
+
     while (my $thing = $collection->Next) {
         # $thing is going to be distinct
     }

-----------------------------------------------------------------------

Summary of changes:
 lib/DBIx/SearchBuilder.pm                 |  85 +++---
 lib/DBIx/SearchBuilder/Handle.pm          | 145 +++++-----
 lib/DBIx/SearchBuilder/Handle/Informix.pm |  54 ++--
 lib/DBIx/SearchBuilder/Handle/ODBC.pm     |   4 +-
 lib/DBIx/SearchBuilder/Handle/Oracle.pm   | 136 ++++-----
 lib/DBIx/SearchBuilder/Handle/Pg.pm       |  53 ++--
 lib/DBIx/SearchBuilder/Handle/SQLite.pm   |  10 +-
 lib/DBIx/SearchBuilder/Handle/Sybase.pm   |  15 +-
 lib/DBIx/SearchBuilder/Handle/mysql.pm    |  20 +-
 lib/DBIx/SearchBuilder/Record.pm          | 466 +++++++++++++++---------------
 lib/DBIx/SearchBuilder/Record/Cachable.pm |   9 +-
 lib/DBIx/SearchBuilder/SchemaGenerator.pm | 172 +++++------
 lib/DBIx/SearchBuilder/Union.pm           |  70 ++---
 lib/DBIx/SearchBuilder/Unique.pm          |   2 +-
 14 files changed, 609 insertions(+), 632 deletions(-)


hooks/post-receive
-- 
dbix-searchbuilder


More information about the Bps-public-commit mailing list