[Dbix-class] Empty inserts with add_to_... and create
Matt S Trout
dbix-class at trout.me.uk
Fri Jan 13 19:07:24 CET 2006
On Thu, Jan 12, 2006 at 01:30:16PM -0800, apv wrote:
> The only thing I can guess is wrong is that the table is
> self-referential?
>
> A chapter might have a parent chapter and so on. I've never done
> constraints
> in DBs before but I've had the same concept work in Class::DBI.
>
> Here's the table definition:
>
> CREATE TABLE `chapter` (
> `id` int(8) unsigned NOT NULL auto_increment,
> `doc` int(8) unsigned NOT NULL default '0',
> `chapter` int(8) unsigned default NULL,
> `number` int(4) default NULL,
> `title` tinytext,
> `subtitle` tinytext,
> `created` datetime default NULL,
> `updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update
> CURRENT_TIMESTAMP,
> PRIMARY KEY (`id`),
> KEY `chapter` (`chapter`),
> KEY `doc` (`doc`),
> CONSTRAINT `chapter_ibfk_1` FOREIGN KEY (`chapter`) REFERENCES
> `chapter` (`id`),
> CONSTRAINT `chapter_ibfk_2` FOREIGN KEY (`doc`) REFERENCES `doc`
> (`id`)
> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
>
> And a sample that's failing (I checked and all the variables are
> defined correctly).
>
> Pangyre::Model::chapter->create({
> title => $chapter,
> doc => $doc->id,
> subtitle => $chapter_subtitle,
> number => $chapter_num,
> });
Very odd. Try checking what gets passed through to $storage->insert and
see if that helps.
--
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 Dbix-class
mailing list