Re: [CDBI] Primary key declarations on non-primary key columns fails poorly
Matt S Trout <dbix-class-uY5y5/[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
Derek Basch wrote:
> Hello All,
>
> I spend several hours tracking down this error and I thought I would submit it to this list before
> submitting a feature request to CPAN.
>
> For this example I am using Mysql v5.0 and Class::DBI v3.0.15
>
> If you declare a column as a primary key with Class::DBI like this:
>
> Music::CD->columns(Primary => qw/pk1 pk2/);
>
> and the column is not declared as a primary key in the database schema then you will get this
> rather unhelpful error:
>
> Can't insert new Database::Table: Can't get last insert id at /usr/local/lib/foo.pm line 180
>
> As soon as you declare the column as primary in the database schema the error disappears.
>
> It seems like Class::DBI should do an idiot check (yes, I am definitely the idiot on this one) to
> ensure that the column really is a primary key column in the database schema.
And then if your database schema was set up by an idiot and you can't change
it, Class::DBI becomes completely useless because you can't declare what
*should* have been in the schema, only what is.
I'll take dealing with the occasional stupid mistake thanks, though the error
message could maybe be improved.
--
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/ +