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

Fix for issue #677: Set the back reference #678

Merged
merged 3 commits into from
May 6, 2013
Merged

Fix for issue #677: Set the back reference #678

merged 3 commits into from
May 6, 2013

Conversation

danez
Copy link
Contributor

@danez danez commented May 3, 2013

When calling add...() on an BaseObject to add a crossreference, the generated code now sets the backreference on the Object that is given to the add function.
This ensures that all references are already set when the object is still not saved.

On the other hand I add a clone in the hasCode function to ensure that the the hasCode function never ever changes the original request as it is not necessary.

Daniel Tschinder added 2 commits May 3, 2013 23:19
Provided tests for testing if all references are set for crossreferences before saving
…nged when calling hashCode

provided test for the hasCode() function
@willdurand
Copy link
Contributor

looks good to me. @staabm?

@staabm
Copy link
Member

staabm commented May 6, 2013

@danez did the tests fail without the patch, otherwise LGTM.

You should always create the test first. This eases handling on our side and also makes sure that the fix works correctly.

@danez
Copy link
Contributor Author

danez commented May 6, 2013

Okay sorry, next time i commit the tests separately first.
Without the fixes in generated object and BaseObject::hashCode:

1) GeneratedObjectRelTest::testManyToManySetterIsNotLoosingAnyReference
setRelCol is losing backreference on set objects
Failed asserting that actual size 0 matches expected size 1.

/Users/user/Propel/test/testsuite/generator/builder/om/GeneratedObjectRelTest.php:205

2) BaseObjectHashCodeTest::testUnsavedObjectCallingHashCodeIsNotChangingObject
Failed asserting that two objects are equal.
--- Expected
+++ Actual
@@ @@
     'age' => null
-    'collBooks' => null
+    'collBooks' => PropelObjectCollection Object (...)
     'collBooksPartial' => true
     'collEssaysRelatedByFirstAuthor' => null
     'collEssaysRelatedByFirstAuthorPartial' => null
     'collEssaysRelatedBySecondAuthor' => null
     'collEssaysRelatedBySecondAuthorPartial' => null
     'alreadyInSave' => false
     'alreadyInValidation' => false
     'alreadyInClearAllReferencesDeep' => false
     'booksScheduledForDeletion' => null
     'essaysRelatedByFirstAuthorScheduledForDeletion' => null
     'essaysRelatedBySecondAuthorScheduledForDeletion' => null
     'validationFailures' => Array ()
     '_new' => true
     '_deleted' => false
     'modifiedColumns' => Array (...)
     'virtualColumns' => Array ()
 )

/Users/user/Propel/test/testsuite/runtime/om/BaseObjectHashCodeTest.php:37

@danez
Copy link
Contributor Author

danez commented May 6, 2013

I changed the order of the parameters so in the test the actual and expected values are correct.

willdurand added a commit that referenced this pull request May 6, 2013
Fix for issue #677: Set the back reference
@willdurand willdurand merged commit 6962c77 into propelorm:master May 6, 2013
@willdurand
Copy link
Contributor

thanks!

@staabm
Copy link
Member

staabm commented May 6, 2013

@danez no problem, just a hint to make things better next time. thanks for your contribution!

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.

6 participants