Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Turn persist_once on by default
- Loading branch information
Showing
2 changed files
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
6c5da4dThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change the default behavior of Alice, it would be great to throw an help message if an error like
"Entity of type My\Bundle\Entity\Foo has identity through a foreign entity My\Bundle\Entity\Bar, however t his entity has no identity itself." happens.
6c5da4dThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify how and why you get this error? I don't really see how it makes a difference to persist once or several times, but I'm probably missing something.
6c5da4dThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I defined a first file with this structure:
and a second file:
Before your default option change, a persist was performed between this two files, and the relation was successfully persisted.
Now, the error "Entity of type My\Bundle\Entity\Foo has identity through a foreign entity My\Bundle\Entity\Bar, however t his entity has no identity itself." is thrown because Bar references a non persisted Foo object, and FK cannot be set.
I would be surprised that this bug was isolated, references are one of the great feature of Alice ;)
6c5da4dThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is weird though, I thought doctrine could deal with that fine by saving the Foo object first. Any thoughts on this @marekkalnik? Seems like you told me the fix was to allow cross-file references, and now it seems it actually prevents them. I'm confused :)
6c5da4dThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check it out in few hours. I have tested and everything seemed to be ok. I'll get back to you.
6c5da4dThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I had to work late and I couldn't test it. May I suggest that you change the behavior to "false" to avoid regression and I'll continue to test it? I gues that it is related to the way Doctrine handles PostgresSQL ids (I tested on a Postgres project, and the ids are automatically injected from sequences), but I have had no time to re-test it and make sure it's not an error in my code.
6c5da4dThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, no worries. I guess I'll just revert and tag a new release, then we can see about this later if it's fixable.
6c5da4dThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.5.1 tagged /cc @baldurrensch
6c5da4dThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I've tested a bit, and I can't seem to reproduce the error. I guess it depends on Doctrine version (I'm using 2.3). As for the feature itself turning persist_once on or off does not change anything, so I guess the "fix" was coincidentally somewhere in my code. Turns out it became just a minor performance improvement for those that use newer doctrine versions :(