In a local dev site, trying to install the module to better understand it (for creating your own) results in the following error if the database being used is SQLite3:

PDOException: SQLSTATE[HY000]: General error: 1 there is already an index named model_type: CREATE TABLE {model_type} ( id INTEGER PRIMARY KEY AUTOINCREMENT, type VARCHAR(255) NOT NULL, label VARCHAR(255) NOT NULL DEFAULT '', weight INTEGER NOT NULL DEFAULT 0, data TEXT NULL DEFAULT NULL, status INTEGER NOT NULL DEFAULT 1, module VARCHAR(255) NULL DEFAULT NULL ); ; Array ( ) in db_create_table() (line 2717 of /var/www/drupal/includes/database/database.inc).

This issue could not be reproduced when using a MySQL database, but could be reproduced on a fresh SQLite3 install.

CommentFileSizeAuthor
#2 model-sqlite-1988576-summary.patch790 bytesawochna
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

awochna’s picture

Version: 7.x-1.0-alpha2 » 7.x-1.x-dev
Assigned: Unassigned » awochna
awochna’s picture

Status: Active » Needs review
FileSize
790 bytes

This is the result of SQLite prefixing its keys with the name of the parent table. Therefore, the key "type" in the table "model" results in an object already called "model_type" which prevents you from creating a table of the same name.

The attached patch changes the name of the table to model_types to avoid this issue.

a.ross’s picture

Status: Needs review » Needs work

The convention is to use [entity]_type as table for the bundle types. This should be fixed in another way.