When using a Views Calc Table to display Ubercart orders, the dblog would contain errors about invalid SQL syntax related to this part of the query:

AND (node.nid IN (,,,,,,,,,,,,,,,,,,,,,,,,))

The error is because the view doesn't involve nodes, it involves Ubercart orders. The attached patch changes two lines of views_calc_table.inc to not assume the node table and node ids when calculating subtotals. Instead it uses the view's base_table and base_field members (which are "node.nid" for nodes and "uc_order.order_id" for Ubercart orders).

I built the patch against 6.x-1.3, and it applies cleanly to 6.x-1.x-dev (2009-Nov-07).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikec’s picture

3dloco’s picture

Status: Active » Reviewed & tested by the community

Thanks mikec your patch worked for me!

basvredeling’s picture

Worked for me too, not for ubercart stuff but for time_tracker entries. If you create a view for something besides nodes. say: node revisions, users or taxonomy terms, the entry id isn't "nid" either. This patch should work for every alternative field id for which a views result is generated.
For the real nitpickers out there, the nomenclature in the code should be adapted likewise. So instead of a $nid[] array, a $base_field[] array (or something like it) should be populated.

Thanks mikec.

miro_dietiker’s picture

I duplicated this by
#776848: Calculate subtotals for non-node views, e.g., Ubercart orders

Providing patch that adds it a little more consistent.

miro_dietiker’s picture

Status: Reviewed & tested by the community » Fixed
FileSize
2.69 KB

Committing attached patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.