SUMMARY:
The purpose of db_distinct_field() is, for example, to turn:
SELECT ... node.nid ...
into:
SELECT ... DISTINCT(node.nid) ...
However, when there's a table in the query that happens to end in 'node', as in--
SELECT ... somenode.nid ...
then db_distinct_field() would turn the query into some invalid SQL:
SELECT ... some DISTINCT(node.nid) ...
This bug causes the Views Fusion module to fail under certain circumstances.
SOLUTION:
The solution is simple: to make the regexp recognize the table name only when it's by itself. I'm attaching a patch.
Comments
Comment #1
aclight commentedThis bug affects the project_issue module if a node access module is also enabled (see #172035-11: Error getting statistics on project issues for a bit of analysis). I've attached two patches for this, one for D5 and one for D6. The D5 patch is just a reroll from the right directory--I didn't make any changes to the code there. The D6 patch is untested, because I don't have a good way to test right now, but I've tested the D5 patch and it works well and fixes the problem. So I'm marking this as RTBC for the D5 patch.
Comment #2
aclight commentedI just realized that #206224: db_distinct_field mangles some queries is actually the same bug, and that issue's older, so I'm marking this one as a duplicate of that issue. I've uploaded the same two patches to that issue.