Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Presence of a DESTROY method in base class confuses MX::NM #15

Open
ribasushi opened this issue Sep 30, 2016 · 5 comments
Open

Presence of a DESTROY method in base class confuses MX::NM #15

ribasushi opened this issue Sep 30, 2016 · 5 comments

Comments

@ribasushi
Copy link

perl -e '
  {
    package GrandParent;

    # this line alone causes MooseX::NonMoose to loose its shit
    sub DESTROY { 1 };

    sub new { bless {}, $_[0] }
  }

  {
    package Parent;

    use Moose;
    use namespace::autoclean;
    use MooseX::NonMoose;

    extends "GrandParent";

    __PACKAGE__->meta->make_immutable;
  }

  {
    package Child;                                                                          

    use Moose;
    use namespace::autoclean;
    use MooseX::NonMoose;

    extends "Parent";

    __PACKAGE__->meta->make_immutable;
  }                                                                          
'

results in

Not inlining a constructor for Child since its parent Parent doesn't contain a constructor named 'new'. If you are certain you don't need to inline your constructor, specify inline_constructor => 0 in your call to Child->meta->make_immutable
@ribasushi
Copy link
Author

@haarg this inconsistency may be of interest to you as well

@KES777
Copy link

KES777 commented Jul 11, 2018

I get similar error. I have App::Schema::Result::Table dumped with dbicdump

Then I change:

-extends 'DBIx::Class::Core';
+extends 'App::Schema::Result';

and add base class. $ cat App/Schema/Result.pm:

package App::Schema::Result;

use Modern::Perl;
use base 'DBIx::Class::Core';

# Put useful things here which will be available from any Result:: class
__PACKAGE__->load_components(qw/
        +HyperMouse::Schema::DefaultResult::HyperMouse
        +HyperMouse::Schema::DefaultResult::I18nRelationships
        +HyperMouse::Schema::DefaultResult::DeepRelationships
        +HyperMouse::MTemporal::Role::Result
        Helper::Row::SelfResultSet
        InflateColumn::DateTime
        EncodedColumn
/);

1;

AFter this I get error for every my Result/Table.pm:

Not inlining a constructor for App::Result::PartnershipObligation since its parent App::Schema::Result doesn't contain a constructor named 'new'. If you are certain you don't need to inline your constructor, specify inline_constructor => 0 in your call to App::Schema::Result::Table->meta->make_immutable

@KES777
Copy link

KES777 commented Jul 11, 2018

And this error while trying to get data from database:

DBIx::Class::ResultSet::new_result(): App::Schema::Result::PartnershipAgreement->new returned a blessed empty hashref - a strong indicator something is wrong with its inheritance chain at

@Ovid
Copy link

Ovid commented Sep 10, 2020

For what it's worth, I've a client trying to switch a DBIC hierarchy to Moose. I was getting the returned a blessed empty hashref error. They make heavy use of DBIC components and in one of them, it turns out that it had use Moo at the top of one of the components. Switching that to use Moose made the issue go away.

@jbakerdev
Copy link

Is there a recommended approach for the "not inlining a constructor" message?

In my use case (with DBIx::Class and moose-ified Result/Result classes) I have to add:

__PACKAGE__->meta->make_immutable( inline_constructor => 0 );

to all my result classes (which would be the "Child" class in @ribasushi's example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants