During setup, autoassignrole table cannot be created because there is a default value for TEXT

BLOB/TEXT column 'value' can't have a default value
query:

CREATE TABLE autoassignrole ( 
  `arid` VARCHAR(38) NOT NULL DEFAULT '', 
  `value` TEXT DEFAULT '', 
   PRIMARY KEY (arid) 
) 
/*!40100 DEFAULT CHARACTER SET UTF8 */ 

in mysite\includes\database.inc in line 515.

I think this error may not be reported by some versions of MySQL. I use version 5.

CommentFileSizeAuthor
#6 autoassignrole_schema_bug.patch388 bytesseanburlington

Comments

danolsavsky’s picture

I am having the same issue. I disabled the module, uninstalled it via Drupal, deleted the folder from my web root, re-downloaded, re-unzipped, re-uploaded, re-enabled... twice, with both the beta3 and dev version.

I can see that it hasn't created the table in SQL.

Please Help!

user warning: BLOB/TEXT column 'value' can't have a default value query: CREATE TABLE autoassignrole ( `arid` VARCHAR(38) NOT NULL DEFAULT '', `value` TEXT DEFAULT '', PRIMARY KEY (arid) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in D:\www\web\BernsteinDCA\includes\database.inc on line 515.
user warning: BLOB/TEXT column 'display' can't have a default value query: CREATE TABLE autoassignrole_page ( `rid` INT NOT NULL, `display` TEXT NOT NULL DEFAULT '', `path` VARCHAR(255) NOT NULL, `title` TEXT NOT NULL DEFAULT '', `description` LONGTEXT DEFAULT NULL, `format` TINYINT DEFAULT NULL, `weight` TINYINT DEFAULT 0, PRIMARY KEY (rid) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in D:\www\web\BernsteinDCA\includes\database.inc on line 515.
user warning: Table 'comfortacademy.autoassignrole' doesn't exist query: INSERT into autoassignrole (arid,value) VALUES ('auto_roles', 'a:0:{}') in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.install on line 20.
user warning: Table 'comfortacademy.autoassignrole' doesn't exist query: INSERT into autoassignrole (arid,value) VALUES ('auto_active', '0') in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.install on line 23.
user warning: Table 'comfortacademy.autoassignrole' doesn't exist query: INSERT into autoassignrole (arid,value) VALUES ('user_active', '0') in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.install on line 26.
user warning: Table 'comfortacademy.autoassignrole' doesn't exist query: INSERT into autoassignrole (arid,value) VALUES ('user_roles', 'a:0:{}') in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.install on line 29.
user warning: Table 'comfortacademy.autoassignrole' doesn't exist query: INSERT into autoassignrole (arid,value) VALUES ('user_required', '0') in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.install on line 32.
user warning: Table 'comfortacademy.autoassignrole' doesn't exist query: INSERT into autoassignrole (arid,value) VALUES ('user_multiple', '0') in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.install on line 35.
user warning: Table 'comfortacademy.autoassignrole' doesn't exist query: INSERT into autoassignrole (arid,value) VALUES ('user_description', '') in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.install on line 38.
user warning: Table 'comfortacademy.autoassignrole' doesn't exist query: INSERT into autoassignrole (arid,value) VALUES ('user_title', 'Role') in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.install on line 41.
user warning: Table 'comfortacademy.autoassignrole' doesn't exist query: INSERT into autoassignrole (arid,value) VALUES ('user_fieldset_title', 'User Roles') in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.install on line 44.
user warning: Table 'comfortacademy.autoassignrole' doesn't exist query: INSERT into autoassignrole (arid,value) VALUES ('user_sort', 'SORT_ASC') in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.install on line 47.
user warning: Table 'comfortacademy.autoassignrole' doesn't exist query: INSERT into autoassignrole (arid,value) VALUES ('user_selection', '2') in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.install on line 50.
user warning: Table 'comfortacademy.autoassignrole' doesn't exist query: INSERT into autoassignrole (arid,value) VALUES ('page_active', '0') in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.install on line 53.
user warning: Table 'comfortacademy.autoassignrole_page' doesn't exist query: SELECT rid, path, display, title, weight FROM autoassignrole_page in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.module on line 31.
user warning: Table 'comfortacademy.autoassignrole_page' doesn't exist query: SELECT rid, path, display, title, weight FROM autoassignrole_page in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.module on line 31.
user warning: Table 'comfortacademy.autoassignrole_page' doesn't exist query: SELECT rid, path, display, title, weight FROM autoassignrole_page in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.module on line 31.
user warning: Table 'comfortacademy.autoassignrole_page' doesn't exist query: SELECT rid, path, display, title, weight FROM autoassignrole_page in D:\www\web\BernsteinDCA\modules\autoassignrole\autoassignrole.module on line 31.

