use MooseX::Declare;
-class SQL::Translator::Object {
+class SQL::Translator::Object with SQL::Translator::Object::Compat {
use Tie::IxHash;
use MooseX::MultiMethods;
use MooseX::Types::Moose qw(Any ArrayRef HashRef Str);
--- /dev/null
+use MooseX::Declare;
+role SQL::Translator::Object::Compat {
+ use MooseX::MultiMethods;
+
+ multi method fields(Str $columns) {
+ my @columns = split /\s*,\s*/, $columns;
+ for my $column (@columns) {
+ die "Column '$column' does not exist!" unless $self->table->exists_column($column);
+ $self->add_column($self->table->get_column($column));
+ }
+ $self->column_ids;
+ }
+
+ multi method fields(ArrayRef $columns) {
+ for my $column (@$columns) {
+ die "Column '$column' does not exist!" unless $self->table->exists_column($column);
+ $self->add_column($self->table->get_column($column));
+ }
+ $self->column_ids;
+ }
+
+ multi method fields(Any $) { $self->column_ids }
+
+ method get_fields { $self->get_columns }
+ method get_field { $self->get_column }
+ method field_names { $self->column_ids }
+ method reference_fields { $self->reference_columns }
+}
use MooseX::Declare;
class SQL::Translator::Object::Constraint extends SQL::Translator::Object {
use MooseX::Types::Moose qw(ArrayRef Bool HashRef Maybe Str Undef);
+ use MooseX::MultiMethods;
use SQL::Translator::Types qw(Column Table);
has 'table' => (
get_columns => 'values',
get_column => 'get',
add_column => 'set',
-
- ## compat
- get_fields => 'values',
- fields => 'keys',
},
default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
);
get_columns => 'values',
get_column => 'get',
add_column => 'set',
-
- ## compat
- get_fields => 'values',
},
default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
);
around add_column(Column $column) { $self->$orig($column->name, $column) }
- multi method fields(Str $columns) {
- for (split /,/, $columns) { die "Column $_ does not exist!" unless $self->table->exists_column($_) }
- $self->add_column($self->table->get_column($_)) for split /,/, $columns;
- $self->column_ids;
- }
-
- multi method fields(@columns) {
- for (@columns) { die "Column $_ does not exist!" unless $self->table->exists_column($_) }
- $self->add_column($self->table->get_column($_)) for @columns;
- $self->column_ids;
- }
-
- multi method fields(Any $) { $self->column_ids }
-
method is_valid { $self->table && scalar $self->get_columns ? 1 : undef }
}
get_column => 'get',
add_column => 'set',
remove_column => 'delete',
-
- ## compat
- get_fields => 'values',
- get_field => 'get',
- fields => 'keys',
},
default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
);
get_columns => 'values',
get_column => 'get',
add_column => 'set',
-
- ## compat
- get_fields => 'values',
- fields => 'keys',
},
default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
);
get_columns => 'values',
get_column => 'get',
add_column => 'set',
-
- ## compat
- get_fields => 'values',
- fields => 'keys',
},
default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
);