Table names where converted incorrectly in my ".install" script

For example code:

=== START PHP CODE ====
function paypal_subscription_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {paypal_subscription} (
`subscription_id` int(10) NOT NULL default '0',
`name` varchar(64) NOT NULL default '',
`item_number` varchar(32) NOT NULL default '',
`receiver_email` varchar(32) NOT NULL default '',
`currency` char(3) NOT NULL default 'USD',
`payment` varchar(16) NOT NULL default '0',
`period` varchar(32) NOT NULL default '',
`role` int(10) NOT NULL default '1',
`send_welcome` tinyint(1) NOT NULL default '0',
`send_warning` tinyint(1) NOT NULL default '0',
`send_goodbye` tinyint(1) NOT NULL default '0',
`welcome_subject` varchar(64) NOT NULL default '',
`welcome_body` longtext NOT NULL,
`warning_subject` varchar(64) NOT NULL default '',
`warning_body` longtext NOT NULL,
`goodbye_subject` varchar(64) NOT NULL default '',
`goodbye_body` longtext NOT NULL,
PRIMARY KEY (`subscription_id`)
) /*!40100 DEFAULT CHARACTER SET utf8 */;");

break;
}
}
=== END PHP CODE ===

converted to:

=== START PHP CODE ===
/**
* Implementation of hook_schema().
*/
function paypal_subscription_schema() {
$schema['paypal_subscription'] = array(
'description' => t('TODO'),
'fields' => array(
'`subscription_id`' => array(
'description' => t('TODO'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'`name`' => array(
'description' => t('TODO'),
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),

.............

'`goodbye_body`' => array(
'description' => t('TODO'),
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
),
),
'primary key' => array('KEY'),
);

return $schema;
}
=== END OF PHP CODE ===

So you can see that we have incorrect table names:

wrong - '`receiver_email`'

must be - 'receiver_email'

Comments

solotandem’s picture

Assigned: Unassigned » solotandem
Status: Active » Fixed

Thanks for the report. Fixed along with #307993: Primary key = KEY by cleaning each schema definition line so it parses properly.

Status: Fixed » Closed (fixed)

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