Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The contextual filter will return no results when the filter value is an actual float, i.e. 200.202
. With integer values it works fine.
Steps to reproduce:
- Clean install of Drupal
- Add a field of type Float (list) to a content type with both integer and float allowed values
- Add some content using different values for this field
- Add a view with a contextual filter on this field
- Enter arguments in the preview area
- See how it doesn't work for actual float values
I hope this is trivial to fix :)
Comments
Comment #1
a.ross CreditAttribution: a.ross commentedFWIW, after reproducing on a clean install, I've done
git checkout 7.x-3.5
all the way back to 7.x-3.0 and the bug is present in all versions.Comment #2
a.ross CreditAttribution: a.ross commentedAlso, with a normal float field it works as expected. Only the List (Float) field type is affected.
Comment #3
a.ross CreditAttribution: a.ross commentedUgh, the funny thing is that the query looks mighty fine:
Comment #4
a.ross CreditAttribution: a.ross commenteddouble post
Comment #4.0
a.ross CreditAttribution: a.ross commentedUpdated issue summary.
Comment #5
a.ross CreditAttribution: a.ross commentedIt turns out that the List (float) field type stores its values as float in the database. And at least in the case of MySQL, problems like this are apparently expected behavior: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html
A way to work around this problem would be to use a decimal field. But that may not work in every use-case, since a decimal is basically an integer and, therefore, doesn't allow for very high values. Also, it appears that a List (decimal) field doesn't really exist at all...