I have added a view to list the users on my site sorted by the 'Profile: Post Count' field in descending order.

There appears to be problems with the sorting, e.g. a user with 3 posts is getting ranked higher than a user with 14 posts. I think this is because the view is doing a string comparison rather than an integer comparison on the user_post_count.value attribute.

This is the SQL query which is being generated:
SELECT node.nid, user_post_count.value AS user_post_count_value, users.name AS users_name, users.uid AS users_uid FROM {node} node INNER JOIN {users} users ON node.uid = users.uid LEFT JOIN {profile_values} user_post_count ON users.uid = user_post_count.uid AND user_post_count.fid = '1' WHERE (node.type IN ('userinfo')) ORDER BY user_post_count_value DESC

If user_post_count.value is changed to CAST(user_post_count.value AS signed) then the sorting works as expected when I try this at the command-line.

Comments

liam mcdermott’s picture

Agreed on what's causing the problem. It was a bad design decision to use profile.module, I've fixed this in the Drupal 6-dev version of this module. Unfortunately I don't have time to backport the changes to the Drupal 5 version.

The only way I can see this getting fixed is if someone pays me (or someone else) some cash to backport the changes from 6-dev. :(

liam mcdermott’s picture

Status: Active » Closed (won't fix)

Changing this to won't fix for the time being.