Fix HasOneSql imported field update support#1038
Merged
Conversation
485b659 to
0102881
Compare
e34309c to
a92e401
Compare
a92e401 to
e261c22
Compare
e261c22 to
e772085
Compare
f19fc36 to
44c0238
Compare
44c0238 to
0fd39d6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fixes #929
closes #933
fixes atk4/filestore#26
data/src/Reference/HasOneSql.php
Lines 35 to 50 in 6657685
hook code is simply wrong.
In 5d49235 the code was intended to be fixed for changed values for different than
our_fieldfield. This caused data corruptions like atk4/filestore#26. The data corruption was hotfixed in #1037 but looking into this issue deeper, the hook should simply not be there. We cannot inferour_fieldvalues based on "imported"/"joined" fields, as these fields might not be unique and might represent totaly different relation.The proposed fix maintains the feature for the setting the
our_fieldvalue for a new record with our field equal to null, under this state, we can determine the foreign/their record based on the imported/joined field without the possibility to mismatch the our field. The relation to foreign/their record can still imply duplicates, but this is a decision by the developer.Making the field read only after the record is saved will fix also #929.
The update issue is obvious in https://github.com/atk4/data/blob/3.1.0/tests/ReferenceSqlTest.php#L562 test. How on Earth can "first name" solely uniquely locate a foreign user record?