[Dbix-class] foreign keys in fixtures for Test::DBIx::Class

Adam Witney awitney at sgul.ac.uk
Thu Nov 20 15:06:18 GMT 2014


Hi,

I am trying to write some fixtures for testing with Test::DBIx::Class. I can do this for a simple one table test, but am having trouble doing it when I have a foreign key between two tables. In the file "t/etc/schema.pl" I have

fixture_sets => {
          'basic' => [
              {
                  Person => [
                      [ 'first_name', 'last_name', ],
                      [ 'John', 'Smith' ],
                  ]
              },{
                  Company => [
                      ['name'],
                      ['My Company']
                  ]
              }
          ]
      }

But I cannot figure out how to assign the Company to Person John  Smith. Does anyone have a working example of this syntax?

The becomes a problem when using foreign keys in PostgreSQL, as it can't create the Person row without an id for the company row

Thanks for any help

Adam 



More information about the DBIx-Class mailing list