Hi!
I have developed and currently maintaining the Nodefeedback module. It uses VotingAPI to store the answers to the questions as option voting.
The issue is that VotingAPI aggregation function names the function as option-0, option-1, etc. - using the hyphen "-" in the name. Then, using hook_votingapi_metadata_alter(), I'm describing the aggregation function:
$data['functions']['option-0'] = array(
'name' => t('Number of answers "Yes" (0)'),
'description' => t('Some description.'),
'module' => 'nodefeedback',
);
And when adding relationship I'm choosing the aggregation function described above. After adding a value of this function to the Views column - the generated query can't be executed and Views automatically adds:
LEFT JOIN votingapi_cache votingapi_cache_node_points_resolution_option-0 ON node.nid = votingapi_cache_node_points_resolution_option-0.content_id AND (votingapi_cache_node_points_resolution_option-0.content_type = 'node' AND votingapi_cache_node_points_resolution_option-0.value_type = 'points' AND votingapi_cache_node_points_resolution_option-0.tag = 'resolution' AND votingapi_cache_node_points_resolution_option-0.function = 'option-0')
which is not a valid MySQL (as it has hyphens in the table alias).
Hope you can help here. The obvious fix for it would be changing the hyphen to the underscore symbol "_", but then we need to figure out updating of all the already calculated aggregations.
Thanks
AndyB
Comment | File | Size | Author |
---|---|---|---|
#1 | 937998.patch | 481 bytes | mauritsl |
Comments
Comment #1
mauritsl CreditAttribution: mauritsl commentedGot the same error.
The alias is generated by the votingapi module itself. A simple preg_replace can fix the problem. The patch attached fixed this problem for me (at least for 2.3).
Comment #2
mauritsl CreditAttribution: mauritsl commentedA usecase and view export is available at #960438: Sorting by "options" results seems to be broken.
Comment #3
vikstrous CreditAttribution: vikstrous commentedThank you! I was having the same problem. This seems like the best solution to me. I don't know why it wasn't done earlier.
Comment #4
eaton CreditAttribution: eaton commentedI've made this fix to the D7 version and will be backporting it as soon as the D7 release is out. Thanks!
Comment #5
legolasboDrupal 6 is no longer supported. Closing old issues to clean up the issue queue.
Please reopen and update this issue if this is still an issue in the D7 or D8 version.