Subject: | Rose::DB::Object use of each without keys |
Date: | Wed, 14 Mar 2012 14:54:46 -0500 |
To: | bug-Rose-DB-Object [...] rt.cpan.org |
From: | Graham Barr <gbarr [...] pobox.com> |
Rose::DB::Object makes use of each, but fails to reset the internal iterator before doing so. It also has a condition that can break out of the loop meaning that if the same code is called again it will not see all key/values from the hash.
for example, from Rose/DB/Object.pm
my $column_map = $relationship->column_map;
my @query;
while(my($local_column, $foreign_column) = each(%$column_map))
{
my $method = $meta->column_accessor_method_name($local_column);
my $value = $self->$method();
# XXX: Comment this out to allow null keys
next REL unless(defined $value);
push(@query, $foreign_column => $value);
}
As $relationship->column_map always returns the same has, the next REL statement can cause problems for subsequent calls
The attached patch is against version 0.794, the code seems unchanged in later versions but I have not installed it yet.
A.so I only checked and patched Rose/DB/Object.pm as that was where I was having problems, the same scenario may occur in other modules.
Message body is not shown because sender requested not to inline it.