In detail this is the message Drupal comes up :

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND ec_receipt_allocation.type = 'transaction' LEFT JOIN Drupal_ec_workflow_s' at line 6 query: SELECT COUNT(*) FROM (SELECT ec_transaction.txnid AS txnid FROM Drupal_ec_transaction ec_transaction INNER JOIN Drupal_ec_customer ec_customer ON ec_transaction.ecid = ec_customer.ecid LEFT JOIN Drupal_users users_ec_customer ON ec_customer.uid = users_ec_customer.uid LEFT JOIN Drupal_ec_transaction_address ec_transaction_address ON ec_transaction.txnid = ec_transaction_address.txnid LEFT JOIN Drupal_ec_receipt_allocation ec_receipt_allocation ON ec_transaction.txnid = CAST(ec_receipt_allocation.etid AS INT) AND ec_receipt_allocation.type = 'transaction' LEFT JOIN Drupal_ec_workflow_statuses ec_workflow_statuses ON ec_transaction.workflow = ec_workflow_statuses.workflow WHERE (ec_transaction_address.type IN ('billing') OR ec_transaction_address.type IS NULL) AND (ec_receipt_allocation.erid = 24) ) count_alias in E:\htdocs\Drupal11\sites\all\modules\extensions\views\includes\view.inc on line 739.

What really matters is:

CAST(ec_receipt_allocation.etid AS INT)

this causes the error und should be instead:

CAST(ec_receipt_allocation.etid AS unsigned INT)

in ec_store.view.inc line 324 I found:

  $data['ec_receipt_allocation']['table']['join'] = array(
    'ec_transaction' => array(
      'handler' => 'ec_receipt_views_join_cast',
      'left_field' => 'txnid',
      'field' => 'etid',
      'cast' => array('type' => 'int'),
      'type' => 'LEFT',
      'extra' => array(
        array(
          'field' => 'type',
          'value' => 'transaction',
        ),
      ),
    ),
  );

But correcting the cast to 'unsigned int' is blocked in ec_receipt.views.inc line 344:

  function cast_field_spec($field, $spec) {
    if (!isset($spec['size'])) {
      $spec['size'] = 'normal';
    }
    $map = db_type_map();
    $cast = $map[$spec['type'] .':'. $spec['size']];
    if (isset($spec['length'])) {
      $cast .= '('. $spec[length] .')';
    }
    elseif (isset($spec['precision']) && isset($spec['scale'])) {
      $cast .= '('. $spec['precision'] .', '. $spec['scale'] .')';
    }

    return "CAST($field AS $cast)";
  }

db_type_map() can't handle 'unsigned int' and returns nothing instead.

Please insert a handling for 'unsigned int' to avoid this failure.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

EPO’s picture

This isnt brilliant programming but it suffices to work:

function cast_field_spec($field, $spec) {
    if (!isset($spec['size'])) {
      $spec['size'] = 'normal';
    }

    $type = explode(' ', $spec['type']);
    if (count($type)==2){
      $modifier = $type[0];
      $spec['type']=$type[1];
    }
    
    $map = db_type_map();
    $cast = $map[$spec['type'] .':'. $spec['size']];
    if (isset($spec['length'])) {
      $cast .= '('. $spec[length] .')';
    }
    elseif (isset($spec['precision']) && isset($spec['scale'])) {
      $cast .= '('. $spec['precision'] .', '. $spec['scale'] .')';
    }

   if (isset($modifier)){
       $cast = $modifier . ' ' . $cast;
   }

    return "CAST($field AS $cast)";
  }
Soren Jones’s picture

Version: 6.x-4.0-rc15 » 6.x-4.x-dev
Status: Active » Needs review
FileSize
1.1 KB

Code above attached as patch for review.

Soren Jones’s picture

Code above attached as patch for review.

Soren Jones’s picture

Didn't attach properly?

gordon’s picture

Status: Needs review » Fixed

Thanks committed to dev

Status: Fixed » Closed (fixed)

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