5

I was wondering if it is possible update_or_create on multiple unique constraints in dbix

Ex From Cpan:

 my $cd = $schema->resultset('CD')->update_or_create(
    {
      artist => 'Massive Attack',
      title  => 'Mezzanine',
      year   => 1998,
    },
    { key => 'cd_artist_title' }
  );

What I would like to do

   my $cd = $schema->resultset('CD')->update_or_create(
    {
      artist => 'Massive Attack',
      title  => 'Mezzanine',
      year   => 1998,
    },
    { key => {'cd_artist_title','year' }
  );
shaneburgess
  • 15,702
  • 15
  • 47
  • 66

1 Answers1

4

I figured it out: you have to define the unique constraint in the Controller with add_unique_constraint.

daxim
  • 39,270
  • 4
  • 65
  • 132
shaneburgess
  • 15,702
  • 15
  • 47
  • 66