Skip to content

Changing private -> protected for extensibility#519

Open
benmcmath wants to merge 2 commits intojpfuentes2:masterfrom
benmcmath:master
Open

Changing private -> protected for extensibility#519
benmcmath wants to merge 2 commits intojpfuentes2:masterfrom
benmcmath:master

Conversation

@benmcmath
Copy link
Copy Markdown

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.

Ben McMath added 2 commits January 27, 2016 11:06
@jpfuentes2
Copy link
Copy Markdown
Owner

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

@koenpunt
Copy link
Copy Markdown
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
Copy Markdown
Owner

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

@koenpunt
Copy link
Copy Markdown
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
Copy Markdown
Owner

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

Comment thread lib/Relationship.php
{
$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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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