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

[5.6] fix pivot timestamp columns without parent #23917

Merged
merged 1 commit into from Apr 18, 2018
Merged

[5.6] fix pivot timestamp columns without parent #23917

merged 1 commit into from Apr 18, 2018

Conversation

browner12
Copy link
Contributor

The motivation of this PR is to allow Pivot models to be queried and saved just like normal Models.

Previously, when trying to save pivot models, an error would be thrown because no pivotParent existed on the model.

This was due to the getCreatedAtColumn() and getUpdatedAtColumn() methods being called. It erred with "Call to a member function getCreatedAtColumn() on null".

This PR makes sure we first check if the pivotParent property exists. If it does, we continue to use the pivot parent's methods. However, if it doesn't, we fallback to the Models methods.

The tests I've added cover both cases of having a pivotParent and not having one.

- check to see if `pivotParent` exists before getting its timestamp columns.
- if there is no parent, fallback to the parent `Model` methods.
- add tests. 1 for when a parent exists, and 1 for when it doesn't
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

2 participants