John-

Thanks for the response.  It's much appreciated.

You are correct in that both pks for these two tables are auto_increments,
so I went ahead and changed the column types to 'serial' as you suggested.
I re-ran my test script, and I'm still getting two rows inserted into the
'child' table with no values for the 'notes' columns.

Parent Definition:
CREATE TABLE `parent` (
 `parent_id` int(11) unsigned zerofill NOT NULL auto_increment,
 `notes` text NOT NULL,
 PRIMARY KEY  (`parent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Child Definition:
CREATE TABLE `child` (
 `child_id` int(11) unsigned zerofill NOT NULL auto_increment,
 `parent_id` int(11) unsigned zerofill NOT NULL,
 `notes` text NOT NULL,
 PRIMARY KEY  (`child_id`),
 KEY `parent_id` (`parent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

ALTER TABLE `child`
 ADD CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES
`parent` (`parent_id`) ON DELETE CASCADE ON UPDATE CASCADE;


Using MySql v 5.0.13.

Any more help would be appreciated.

- Chris


On 12/22/06, John Siracusa <[EMAIL PROTECTED]> wrote:

On 12/22/06 1:40 PM, Chris Campise wrote:
> The way I understood the above to work was that it would insert a new
Parent
> row and then auto-insert ONE (1) Child row with the child.parent_idforeign
> key pointed back to parent.parent_Id.  But there are two Child rows
being
> inserted, and neither have the child.notes field populated

You don't specify any values for the primary keys here:

> my $p = My::DB::Parent->new(
>     notes => "These are some parent notes")->save;
>
> $p->child(notes => "These are some child notes");
> $p->save;

If those calls actually work, then the pk columns are likely
AUTO_INCREMENT
in the database, in which case the column type in your classes should be
"serial", not "integer".

If I've missed something, please post the table definitions and I'll see
if
I can reproduce your situation on my end.

-John

> package My::DB::Parent;
...
>   columns =>
>   [
>     parent_id => { type => 'integer', not_null => 1 },
...
> package My::DB::Child;
...
>   columns =>
>   [
>     child_id  => { type => 'integer', not_null => 1 },



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to