sub _add_column_group {
my ($class, $group, @cols) = @_;
- $class->_register_column_group($group => @cols);
$class->add_columns(@cols);
+ $class->_register_column_group($group => @cols);
}
sub _register_column_group {
sub set_primary_key {
my ($class, @cols) = @_;
+ # check if primary key columns are valid columns
+ for (@cols) {
+ $class->throw( "Column $_ can't be used as primary key because it isn't defined in $class" )
+ unless $class->has_column($_);
+ }
my %pri;
tie %pri, 'Tie::IxHash', map { $_ => {} } @cols;
$class->_primaries(\%pri);