[Rt-commit] r2944 - in DBIx-SearchBuilder/trunk: . SearchBuilder t

glasser at bestpractical.com glasser at bestpractical.com
Tue May 24 13:07:14 EDT 2005


Author: glasser
Date: Tue May 24 13:07:14 2005
New Revision: 2944

Modified:
   DBIx-SearchBuilder/trunk/   (props changed)
   DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm
   DBIx-SearchBuilder/trunk/t/01records.t
Log:
 r32882 at tin-foil:  glasser | 2005-05-24 11:49:05 -0400
 From Ruslan: for numeric types, make the empty check be "null or 0", not "null or ''"


Modified: DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm	(original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder/Record.pm	Tue May 24 13:07:14 2005
@@ -986,7 +986,16 @@
 		push @bind, $value;
 	}
 	else {
-		push @phrases, "($key IS NULL OR $key = '')";
+       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, '';
+       }
+
 	}
     }
     

Modified: DBIx-SearchBuilder/trunk/t/01records.t
==============================================================================
--- DBIx-SearchBuilder/trunk/t/01records.t	(original)
+++ DBIx-SearchBuilder/trunk/t/01records.t	Tue May 24 13:07:14 2005
@@ -8,7 +8,7 @@
 BEGIN { require "t/utils.pl" }
 our (@AvailableDrivers);
 
-use constant TESTS_PER_DRIVER => 64;
+use constant TESTS_PER_DRIVER => 65;
 
 my $total = scalar(@AvailableDrivers) * TESTS_PER_DRIVER;
 plan tests => $total;
@@ -169,9 +169,8 @@
 	$id = $rec->Create( Name => 'Obra', Phone => undef );
 	ok( $id, "new record");
 	$rec = TestApp::Address->new($handle);
-#	$rec->LoadByCols( Name => 'Obra', Phone => undef, EmployeeId => '' );
-#	Fails under Pg
-#    is( $rec->id, $id, "loaded record by empty value" );
+	$rec->LoadByCols( Name => 'Obra', Phone => undef, EmployeeId => '' );
+    is( $rec->id, $id, "loaded record by empty value" );
 
 # __Set error paths
 	$rec = TestApp::Address->new($handle);


More information about the Rt-commit mailing list