I created a view that is not displaying content in one particular column. After much trial and error, I determined that it is because there is a filter set for the corresponding field with Is none of set to two items. Changing it to one item does not correct the problem, but removing the filter or setting it to Is all of or Is one of causes it to behave as expected. I tried clearing the views cache as well as rebuilding the view from scratch.

The field in question is a text field, but it also happened when I had it set to an Integer field.

My view export and SQL queries are below:

$view = new view;
$view->name = 'Products';
$view->description = '';
$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(
  'title' => array(
    'label' => 'Catalog #',
    'link_to_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
  'field_name_value' => array(
    'label' => 'Description',
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_name_value',
    'table' => 'node_data_field_name',
    'field' => 'field_name_value',
    'relationship' => 'none',
  ),
  'field_size_value' => array(
    'id' => 'field_size_value',
    'table' => 'node_data_field_size',
    'field' => 'field_size_value',
    'label' => 'Size',
  ),
  'field_storage_temperature_value' => array(
    'label' => 'Storage',
    'link_to_node' => 0,
    'label_type' => 'custom',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_storage_temperature_value',
    'table' => 'node_data_field_storage_temperature',
    'field' => 'field_storage_temperature_value',
    'relationship' => 'none',
  ),
  'field_biohazard_value' => array(
    'label' => 'Bio Cat.',
    'link_to_node' => 0,
    'label_type' => 'custom',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_biohazard_value',
    'table' => 'node_data_field_biohazard',
    'field' => 'field_biohazard_value',
    'relationship' => 'none',
  ),
  'field_status_value' => array(
    'label' => '',
    'link_to_node' => 0,
    'label_type' => 'widget',
    'format' => 'default',
    'multiple' => array(
      'group' => TRUE,
      'multiple_number' => '',
      'multiple_from' => '',
      'multiple_reversed' => FALSE,
    ),
    'exclude' => 0,
    'id' => 'field_status_value',
    'table' => 'node_data_field_status',
    'field' => 'field_status_value',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('sorts', array(
  'title' => array(
    'order' => 'ASC',
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'name' => array(
    'default_action' => 'ignore',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'glossary' => 0,
    'limit' => '0',
    'case' => 'none',
    'path_case' => 'none',
    'transform_dash' => 0,
    'add_table' => 0,
    'require_value' => 0,
    'id' => 'name',
    'table' => 'term_data',
    'field' => 'name',
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'webform' => 0,
      'blog' => 0,
      'faq' => 0,
      'image' => 0,
      'distributor' => 0,
      'event' => 0,
      'job_position' => 0,
      'page' => 0,
      'product' => 0,
      'story' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '4' => 0,
      '1' => 0,
      '2' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'product' => 'product',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
  'field_status_value' => array(
    'operator' => 'not',
    'value' => array(
      'Discontinued-No Longer Available' => 'Discontinued-No Longer Available',
      'Discontinued-Custom' => 'Discontinued-Custom',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'field_status_value',
    'table' => 'node_data_field_status',
    'field' => 'field_status_value',
    'relationship' => 'none',
    'reduce_duplicates' => 0,
    'override' => array(
      'button' => 'Override',
    ),
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
  'role' => array(),
  'perm' => '',
));
$handler->override_option('title', 'Products');
$handler->override_option('header_format', '1');
$handler->override_option('footer_format', '1');
$handler->override_option('empty_format', '1');
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', '0');
$handler->override_option('use_pager', '1');
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
  'grouping' => '',
  'override' => 0,
  'sticky' => 1,
  'order' => 'asc',
  'columns' => array(
    'field_status_value' => 'field_status_value',
    'title' => 'title',
    'field_name_value' => 'field_name_value',
    'field_size_value' => 'field_size_value',
    'field_storage_temperature_value' => 'field_storage_temperature_value',
    'field_biohazard_value' => 'field_biohazard_value',
  ),
  'info' => array(
    'field_status_value' => array(
      'sortable' => 1,
      'separator' => '',
    ),
    'title' => array(
      'sortable' => 1,
      'separator' => '',
    ),
    'field_name_value' => array(
      'sortable' => 1,
      'separator' => '',
    ),
    'field_size_value' => array(
      'sortable' => 0,
      'separator' => '',
    ),
    'field_storage_temperature_value' => array(
      'sortable' => 0,
      'separator' => '',
    ),
    'field_biohazard_value' => array(
      'sortable' => 0,
      'separator' => '',
    ),
  ),
  'default' => '-1',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'products');
$handler->override_option('menu', array(
  'type' => 'normal',
  'title' => 'Products',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'weight' => '0',
));
SELECT node.nid AS nid,
   node.title AS node_title,
   node_data_field_name.field_name_value AS node_data_field_name_field_name_value,
   node_data_field_name.field_name_format AS node_data_field_name_field_name_format,
   node_data_field_name.nid AS node_data_field_name_nid,
   node.type AS node_type,
   node_data_field_name.field_size_value AS node_data_field_name_field_size_value,
   node_data_field_name.field_storage_temperature_value AS node_data_field_name_field_storage_temperature_value,
   node_data_field_name.field_biohazard_value AS node_data_field_name_field_biohazard_value,
   node_data_field_status.field_status_value AS node_data_field_status_field_status_value,
   node_data_field_status.nid AS node_data_field_status_nid
 FROM node node 
 LEFT JOIN content_type_product node_data_field_status ON node.vid = node_data_field_status.vid AND (node_data_field_status.field_status_value = 'Discontinued-No Longer Available' OR node_data_field_status.field_status_value = 'Discontinued-Custom')
 LEFT JOIN content_type_product node_data_field_name ON node.vid = node_data_field_name.vid
 WHERE (node.type in ('product')) AND (node_data_field_status.field_status_value IS NULL)
   ORDER BY node_title ASC
CommentFileSizeAuthor
#4 cck_views_filter_allowed.patch4.52 KByched

Comments

merlinofchaos’s picture

Status: Active » Postponed (maintainer needs more info)

I'm sorry, I'm not understanding what exactly is wrong from your description. Can you please provide specific examples of what it should display versus what it actually displays and name the specific filters you think are causing this?

jimmyobomsawin’s picture

I have a field, "Production Status" or field_status_value.

It is an optional text field with the following possible choices: Discontinued-No Longer Available', 'Discontinued-Custom', 'Discontinued but remaining inventory is available', or 'New Product'

I set up a table view with a filter set to "Is None Of" and the first two options above are selected.

I expect that the table shows only items that have the field set to 'Discontinued but remaining inventory is available' 'New Product' or those items which do not have the field set. I also expect that the field data is visible in the column for "Production Status"

While the correct items do display in the table, the entire "Production Status" column is blank, even for those items which have the third and fourth items selected.

While I could make a fifth option of 'current product' and make the field required so that I can choose "Is One Of" I don't want to do that because I only want data to be seen in that field when it is not the norm (current product).

merlinofchaos’s picture

Project: Views (for Drupal 7) » Content Construction Kit (CCK)
Version: 6.x-2.0-rc5 » 6.x-2.x-dev
Component: Views Data » Views Integration
Status: Postponed (maintainer needs more info) » Active

Ok, I've reproduced and identified the problem.

The problem is that CCK is using a mechanism for this that only works for multiple fields; it doesn't apparently work for single fields because it tries to re-join the table and that is both inefficient and causing data loss.

For the non-multiple field case, CCK should just be adding a simple IN or NOT IN filter like node type does, based upon views_handler_filter_operator_in

yched’s picture

Status: Active » Needs review
StatusFileSize
new4.52 KB

You mean something like this ? (I got absolutely no time to test this right now :-( )

Trouble with this is :
- when the (cck) field gets changed from multiple to single, the filter will break with error messages, because it doesn't find its operators anymore - I guess other views stuff can probably 'stop working' when switching a field's cardinality, but AFAIK, none that would cause PHP errors
- this will break existing views using the filter with non-multiple fields - when I changed stuff in that area between RC and final release, this caused a mini-tsunami...

merlinofchaos’s picture

Hm. Yea, that's tough. That means you need to make your handler smart enough to a) be able to tell the difference and b) act appropriately even if the cardinality has changed. Ouch. That's tough. :/

jimmyobomsawin’s picture

Version: 6.x-2.x-dev » 6.x-2.4

I found a workaround, although it's an ugly hack. I used the computed value CCK plugin to create an additional field that simply duplicates the value of the desired field, set it to store in the database, and now I can use that field in the view with no problems.

karenann’s picture

Version: 6.x-2.4 » 6.x-2.9

I experienced the same (and a related) issue. To explain:

~ I have a field "Status", Text, Select List, 1 value, Not Required
~ Allowed Values
|Need Status
i|In Progress
c|Completed
b|Billed
p|paid
~ When I created a View with a Filter "is none of" and selected Billed and Paid, all of the correct rows appear but the Status field element was wiped to blank instead of their respective values. I used a Customfield:PHP to print_r the $data element and confirmed it was blank.
~ When I then set the view to "is one of" and selected all but Billed and Paid, the rows with a blank status were filtered out entirely even though they were selected for inclusion.

I utilized the hack in #6 (thanks, it got the job done)