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

Changing private -> protected for extensibility #519

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

benmcmath
Copy link

Recently needed to extend Table.php and Model.php and it required us to convert private methods and properties to protected. Figured it would be a good change for the project.

@jpfuentes2
Copy link
Owner

Thanks, @benmcmath -- I see no reason we can't accept this now, @koenpunt ?

@koenpunt
Copy link
Collaborator

there are probably some internal methods that will never require any override, but I'm not against.

That second commit needs tests though.

@jpfuentes2
Copy link
Owner

We likely already have sufficient coverage for that 2nd commit, right?

@koenpunt
Copy link
Collaborator

The tests don't break by changing it, and didn't break before, so I'm pretty sure we're missing a test for the faulty behaviour.

@jpfuentes2
Copy link
Owner

Wait, are we sure anything is faulty here? I think we have sufficient eager loading tests to capture this but perhaps not.

@@ -602,7 +602,7 @@ public function create_association(Model $model, $attributes=array(), $guard_att
public function load_eagerly($models=array(), $attributes=array(), $includes, Table $table)
{
$this->set_keys($table->class->name);
$this->query_and_attach_related_models_eagerly($table,$models,$attributes,$includes,$this->foreign_key, $table->pk);
$this->query_and_attach_related_models_eagerly($table,$models,$attributes,$includes,$this->foreign_key, $this->primary_key);
Copy link
Owner

Choose a reason for hiding this comment

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

@benmcmath are you able to explain the purpose this change?

Copy link
Author

Choose a reason for hiding this comment

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

To use the primary key on the association, and not the table. Primary key can be explicitly set in the association, and that key might be different than the table's primary key. I believe if the association doesn't have a primary key, the table's primary key is used.

Copy link
Owner

Choose a reason for hiding this comment

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

Ding ding: this rings a bell now. @koenpunt is right, we'll want a test for this.

@koenpunt
Copy link
Collaborator

But if the behavior of this change was tested, it should break by now, but it doesn't, so even if this change isn't what we want, we're still missing tests for it.

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.

3 participants