Views that uses a field as argument have SQL instructions similar to a "is between" filter, but no date filter is set.

Reproduce the issue

Create a new View for nodes.

Add a field to Fields, for example Node:Title.

Add a date field to Arguments, for example Node:Post date.

Examine Live Prieview, you will get something like:

SELECT node.nid AS nid,
   node.title AS node_title
 FROM node node 
 WHERE (DATE_FORMAT(ADDTIME(FROM_UNIXTIME(node.created), SEC_TO_TIME(7200)), '%Y-%m-%%d') <= '2009-03-30' AND DATE_FORMAT(ADDTIME(FROM_UNIXTIME(node.created), SEC_TO_TIME(7200)), '%Y-%m-%%d') >= '2009-03-30')   

The part about date in the WHERE clause is not included in the view definition, so it's erroneous.

I suppose is a Date module issue because today I have updated Date and Calendar modules and this bug have arised. I have done all troubleshooting steps (updating to dev version, run update.php, flushing cache, etc).

Using:

PHP 5.2.5
Drupal 6.10
Date 6.x 2.x-dev (date_api.info says packaging script is from 2009-03-27, datestamp = 1238155650)
Calendar 6.x-2.1

Not using Calendar development version because it's not involved.

The view created:

$view = new view;
$view->name = 'test';
$view->description = 'test de views';
$view->tag = 'Test';
$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' => 'Título',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_node' => 0,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'date_argument' => array(
    'default_action' => 'default',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'Todos',
    'title' => '',
    'default_argument_type' => 'date',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'date_fields' => array(
      'node.created' => 'node.created',
    ),
    'year_range' => '-3:+3',
    'date_method' => 'OR',
    'granularity' => 'day',
    'id' => 'date_argument',
    'table' => 'node',
    'field' => 'date_argument',
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'forum' => 0,
      'entrada' => 0,
      'evento' => 0,
      'page' => 0,
      'proyecto' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
      '2' => 0,
    ),
    'validate_argument_type' => 'tid',
    'user_argument_type' => '',
    'restrict_user_roles' => 0,
    'user_roles' => array(),
    'validate_argument_php' => '',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));

Issue occurs even using the standard calendar view (it's shipped with Calendar module I guess), that only uses Node:update date field and a published node filter. The Live Preview shows that the SQL for that view (Default display) is:

SELECT node.nid AS nid,
   node.title AS node_title,
   node.changed AS node_changed,
   node.type AS node_type
 FROM node node 
 WHERE (node.status <> 0)
    AND ((DATE_FORMAT(ADDTIME(FROM_UNIXTIME(node.changed), SEC_TO_TIME(7200)), '%Y-%m') <= '2009-03' AND DATE_FORMAT(ADDTIME(FROM_UNIXTIME(node.changed), SEC_TO_TIME(7200)), '%Y-%m') >= '2009-03'))
   ORDER BY node_changed ASC

Thanks in advance.

Comments

tunic’s picture

Priority: Critical » Normal

Changing priority from critical to normal as I guess this issue brokes only a part of the module, although this issue is critical for me ;-)

tunic’s picture

Status: Active » Closed (works as designed)

Finally I got it, it's the "use a default argument" for the date argument.

So it's not a bug, it's a feature :D

Sorry!