danolsavsky’s picture

!FIXED!

I changed (and by I, I mean Alex) ; 'not null' => TRUE, -to- 'not null' => FALSE, and removed the default values for text types. See below

<?php
// $Id: autoassignrole.install,v 1.7.2.5 2008/10/10 21:32:57 cyberswat Exp $

/**
* @file
*
* The autoassignrole.install file
*
* Installs the {autoassignrole} table and inserts default data as well as
* provides uninstall functionality.
*/

/**
* Implementation of hook_install().
*/
function autoassignrole_install() {
drupal_install_schema('autoassignrole');
db_query("INSERT into {autoassignrole} (arid,value) VALUES ('%s', '%s')",
'auto_roles', serialize(array())
);
db_query("INSERT into {autoassignrole} (arid,value) VALUES ('%s', '%s')",
'auto_active', 0
);
db_query("INSERT into {autoassignrole} (arid,value) VALUES ('%s', '%s')",
'user_active', 0
);
db_query("INSERT into {autoassignrole} (arid,value) VALUES ('%s', '%s')",
'user_roles', serialize(array())
);
db_query("INSERT into {autoassignrole} (arid,value) VALUES ('%s', '%s')",
'user_required', 0
);
db_query("INSERT into {autoassignrole} (arid,value) VALUES ('%s', '%s')",
'user_multiple', 0
);
db_query("INSERT into {autoassignrole} (arid,value) VALUES ('%s', '%s')",
'user_description', ''
);
db_query("INSERT into {autoassignrole} (arid,value) VALUES ('%s', '%s')",
'user_title', t("Role")
);
db_query("INSERT into {autoassignrole} (arid,value) VALUES ('%s', '%s')",
'user_fieldset_title', t("User Roles")
);
db_query("INSERT into {autoassignrole} (arid,value) VALUES ('%s', '%s')",
'user_sort', 'SORT_ASC'
);
db_query("INSERT into {autoassignrole} (arid,value) VALUES ('%s', '%s')",
'user_selection', 2
);
db_query("INSERT into {autoassignrole} (arid,value) VALUES ('%s', '%s')",
'page_active', 0
);
}

/**
* Implementation of hook_uninstall().
*/
function autoassignrole_uninstall() {
drupal_uninstall_schema('autoassignrole');
}

/**
* Implementation of hook_schema().
*/
function autoassignrole_schema() {
$schema['autoassignrole'] = array(
'description' => t('Stores autoassignrole variables.'),
'fields' => array(
'arid' => array(
'type' => 'varchar',
'length' => 38,
'not null' => TRUE,
'default' => '0',
'description' => t('The id for this setting.'),
),
'value' => array(
'type' => 'text',
'not null' => FALSE,
'description' => t('The value for this setting.'),
),
),
'primary key' => array('arid'),
);
$schema['autoassignrole_page'] = array(
'description' => t('Stores autoassignrole page information.'),
'fields' => array(
'rid' => array(
'type' => 'int',
'not null' => TRUE,
'description' => t('The rid for this page.'),
),
'display' => array(
'type' => 'text',
'not null' => FALSE,
'description' => t('How to display the navigation to this page.'),
),
'path' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => t('The path for this page.'),
),
'title' => array(
'type' => 'text',
'not null' => FALSE,
'description' => t('The title for this page.'),
),
'description' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
'description' => t('The description for this page.'),
),
'format' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => FALSE,
'description' => t('The filter format to use on the description.'),
),
'weight' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => FALSE,
'default' => 0,
'description' => t('The weight of this item.'),
),
),
'primary key' => array('rid'),
);
return $schema;
}
function autoassignrole_update_6000() {
$items = array();
$sql = "SELECT name FROM {variable} WHERE name LIKE 'AUTOASSIGNROLE_%%'";
$vars = db_query($sql);
while ($var = db_fetch_object($vars)) {
variable_del($var->name);
}
$items[] = array("success" => 1, "query" => "Cleaned up old variables and installed new table");

autoassignrole_install();
return $items;
}

cyberswat’s picture

Any chance you could follow the instructions at Creating Patches so that your fix can be tested and used?

cyberswat’s picture

Status: Active » Closed (fixed)

I'm closing this due to the lack of a patch ... if you want it fixed, reroll a patch that can be used and reopen the issue.

seanburlington’s picture

Status: Closed (fixed) » Needs work

This is also reported as a bug by the schema module

seanburlington’s picture

StatusFileSize
new388 bytes

here's the patch

It's pretty trivial

Just delete the line

'default' => '',

for the `value` column - this is of type text which does not support default values

seanburlington’s picture

Status: Needs work » Needs review
cyberswat’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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