I'm getting a "SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)" error with my date filter that can be fixed by rolling back a change to the date_views module. A patch is attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Agileware created an issue. See original summary.

akosipax’s picture

Here's another patch that is relative the date module's directory and would apply cleanly.

estebanhere’s picture

I'm getting a "SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 2 column(s)" error, when I try to use a relationship representative node in a view.

Why? I use the patch, but it does not work for me

Thanks!

DamienMcKenna’s picture

Version: 7.x-2.9 » 7.x-2.x-dev
Status: Needs review » Needs work

The problem is that the query generator returns a value like this:

(for September 1st, 2016)

AND (DATE_FORMAT(FROM_UNIXTIME(field_data_field_something.field_something_value), '%Y-%m-%d') >= '2016', '9', '1')

If you execute the DATE_FORMAT() string on its own it results in string like this: 2016-08-12

Clearly the problem is that something is converting the date to an array and then they're being output as three comma separated strings instead of being combined into a date value.

DamienMcKenna’s picture

Title: SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s) » Default values in exposed fields processed incorrectly in query
Related issues: +#2420323: Exposed date filter shouldn't automatically set a default date if none requested

So while #2420323: Exposed date filter shouldn't automatically set a default date if none requested fixed empty default values it broke handling of non-empty default values. OTOH the previous code didn't work either ;-)

DamienMcKenna’s picture

Status: Needs work » Needs review
FileSize
1.51 KB

I feel like this is going in circles :-\

Chris Matthews’s picture

The 2 year old patch in #6 to date_views_filter_handler_simple.inc does not apply to the latest 7.x-2.x-dev and may be too old to easily reroll, but I went ahead and tagged the issue accordingly.

Checking patch date_views/includes/date_views_filter_handler_simple.inc...
error: while searching for:
        $form[$prefix]['#dependency'] = array($source => $operator_values);
      }
      if (!isset($form_state['input'][$identifier][$prefix])) {
        // Ensure these exist.
        foreach ($granularity as $key) {
          $form_state['input'][$identifier][$prefix][$key] = NULL;
        }
      }
    }

error: patch failed: date_views/includes/date_views_filter_handler_simple.inc:381
error: date_views/includes/date_views_filter_handler_simple.inc: patch does not apply
DamienMcKenna’s picture

Issue tags: +Needs tests

I think we need test coverage too.

steinmb’s picture

Issue tags: -Needs reroll
FileSize
2.12 KB

Untested, manual re-roll.