Major error occurring on sums

jim0203 - May 10, 2009 - 10:19
Project:Views Calc
Version:6.x-1.2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Seemingly whenever I try to sum anything on my remote server, I get the following error message:

<?php
   
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'DISTINCT(node.nid)
FROM node node
WHERE node.type in ('
3_month_refresher_repo' at line 3 query: SELECT MAX('')
AS node_created, MAX('
SUM') AS TOTAL_SUM, MAX('') AS DISTINCT(node.nid)
FROM node node
WHERE node.type in ('
3_month_refresher_report', '6_month_refresher_report', 'additional_report', 'assessment_report', 'cancelled_lesson', 'itq_assessment', 'itq_lesson', 'regular_lesson', 'remote_installation', 'remote_lesson_report', 'seminar) in /home/ucandoit/public_html/sites/all/modules/views/includes/view.inc on line 735.
   
* warning: Invalid argument supplied for foreach() in /home/ucandoit/public_html/sites/all/modules/views_calc/theme.inc on line 180.
   
* warning: Invalid argument supplied for foreach() in /home/ucandoit/public_html/sites/all/modules/views_calc/theme.inc on line 180.
?>

I can see the problem in the query: it's on the first line that starts "WHERE". 3_month_refresher_repo should read 3_month_refresher_report, as it does further on in the code.

I have no idea what's going on here. When I change the view so that it doesn't select nodes of type 3_month_refresher_report (but does select all the others) the problem seems to disappear. I thought it might be because of the length of the node type, but 6_month_refresher_report has exactly the same length.

The only thing that is unique about 3_month_refresher_report is that it is first in the list of node types.

Line 735 of view.inc is

<?php
$result
= db_query($query, $args);
?>

So it looks like the problem lies in how Views is building $query (or, more to the point, how Views Calc is telling it to build it). I know next to nothing about the Views and Views Calc code so this is all I can do for the moment.

D6.9
Views 2.5
Views Calc 1.2
CCK 2.1

#1

KarenS - May 10, 2009 - 10:30
Status:active» postponed (maintainer needs more info)

You have the wrong bug identified. That word is just cut off in the message, not in the query. Your query is broken by the DISTINCT, which indicates you're using some kind of node access system and you set up your view to show distinct nodes. That's a known core bug that I have no control over. Remove the 'Distinct' option from your view and it should work fine.

#2

jim0203 - May 10, 2009 - 10:40
Status:postponed (maintainer needs more info)» active

Workaround: create a new content type so that 3_month_refresher_report isn't first in the list. Leave that content type deselected when building the view, and everything works like a charm!

#3

KarenS - May 10, 2009 - 10:49
Status:active» postponed (maintainer needs more info)

I have no idea what the problem is because I know nothing about what's in this view or what those fields are or what you're doing with the view or what queries your new view created or anything else.

Not a single thing I can do with this report as it stands.

#4

jim0203 - May 10, 2009 - 15:21

Hi Karen,

I've not selected "distinct" in the view in question. I am using a node access system though; I've got specific privileges set so that certain users view only certain node types. Does this help? What other information would be useful to you?

#5

KarenS - May 17, 2009 - 11:17

The node access bug is the bug, nothing I can do about it. When I say I need more information I need things like an export of your view and information about what kind of fields you are using. But in this case there's no point in providing all that because it's the node access bug, and I can't do anything about that. You can tell that for sure if you disable your node access system and the view works correctly.

#6

KarenS - June 12, 2009 - 13:30
Status:postponed (maintainer needs more info)» closed

No response so I can't do anything with this report, and it is not the latest code anyway.

 
 

Drupal is a registered trademark of Dries Buytaert.