use File::Temp qw//;
use Class::Unload;
use Class::Inspector ();
-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;
+use DBIx::Class::Schema::Loader::Utils qw/split_name dumper_squashed/;
+use DBIx::Class::Schema::Loader::Optional::Dependencies ();
+use Try::Tiny;
+use DBIx::Class ();
use namespace::clean;
-our $VERSION = '0.07001';
+our $VERSION = '0.08000';
__PACKAGE__->mk_group_ro_accessors('simple', qw/
schema
The option also takes a hashref:
- naming => { relationships => 'v7', monikers => 'v7' }
+ naming => { relationships => 'v8', monikers => 'v8' }
The keys are:
If you don't have any CamelCase table or column names, you can upgrade without
breaking any of your code.
+=item v8
+
+This mode tries harder to not have collisions between column accessors and
+belongs_to relationship accessors.
+
=back
Dynamic schemas will always default to the 0.04XXX relationship names and won't
__PACKAGE__->naming('current');
-Or if you prefer to use 0.07XXX features but insure that nothing breaks in the
+Or if you prefer to use 0.08XXX features but insure that nothing breaks in the
next major version upgrade:
- __PACKAGE__->naming('v7');
+ __PACKAGE__->naming('v8');
=head2 generate_pod
For example:
relationship_attrs => {
- belongs_to => { is_deferrable => 1 },
+ belongs_to => { is_deferrable => 0 },
},
-use this to make your foreign key constraints DEFERRABLE.
+use this to turn off DEFERRABLE on your foreign key constraints.
=head2 debug
=cut
-my $CURRENT_V = 'v7';
+my $CURRENT_V = 'v8';
my @CLASS_ARGS = qw(
schema_base_class result_base_class additional_base_classes
$self->_validate_class_args;
if ($self->use_moose) {
- eval <<'EOF';
-require Moose;
-require MooseX::NonMoose;
-require namespace::autoclean;
-EOF
- if ($@) {
- die sprintf "You must install the following CPAN modules to enable the use_moose option: %s.\n",
- "Moose, MooseX::NonMoose and namespace::autoclean";
+ if (not DBIx::Class::Schema::Loader::Optional::Dependencies->req_ok_for('use_moose')) {
+ die sprintf "You must install the following CPAN modules to enable the use_moose option: %s.\nYou are missing: %s.\n",
+ "Moose, MooseX::NonMoose and namespace::autoclean",
+ DBIx::Class::Schema::Loader::Optional::Dependencies->req_missing_for('use_moose');
}
}
$self->relationship_attrs,
);
}
+ elsif ($self->naming->{relationships} eq 'v6') {
+ require DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_07;
+ return $self->{relbuilder} ||= DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_07->new (
+ $self->schema,
+ $self->inflect_plural,
+ $self->inflect_singular,
+ $self->relationship_attrs,
+ );
+ }
return $self->{relbuilder} ||= DBIx::Class::Schema::Loader::RelBuilder->new (
$self->schema,
local *Class::C3::reinitialize = sub {};
use warnings;
- if ($class->can('meta') && (ref $class->meta)->isa('Moose::Meta::Class')) {
+ if ($class->can('meta') && try { $class->meta->isa('Moose::Meta::Class') }) {
$class->meta->make_mutable;
}
Class::Unload->unload($class) if $unload;
&& ($resultset_class ne 'DBIx::Class::ResultSet')
) {
my $has_file = Class::Inspector->loaded_filename($resultset_class);
- if ($resultset_class->can('meta') && (ref $resultset_class->meta)->isa('Moose::Meta::Class')) {
+ if ($resultset_class->can('meta') && try { $resultset_class->meta->isa('Moose::Meta::Class') }) {
$resultset_class->meta->make_mutable;
}
Class::Unload->unload($resultset_class) if $unload;
$s = !defined $s ? 'undef' :
length($s) == 0 ? '(empty string)' :
ref($s) eq 'SCALAR' ? $$s :
- ref($s) ? do {
- my $dd = Dumper;
- $dd->Indent(0);
- $dd->Values([$s]);
- $dd->Dump;
- } :
+ ref($s) ? dumper_squashed $s :
looks_like_number($s) ? $s :
qq{'$s'}
;