if ($self->use_moose) {
eval <<'EOF';
-package __DBICSL__DUMMY;
-use Moose;
-use MooseX::NonMoose;
-use namespace::autoclean;
+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",
local *Class::C3::reinitialize = sub {};
use warnings;
- if ($class->can('meta')) {
+ if ($class->can('meta') && (ref $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')) {
+ if ($resultset_class->can('meta') && (ref $resultset_class->meta)->isa('Moose::Meta::Class')) {
$resultset_class->meta->make_mutable;
}
Class::Unload->unload($resultset_class) if $unload;
. qq|# DO NOT MODIFY THE FIRST PART OF THIS FILE\n\n|
. qq|use strict;\nuse warnings;\n\n|;
if ($self->use_moose) {
- $src_text.= qq|use Moose;\nuse MooseX::NonMoose;\nuse namespace::autoclean;\nextends '$result_base_class';\n\n|;
+ $src_text.= qq|use Moose;\nuse MooseX::NonMoose;\nuse namespace::autoclean;|;
+
+ # these options 'use base' which is compile time
+ if ($self->left_base_classes || $self->additional_base_classes) {
+ $src_text .= qq|\nBEGIN { extends '$result_base_class' }\n\n|;
+ }
+ else {
+ $src_text .= qq|\nextends '$result_base_class';\n\n|;
+ }
}
else {
$src_text .= qq|use base '$result_base_class';\n\n|;
sub _inject {
my $self = shift;
my $target = shift;
- my $schema_class = $self->schema_class;
my $blist = join(q{ }, @_);
- warn "$target: use base qw/ $blist /;" if $self->debug && @_;
- $self->_raw_stmt($target, "use base qw/ $blist /;") if @_;
+
+ return unless $blist;
+
+ warn "$target: use base qw/$blist/;" if $self->debug;
+ $self->_raw_stmt($target, "use base qw/$blist/;");
}
sub _result_namespace {
my @methods;
- for my $class ($base, @components) {
+ for my $class ($base, @components, $self->use_moose ? 'Moose::Object' : ()) {
eval "require ${class};";
die $@ if $@;
my %methods;
@methods{@methods} = ();
+ # futureproof meta
+ $methods{meta} = undef;
+
while (my ($col, $info) = each %$col_info) {
my $accessor = $info->{accessor} || $col;
my $extra_count = $self->{extra}{count} || 0;
- plan tests => @connect_info * (181 + $extra_count + ($self->{data_type_tests}{test_count} || 0));
+ plan tests => @connect_info * (182 + $extra_count + ($self->{data_type_tests}{test_count} || 0));
foreach my $info_idx (0..$#connect_info) {
my $info = $connect_info[$info_idx];
my $debug = ($self->{verbose} > 1) ? 1 : 0;
+ eval <<'EOF';
+require Moose;
+require MooseX::NonMoose;
+require namespace::autoclean;
+EOF
+ my $use_moose = $@ ? 0 : 1;
+
my %loader_opts = (
constraint =>
qr/^(?:\S+\.)?(?:(?:$self->{vendor}|extra)_?)?loader_?test[0-9]+(?!.*_)/i,
dump_directory => $DUMP_DIR,
datetime_timezone => 'Europe/Berlin',
datetime_locale => 'de_DE',
+ use_moose => $use_moose,
%{ $self->{loader_options} || {} },
);
isa_ok( $rsobj35, "DBIx::Class::ResultSet" );
my @columns_lt2 = $class2->columns;
- is_deeply( \@columns_lt2, [ qw/id dat dat2 set_primary_key dbix_class_testcomponent/ ], "Column Ordering" );
+ is_deeply( \@columns_lt2, [ qw/id dat dat2 set_primary_key dbix_class_testcomponent meta/ ], "Column Ordering" );
is $class2->column_info('set_primary_key')->{accessor}, undef,
'accessor for column name that conflicts with a result base class method removed';
is $class2->column_info('dbix_class_testcomponent')->{accessor}, undef,
'accessor for column name that conflicts with a component class method removed';
+ is $class2->column_info('meta')->{accessor}, undef,
+ 'accessor for column name that conflicts with Moose removed';
+
my %uniq1 = $class1->unique_constraints;
my $uniq1_test = 0;
foreach my $ucname (keys %uniq1) {
dat2 VARCHAR(32) NOT NULL,
set_primary_key INTEGER $self->{null},
dbix_class_testcomponent INTEGER $self->{null},
+ meta $self->{null},
UNIQUE (dat2, dat)
) $self->{innodb}
},