views calc not generating a correct query
enboig - September 24, 2009 - 08:59
| Project: | Views Calc |
| Version: | 6.x-1.3 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I have created my custom content-type; defined views and everything is working when viewing a table view; but when I try using views calc to get a total I recive:
user warning: Unknown column 'node_cc_assentaments_linies.valor_desglossat' in 'field list' query: SELECT MAX('') AS node_cc_assentaments_linies_lid, MAX('SUM') AS TOTAL_SUM, MAX('') AS linia_projectes_nid, MAX('') AS node_cc_assentaments_linies_comptes_comptables_compte_comptable_nom, MAX('') AS node_cc_assentaments_linies_concepte, SUM(node_cc_assentaments_linies.valor_desglossat) AS node_cc_assentaments_linies_valor FROM cc2_node node LEFT JOIN cc2_node_cc_assentaments_linies node_cc_assentaments_linies ON node.nid = node_cc_assentaments_linies.assentament_nid LEFT JOIN cc2_node linia_projectes2 ON node_cc_assentaments_linies.projecte_nid = linia_projectes2.nid LEFT JOIN cc2_node_cc_projects linia_projectes ON linia_projectes2.vid = linia_projectes.vid LEFT JOIN cc2_cc_comptes_comptables node_cc_assentaments_linies_comptes_comptables ON node_cc_assentaments_linies.compte_comptable = node_cc_assentaments_linies_comptes_comptables.compte_comptable_codi INNER JOIN cc2_node_access na ON na.nid = node.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 494 AND na.realm = 'wu_comptacau') OR (na.gid = 494 AND na.realm = 'wu_comptacau') OR (na.gid = 494 AND na.realm = 'wu_comptacau <###> 2010') OR (na.gid = 494 AND na.realm = 'wu_comptacau <###> 2010'))) AND ( (node.type in ('cc_pressupost')) AND (linia_projectes.nid = 1220) AND (node.nid IN (1242,1243)) )ORDER BY node_cc_assentaments_linies_comptes_comptables_compte_comptable_nom ASC LIMIT 0, 10 in /home/escolcat/public_html/comptacau2/sites/all/modules/views/includes/view.inc on line 755.But despite of this, the view is ok, I just don't get any total below.
I don't know how to track this error; maybe I should add something to table definition?
My view export is:
$view = new view;
$view->name = 'cc_pressupostos';
$view->description = 'Llista dels assentaments del projecte marcats com a pressuposts';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
'lid' => array(
'label' => 'Identificador de línia',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'set_precision' => FALSE,
'precision' => 0,
'decimal' => '.',
'separator' => '',
'prefix' => '',
'suffix' => '',
'exclude' => 1,
'id' => 'lid',
'table' => 'node_cc_assentaments_linies',
'field' => 'lid',
'relationship' => 'none',
),
'nid' => array(
'label' => 'Nid del projecte de la línia',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'set_precision' => FALSE,
'precision' => 0,
'decimal' => '.',
'separator' => '',
'prefix' => '',
'suffix' => '',
'exclude' => 1,
'id' => 'nid',
'table' => 'linia_projectes',
'field' => 'nid',
'relationship' => 'none',
),
'compte_comptable_nom' => array(
'label' => 'Tipus',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'exclude' => 0,
'id' => 'compte_comptable_nom',
'table' => 'node_cc_assentaments_linies_comptes_comptables',
'field' => 'compte_comptable_nom',
'relationship' => 'none',
),
'concepte' => array(
'label' => 'Concepte',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'exclude' => 0,
'id' => 'concepte',
'table' => 'node_cc_assentaments_linies',
'field' => 'concepte',
'relationship' => 'none',
),
'valor_desglossat' => array(
'label' => 'Valor',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'set_precision' => 1,
'precision' => '2',
'decimal' => ',',
'separator' => '.',
'prefix' => '',
'suffix' => '€',
'exclude' => 0,
'id' => 'valor_desglossat',
'table' => 'node_cc_assentaments_linies',
'field' => 'valor_desglossat',
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'nid' => array(
'default_action' => 'ignore',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'Tot',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'none',
'validate_fail' => 'not found',
'break_phrase' => 0,
'not' => 0,
'id' => 'nid',
'table' => 'linia_projectes',
'field' => 'nid',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
'16' => 0,
'18' => 0,
'28' => 0,
'7' => 0,
'25' => 0,
'26' => 0,
'15' => 0,
'6' => 0,
'8' => 0,
'27' => 0,
'17' => 0,
'23' => 0,
'5' => 0,
'4' => 0,
'24' => 0,
'13' => 0,
'14' => 0,
'3' => 0,
'9' => 0,
),
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'cc_despesa' => 0,
'cc_ingres' => 0,
'cc_traspas' => 0,
'cc_pagament' => 0,
'cc_cobrament' => 0,
'cc_pressupost' => 0,
'cc_client' => 0,
'cc_banc' => 0,
'cc_caixa' => 0,
'cc_projecte' => 0,
'cc_proveidor' => 0,
'cc_quadern' => 0,
'page' => 0,
'story' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
),
));
$handler->override_option('filters', array(
'type' => array(
'operator' => 'in',
'value' => array(
'cc_pressupost' => 'cc_pressupost',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 50);
$handler->override_option('use_pager', '1');
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
'grouping' => '',
'override' => 1,
'sticky' => 0,
'order' => 'asc',
'columns' => array(
'lid' => 'lid',
'nid' => 'nid',
'valor_desglossat' => 'valor_desglossat',
'compte_comptable' => 'compte_comptable',
'compte_comptable_nom' => 'compte_comptable_nom',
),
'info' => array(
'lid' => array(
'sortable' => 0,
'separator' => '',
),
'nid' => array(
'sortable' => 0,
'separator' => '',
),
'valor_desglossat' => array(
'sortable' => 0,
'separator' => '',
),
'compte_comptable' => array(
'sortable' => 0,
'separator' => '',
),
'compte_comptable_nom' => array(
'sortable' => 0,
'separator' => '',
),
),
'default' => '-1',
));
$handler = $view->new_display('page', 'Pàgina', 'page_1');
$handler->override_option('style_plugin', 'views_calc');
$handler->override_option('style_options', array(
'grouping' => '',
'override' => 1,
'sticky' => 0,
'order' => 'asc',
'columns' => array(
'lid' => 'lid',
'nid' => 'nid',
'compte_comptable_nom' => 'compte_comptable_nom',
'concepte' => 'concepte',
'valor_desglossat' => 'valor_desglossat',
),
'info' => array(
'lid' => array(
'sortable' => 0,
'separator' => '',
'justification' => 'views_calc_justify_none',
'has_calc' => 0,
'calc' => array(),
),
'nid' => array(
'sortable' => 0,
'separator' => '',
'justification' => 'views_calc_justify_none',
'has_calc' => 0,
'calc' => array(),
),
'compte_comptable_nom' => array(
'sortable' => 1,
'separator' => '',
'justification' => 'views_calc_justify_none',
'has_calc' => 0,
'calc' => array(),
),
'concepte' => array(
'sortable' => 1,
'separator' => '',
'justification' => 'views_calc_justify_none',
'has_calc' => 0,
'calc' => array(),
),
'valor_desglossat' => array(
'sortable' => 1,
'separator' => '',
'justification' => 'views_calc_justify_right',
'has_calc' => 1,
'calc' => array(
'SUM' => 'SUM',
),
),
),
'default' => 'compte_comptable_nom',
'detailed_values' => '0',
));
$handler->override_option('path', 'cc_compacau/projectes/pressupostos');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
));thanks

#1
I get the same error message. Subscribing.
#2
I'm not sure if this is relevant but I changed the Style (under Basic Settings) to "Views Calc Table" and using the in-build calculation under the Fields (instead of creating my own view calc field) and it seems to work.
It might help.
#3
I cannot find the "in-build calculation" otpion, where is it?
#4
Sorry, not clear enough.
Under the settings for the "Views Calc Table", tick the box against "display calculation".