Skip to content

Commit

Permalink
Test SQLT gets told about deferrable unique
Browse files Browse the repository at this point in the history
  • Loading branch information
Alastair McGowan-Douglas committed Jul 17, 2017
1 parent 9f29d1b commit fc0b714
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions t/99dbic_sqlt_parser.t
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ my $idx_exceptions = {
my $idx_test = join("\x00", $index->fields);
isnt ( $pk_test, $idx_test, "no additional index for the primary columns exists in $source_name");
}

my $deferrables = grep {
$_->name eq 'track_cd_position'
and $_->type eq 'UNIQUE'
and $_->deferrable == 1
}
get_table($sqlt_schema, $schema, 'Track')->get_constraints;

is ($deferrables, 1, "a deferrable unique constraint called track_cd_position exists on Track");
}
}

Expand Down
5 changes: 4 additions & 1 deletion t/lib/DBICTest/Schema/Track.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ __PACKAGE__->add_columns(
);
__PACKAGE__->set_primary_key('trackid');

__PACKAGE__->add_unique_constraint([ qw/cd position/ ]);
__PACKAGE__->add_unique_constraint({
columns => [ qw/cd position/ ],
sqlt_extra => { deferrable => 1 }
});
__PACKAGE__->add_unique_constraint([ qw/cd title/ ]);

__PACKAGE__->position_column ('position');
Expand Down

0 comments on commit fc0b714

Please sign in to comment.