[Dbix-class] create_related is failing on second time through loop?

Tim Anderson tja824 at gmail.com
Thu Jun 21 21:11:06 GMT 2012


My Header.pm:

use utf8;
package TJATest::Schema::Result::Header;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE

use strict;
use warnings;

use base 'DBIx::Class::Core';

__PACKAGE__->table("header");

__PACKAGE__->add_columns(
  "header_id",
  { data_type =3D> "nvarchar", is_nullable =3D> 0, size =3D> 8 },
  "header_name",
  { data_type =3D> "nvarchar", is_nullable =3D> 0, size =3D> 16 },
);

__PACKAGE__->set_primary_key("header_id");

__PACKAGE__->has_many(
  "details",
  "TJATest::Schema::Result::Detail",
  { "foreign.header_id" =3D> "self.header_id" },
  { cascade_copy =3D> 0, cascade_delete =3D> 0 },
);

# Created by DBIx::Class::Schema::Loader v0.07025 @ 2012-06-21 10:57:34
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dlqmQqCFLzrg5Oyy0OkjaQ


# You can replace this text with custom code or comments, and it will be
preserved on regeneration
1;


and my Detail.pm:

use utf8;
package TJATest::Schema::Result::Detail;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE

use strict;
use warnings;

use base 'DBIx::Class::Core';

__PACKAGE__->table("detail");

__PACKAGE__->add_columns(
  "header_id",
  { data_type =3D> "nvarchar", is_foreign_key =3D> 1, is_nullable =3D> 0, s=
ize =3D>
8 },
  "detail_id",
  { data_type =3D> "nvarchar", is_nullable =3D> 0, size =3D> 8 },
  "detail_name",
  { data_type =3D> "nvarchar", is_nullable =3D> 0, size =3D> 32 },
);

__PACKAGE__->set_primary_key("header_id", "detail_id");

__PACKAGE__->belongs_to(
  "header",
  "TJATest::Schema::Result::Header",
  { header_id =3D> "header_id" },
  { is_deferrable =3D> 1, on_delete =3D> "CASCADE", on_update =3D> "CASCADE=
" },
);

# Created by DBIx::Class::Schema::Loader v0.07025 @ 2012-06-21 10:57:34
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:RoARw2LXtvRN8PNvTMq7rQ


# You can replace this text with custom code or comments, and it will be
preserved on regeneration
1;



-Tim


On Thu, Jun 21, 2012 at 3:59 PM, David Stevenson <hoagy at ytfc.com> wrote:

> My money is on you not declaring your primary keys correctly - such that
> you ended up with detail_id as the primary key
>
> What's the DB schema?
>
>
> _______________________________________________
> 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/dbix-class@lists.scsys.co.uk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120621/5ed=
8b944/attachment.htm


More information about the DBIx-Class mailing list