#754 ✓resolved

[PATCH] Problem with empty flag

Reported by Roman | January 8th, 2009 @ 04:12 AM

diff --git a/dm-types/lib/dm-types/flag.rb b/dm-types/lib/dm-types/flag.rb
index f9ca16f..4f189aa 100644
--- a/dm-types/lib/dm-types/flag.rb
+++ b/dm-types/lib/dm-types/flag.rb
@@ -32,6 +32,7 @@ module DataMapper
           matches = []
+          return if value <= 0
           0.upto((Math.log(value) / Math.log(2)).ceil) do |i|
             pow = 2 ** i
             matches << flag_map[pow] if value & pow == pow

Without the patch Math.log(value) returns -Infinity for value = 0 and there is an exception.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket


Referenced by