Permalink
Browse files

Better check if a proper list of values was passed to where

  • Loading branch information...
1 parent 119faf9 commit e4c0b5e9fc3e9fa6f097f2f231f5eec9efbf8249 Sergey committed Jan 6, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 private/system/lib/Stuffed/System/Database.pm
@@ -157,11 +157,11 @@ sub where {
my $q_field_name = $q_prefix . quote($field_name, start => '`');
- if (ref $in->{$field_name} eq 'ARRAY') {
+ if ( ref $in->{$field_name} eq 'ARRAY' and @{ $in->{$field_name} } ) {
push @where_arr, $q_field_name . ' in (' . join(',', map { $system->dbh->quote($_) } @{$in->{$field_name}}) . ')';
}
- elsif (ref $in->{$field_name} eq 'CODE') {
+ elsif ( ref $in->{$field_name} eq 'CODE' ) {
push @where_arr, $q_field_name . $in->{$field_name}->();
}
@@ -247,7 +247,7 @@ sub delete {
my $table = $self->{table} || return undef;
my $where_str = $self->where( @_ );
-
+
# we will not delete without a condition (all rows)
return undef if false( $where_str );

0 comments on commit e4c0b5e

Please sign in to comment.