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

Added support for polymorphic relations. Fixes #487. #864

Merged
merged 1 commit into from
Jan 21, 2015
Merged

Added support for polymorphic relations. Fixes #487. #864

merged 1 commit into from
Jan 21, 2015

Conversation

marcj
Copy link
Member

@marcj marcj commented Jan 20, 2015

$bindings[$index + 1] = $columnReference['foreign']->getPhpName();

if ($this->getForeignKey()->isPolymorphic()) {
throw new \InvalidArgumentException(sprintf('AggregateColumnBehavior does not work with polymorphic relations.'));
Copy link
Member

Choose a reason for hiding this comment

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

The sprintf call can be removed here

marcj added a commit that referenced this pull request Jan 21, 2015
Added support for polymorphic relations. Fixes #487.
@marcj marcj merged commit 579b2ab into propelorm:master Jan 21, 2015
@marcj
Copy link
Member Author

marcj commented Jan 21, 2015

Thanks guys!


return isset($m[$local]) ? $m[$local] : null;
$index = array_search($local, $this->localColumns);
return $this->foreignColumns[$index];
Copy link
Member

Choose a reason for hiding this comment

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

@marcj

should this return null when $local could not be found using array_search instead of issue a php warnig because of a undefined index $this->foreignColumns[$index]?

same below in getMappedLocalColumn()

Copy link
Member Author

Choose a reason for hiding this comment

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

No, if it can't be found, it's a internal error and should trigger warnings/errors. returning null would be wrong.

Copy link
Member

Choose a reason for hiding this comment

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

but then we should throw a exception instead of implicitly rely on the warning? This is public api, so it should help the user to find the cause of errors

Copy link
Member Author

Choose a reason for hiding this comment

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

Feel free. I don't think it's necessary as it's only used in internal code.

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