I hope I do it right by sending this here and not to the request tracker.

The gist of the problem is that when the current Loader loads:

create table composed_key(
    id1 integer,
    id2 integer,
    value integer,
    primary key (id1, id2)
);

it marks both 'id1' and 'id2' as auto-increment - which does not make
sense.  I am attaching a simple script reproducing the problem and I
also send some analysis what I presume happened.

The problem is that the SQLite rules for auto-increment PKs are rather
weird (see http://www.sqlite.org/autoinc.html) and indeed the
documentation says "If a table contains a column of type INTEGER
PRIMARY KEY, then that column becomes an alias for the ROWID." with
ROWID being the internal row id  - which is automatically assigned and
so is auto-increment.  But that sentence does not make sense for
composed keys - so I would interpret it strictly as it only applies to
columns defined as 'INTEGER PRIMARY KEY' and not columns defined just
'INTEGER' and later added to the primary key with 'primary key (id1,
id2)'.

In my own code I just checked how many columns there are in the
primary key and not assigned is_auto_increment in the case when there
was more than one.

Cheers,
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/

PS. By the way what is the current repo for this dist?

Attachment: composed_key_loader_problem.pl
Description: Binary data

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to