[Catalyst] Why Can't I Create a Model For Tables With Autoincrement

Matt S Trout dbix-class at trout.me.uk
Mon Mar 20 13:38:27 CET 2006


hkclark at gmail.com wrote:
> If I create an SQLite table using this:
>     CREATE TABLE user (
>             id INTEGER PRIMARY KEY AUTOINCREMENT,
>             username TEXT,
>             password TEXT
>     );
> 
> Then when I try to create my model I get this:
> 
>     [MyApp]$ script/myapp_create.pl model DBIC DBIC dbi:SQLite:myapp.db
>      exists "/test/MyApp/script/../lib/MyApp/Model"
>      exists "/test/MyApp/script/../t"
>      exists "/test/MyApp/script/../lib/MyApp/Model/DBIC.pm"
>     sqlite_sequence has no primary key at 
> /usr/lib/perl5/site_perl/5.8.5/DBIx/Class/Loader.pm line 110
>     Segmentation fault
>     [MyApp]$

Please use Model::DBIC::Schema, the old DBIC model was a clone of the CDBI one 
and isn't nearly as good.

> But if I remove the AUTOINCREMENT it works fine.  I know that SQLite 
> will still increment the id for me even without the AUTOINCREMENT 
> keyword, but it seems like it should also work with the keyword. 

Without the AUTOINCREMENT, SQLite does actual auto_increment. With it, it 
creates a fake table to pretend to be a sequence which complicates things 
substantially - and as such Loader and SchemaLoader (the latter of which you'd 
be using with M::DBIC::Schema) don't support it.

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list