has 'on_delete' => ( is => 'rw', required => 0);
has 'on_update' => ( is => 'rw', required => 0);
- around add_column(Column $column) {
+ around add_column(Column $column does coerce) {
if ($self->has_type && $self->type eq 'PRIMARY KEY') {
$column->is_primary_key(1);
}
}
method is_valid { return $self->has_type && scalar $self->column_ids ? 1 : undef }
+
+ around BUILDARGS(ClassName $self: @args) {
+ my $args = $self->$orig(@args);
+
+ my $fields = delete $args->{fields} || [];
+
+ $fields = ref($fields) eq 'ARRAY' ? $fields : [ $fields ];
+ my $ix_hash = Tie::IxHash->new();
+ $ix_hash->STORE($_, SQL::Translator::Object::Column->new( name => $_ )) for @$fields;
+ $args->{columns} = $ix_hash;
+
+ return $args;
+ }
}