use Data::Dumper::Concise;
use Scalar::Util 'looks_like_number';
use File::Slurp 'slurp';
+use DBIx::Class::Schema::Loader::Utils 'split_name';
require DBIx::Class;
our $VERSION = '0.07000';
For example:
relationship_attrs => {
- all => { cascade_delete => 0 },
- has_many => { cascade_delete => 1 },
+ belongs_to => { is_deferrable => 1 },
},
-will set the C<cascade_delete> option to 0 for all generated relationships,
-except for C<has_many>, which will have cascade_delete as 1.
+use this to make your foreign key constraints DEFERRABLE.
=head2 debug
=head2 components
List of additional components to be loaded into all of your table
-classes. A good example would be C<ResultSetManager>.
+classes. A good example would be
+L<InflateColumn::DateTime|DBIx::Class::InflateColumn::DateTime>
=head2 resultset_components
sub _make_column_accessor_name {
my ($self, $column_name) = @_;
- return join '_', map lc, split /(?<=[[:lower:]])[\W_]*(?=[[:upper:]])|[\W_]+/, $column_name;
+ return join '_', map lc, split_name $column_name;
}
# Set up metadata (cols, pks, etc)
my $cols = $self->_table_columns($table);
my $col_info = $self->__columns_info_for($table);
+
+ while (my ($col, $info) = each %$col_info) {
+ if ($col =~ /\W/) {
+ ($info->{accessor} = $col) =~ s/\W+/_/g;
+ }
+ }
+
if ($self->preserve_case) {
- for my $col (keys %$col_info) {
+ while (my ($col, $info) = each %$col_info) {
if ($col ne lc($col)) {
if ((not exists $self->naming->{column_accessors}) || (($self->naming->{column_accessors} =~ /(\d+)/)[0] >= 7)) {
- $col_info->{$col}{accessor} = $self->_make_column_accessor_name($col);
+ $info->{accessor} = $self->_make_column_accessor_name($info->{accessor} || $col);
}
else {
- $col_info->{$col}{accessor} = lc $col;
+ $info->{accessor} = lc($info->{accessor} || $col);
}
}
}
return join '', map ucfirst, split /\W+/, $inflected;
}
- my @words = map lc, split /(?<=[[:lower:]])[\W_]*(?=[[:upper:]])|[\W_]+/, $table;
+ my @words = map lc, split_name $table;
my $as_phrase = join ' ', @words;
my $inflected = Lingua::EN::Inflect::Phrase::to_S($as_phrase);