[Dbix-class] Bug in the SQLT parser introduced by r4126

Peter Rabbitson rabbit+list at rabbit.us
Wed Apr 2 11:05:20 BST 2008


This was discussed in the channel yesterday, but I want to post it here too so 
it doesn't get lost. The change: 
http://dev.catalystframework.org/svnweb/bast/revision/?rev=3832 creates 
default indexes for seamless SQLT diffs. The problem is that when doing 
$schema->deploy, the RDBMS interprets all statements and doubles all unique 
indexes (->set_primary_key and ->add_unique_index).

An example:

__PACKAGE__->add_columns (

     id => {
         data_type => 'SMALLINT',
     },
     name => {
         data_type => 'VARCHAR',
         size => '255',
     },
     config => {
         data_type => 'BLOB',
         inflate => 'structure',
         is_nullable => 1,
     },
);

__PACKAGE__->set_primary_key ('id');
__PACKAGE__->add_unique_constraint (u_name => ['name']);


produces:

CREATE TABLE `adservices` (
   `id` SMALLINT NOT NULL,
   `name` VARCHAR(255) NOT NULL,
   `config` BLOB,
   INDEX id (`id`),
   INDEX name (`name`),
   PRIMARY KEY (`id`),
   UNIQUE `u_name` (`name`)
) ENGINE=InnoDB;

which mysql interprets as:

mysql> show indexes from ccs_data.adservices;
+------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table      | Non_unique | Key_name | Seq_in_index | Column_name | Collation 
| Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| adservices |          0 | PRIMARY  |            1 | id          | A 
|           0 |     NULL | NULL   |      | BTREE      |         |
| adservices |          0 | u_name   |            1 | name        | A 
|           0 |     NULL | NULL   |      | BTREE      |         |
| adservices |          1 | id       |            1 | id          | A 
|           0 |     NULL | NULL   |      | BTREE      |         |
| adservices |          1 | name     |            1 | name        | A 
|           0 |     NULL | NULL   |      | BTREE      |         |
+------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+



More information about the DBIx-Class mailing list