Versionable Behaviour : bug with multiple identical related objects #876
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
I think I might found a bug with the versionable behaviour. It happens when a versionable table links twice an other versionable table. I said I might because it could also be that I'm not using the versionable behaviour as I should. In fact I'm having 2 issues, as I will explain.
I have a lease contract, which is signed between two companies, a renter, and a tenant. I'm working within a symfony2 project. I have the following schema :
In one bundle, the company :
In an other bundle, the contract :
This schema results in 4 tables : contract, contract_version, company and company_version.
First issue
Console :
The bug comes from the fact that there is no company version created. I have fixed it by overloading the enforceVersioning method in the Contract.php :
Ok, now it works. I assume that I'm doing something wrong in the way I'm doing my work for this point because I have read that the versionable behaviour handles itself the related tables. Obviously I have not found what so I'm doing this bugfix in my code. For the second bug, I really believe there is an issue with the behaviour, that's why I creating this pull request. The purpose og this pull request is not to fix this issue, bug the second one.
Second issue
Console :
This is the content of company_version table after the code execution :
The bug is in the populateFromVersion of BaseCompany.
The request made to retreive related contract_versions where the company belongs as the tenant is made as so :
So we have one contract.
The request made to retreive related contract_versions where the company belongs as the renter is made as so :
So we have one contract.
Both requests are identical, and they sould not.
With this pull request, here are the requests generated in populateFromVersion :
as a renter :
as a tenant :
So the Company is either found as a tenant company or a renter company, but not for both. The output is now :