[Jifty-commit] r2955 - in Jifty-DBI/trunk: lib/Jifty/DBI
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Tue Mar 13 16:28:32 EDT 2007
Author: clkao
Date: Tue Mar 13 16:28:32 2007
New Revision: 2955
Modified:
Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
Jifty-DBI/trunk/t/02records_cachable.t
Log:
Make load_by_cols work when a given value is undef by turning
the query into IS NULL.
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 Tue Mar 13 16:28:32 2007
@@ -894,6 +894,8 @@
push @phrases, "$key $op $function";
push @bind, $value;
+ } elsif (!defined $hash{$key}) {
+ push @phrases, "$key IS NULL";
} else {
push @phrases, "($key IS NULL OR $key = ?)";
my $column = $self->column($key);
Modified: Jifty-DBI/trunk/t/02records_cachable.t
==============================================================================
--- Jifty-DBI/trunk/t/02records_cachable.t (original)
+++ Jifty-DBI/trunk/t/02records_cachable.t Tue Mar 13 16:28:32 2007
@@ -76,16 +76,9 @@
Jifty::DBI::Record::Cachable->flush_cache;
ok( $rec->load_by_cols( Phone => undef ), "Loaded the record" );
- TODO:
- {
- local $TODO = "Loading undef PKs doesn't work properly";
- is( $rec->name, 'UndefPhone', "UndefPhone record" );
- }
-
- # XXX: JDBI turns undef into '' which makes me really sad //ruz
- # test should be:
- # is($rec->phone, undef, "Phone number is undefined");
- is( $rec->phone, '', "Phone number is undefined" );
+ is( $rec->name, 'UndefPhone', "UndefPhone record" );
+
+ is( $rec->phone, undef, "Phone number is undefined" );
ok( $rec->load_by_cols( Phone => '' ), "Loaded the record" );
is( $rec->name, 'EmptyPhone', "EmptyPhone record" );
More information about the Jifty-commit
mailing list