0

I have installed the jQuery File Upload module, and I get the following error:

jquery_file_upload.id is part of the primary key but is not specified to be 'not null'

What does that error message mean, and how can I resolve it?

  • Are you asking for a module that has been developed from others, and which is hosted on Drupal.org? – kiamlaluno Oct 21 '12 at 17:58
  • Yes sorry. It is on my drupal 7.16 installation. – Magpie Oct 21 '12 at 18:39
1

The error message is about the schema currently used by the module, which defines the primary key using the following code.

function jquery_file_upload_schema() {
  $schema['jquery_file_upload'] = array(
      'description' => t('Stores files sizes for each user.'),
      'fields' => array(
          'id' => array(
              'description' => t('auto increment'),
              'type' => 'serial',
              'size' => 'normal',
          ),
          'uid' => array(
              'description' => t('registered user'),
              'type' => 'int',
              'unsigned' => TRUE,
              'not null' => TRUE,
              'default' => 0,
          ),
          'file_name' => array(
              'description' => t('File Name.'),
              'type' => 'varchar',
              'length' => '255',
              'not null' => TRUE,
          ),
          'file_size' => array(
              'description' => t('File Size.'),
              'type' => 'float',
              'size' => 'big',
              'default' => 0,
          ),
      ),
      'primary key' => array('id'),
  );
  return $schema;
}

The correct definition would be the following one, as the fields that are part of the primary key should be declarated as "NOT NULL."

function jquery_file_upload_schema() {
  $schema['jquery_file_upload'] = array(
      'description' => t('Stores files sizes for each user.'),
      'fields' => array(
          'id' => array(
              'description' => t('auto increment'),
              'type' => 'serial',
              'size' => 'normal',
              'not null' => TRUE,
          ),
          'uid' => array(
              'description' => t('registered user'),
              'type' => 'int',
              'unsigned' => TRUE,
              'not null' => TRUE,
              'default' => 0,
          ),
          'file_name' => array(
              'description' => t('File Name.'),
              'type' => 'varchar',
              'length' => '255',
              'not null' => TRUE,
          ),
          'file_size' => array(
              'description' => t('File Size.'),
              'type' => 'float',
              'size' => 'big',
              'default' => 0,
          ),
      ),
      'primary key' => array('id'),
  );
  return $schema;
}

There is nothing you can do, if not opening an issue report for the module, in its issue queue. Be sure there isn't already a report about that.

|improve this answer|||||
  • can I not just edit it? – Magpie Oct 21 '12 at 21:51
  • Editing the code of a module hosted on Drupal.org is not a good idea, just for the fact you should edit the code every time you update the module. – kiamlaluno Oct 21 '12 at 21:54
  • it is not hosted on drupal it's just a drupal installation. – Magpie Oct 21 '12 at 21:54
  • jquery_file_upload.module is hosted on Drupal.org; it's not a custom module you developed. – kiamlaluno Oct 21 '12 at 21:56
  • how can i fix it then? – Magpie Oct 28 '12 at 1:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.