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

a.ross’s picture

FWIW, 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.

a.ross’s picture

Also, with a normal float field it works as expected. Only the List (Float) field type is affected.

a.ross’s picture

Ugh, the funny thing is that the query looks mighty fine:

SELECT node.created AS node_created, node.nid AS nid
FROM 
{node} node
LEFT JOIN {field_data_field_floats_} field_data_field_floats_ ON node.nid = field_data_field_floats_.entity_id AND (field_data_field_floats_.entity_type = 'node' AND field_data_field_floats_.deleted = '0')
WHERE (( (field_data_field_floats_.field_floats__value = '200.202' ) )AND(( (node.status = '1') AND (node.type IN  ('page')) )))
ORDER BY node_created DESC
LIMIT 10 OFFSET 0
a.ross’s picture

double post

a.ross’s picture

Issue summary: View changes

Updated issue summary.

a.ross’s picture

Status: Active » Closed (works as designed)

It 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...