
[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
begin
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
-
Dan Kubb (dkubb) January 8th, 2009 @ 02:47 PM
- Assigned user set to Michael Klishin (antares)
-
Michael Klishin (antares) January 9th, 2009 @ 05:57 PM
- State changed from unconfirmed to confirmed
What do you think should be returned? You diff above states nil, the rest of the method returns empty array in case of other possible failures. I am going to make it return an empty array, but maybe you have some other opinion?
-
-
Michael Klishin (antares) January 10th, 2009 @ 04:00 AM
- State changed from confirmed to resolved
-
Dan Kubb (dkubb) January 11th, 2009 @ 12:15 PM
(from [12f0d1a6aea233d0ab0de42f1394eb8c534f9a65]) [dm-types] Return empty array for a flag type property when value is nil or <= 0 [#754 resolved] http://github.com/dkubb/dm-more/...
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.
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
Tags
Referenced by
-
638 [PATCH] Avoid FloatDomainError when 0 is passed into Flag.load(). Duplicate of #754 that I just resolved. Let me know if th...
-
754 [PATCH] Problem with empty flag (from [12f0d1a6aea233d0ab0de42f1394eb8c534f9a65]) [dm-typ...