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

Reduce inheritance, fix #91 #103

Closed
wants to merge 2 commits into from
Closed

Conversation

dakkar
Copy link

@dakkar dakkar commented Feb 27, 2020

I have removed most use parent, and replaced the necessary ones with the smallest needed class.

I've also added a test showing the problem reported in issue #91. I think the root of the problem is that derived classes that don't call load_components don't get the C3 mro.

All tests still pass on my machine.

having helpers inherit from Row, ResultSet &c causes problems when
loading multiple components: some base classes appear before
components in C3 resolution, and component methods get skipped

See for example issue frioux#91
the problem happens when iheriting from a class that `load_components`

I suspect the root of the problem is that the derived class doesn't
use C3
@dakkar
Copy link
Author

dakkar commented Feb 27, 2020

Yep, confirmed, adding use mro 'c3' to the derived classes in t/component-order.t makes it pass without my patches. I still think that it's a good idea to reduce the inheritance tree, though.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.005%) to 98.557% when pulling a171707 on dakkar:reduce-inheritance into 3ce57a3 on frioux:master.

@@ -5,9 +5,7 @@ package DBIx::Class::Helper::ResultSet::IgnoreWantarray;
use strict;
use warnings;

use parent 'DBIx::Class::ResultSet';

sub search :DBIC_method_is_indirect_sugar{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this attribute? Is this no longer needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I grepped for it in the source code of the latest released DBIC, and couldn't find it, so my tests failed. I don't know how they pass for you and CI, I suspect I'm missing something crucial.

@frioux
Copy link
Owner

frioux commented Feb 28, 2020

Unless you can show a concrete improvement from this patchset I'm inclined to close it. This is what DBIx::Class::Helper::Schema::Verifier::C3 was built to automate: people must use c3, one way or another, with DBIC.

@dakkar
Copy link
Author

dakkar commented Feb 29, 2020

people must use c3, one way or another, with DBIC

Very fair! Maybe add a line of documentation in https://github.com/frioux/DBIx-Class-Helpers/blob/master/lib/DBIx/Class/Helper/ResultSet.pm and to a Result helper or doc-only package, explaining that?

One of the problems is that Schema::Loader puts a use base in the generated Result classes, and no use mro 'c3', even whed a custom base class is specified (that's how I encountered this issue). Should I ask the Schema::Loader maintaner to add that?

@frioux
Copy link
Owner

frioux commented Feb 29, 2020

yeah they either need to use mro 'c3' or I think calling load_components does that for you as well.

@dakkar
Copy link
Author

dakkar commented Mar 1, 2020

I reported the suggestion to Schema::Loader https://rt.cpan.org/Ticket/Display.html?id=132035

@frioux
Copy link
Owner

frioux commented Mar 1, 2020

Cool. Gonna close this one now. Thanks!

@frioux frioux closed this Mar 1, 2020
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

Successfully merging this pull request may close these issues.

None yet

3 participants