-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Allow DateTimeImmutable
be part of composite key
#10830
base: 2.15.x
Are you sure you want to change the base?
Conversation
DateTimeImmutable
be part of composite key
What do you mean? |
3512b6e
to
7c049fe
Compare
You may disregard the documentation build, it's not stable yet. |
When can I expect a review of PR? |
There 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.
Codecov reported 2 blocks of code as uncovered, did you notice that?
{ | ||
$article = new Article('Some title'); | ||
$article->changeTitle('New title'); | ||
sleep(1); |
There 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.
Please find a way to avoid this. Maybe define a class that extends DateTimeImmutable
and makes sure to add 1 second when the constructor is called, I don't know.
BTW, doesn't this point at a weakness of having time part of the composite key? What happens in high throughput scenarios? People might end up with entities with the same ID, might they not? I'm starting to have some doubts about this…
There 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 consider such validation as a part of entity design. Ofc I can add that validation in tested entities to get rid of that sleep
function.
It is not the responsibility of Doctrine to think for programmers on the consistency of their entities.
There 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.
It's not that I want to tell people what's wrong or right, but I would like to avoid people opening bug reports, have us help them debug only to find they are hitting this limitation. That's why I'm weary of code that works only if people know what they are doing.
There 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.
Agree but requirement of having unique entity identifier is not magic knowledge when you are dealing with ORM and even database I guess. What do you think?
There 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.
It sounds sensible. Let's keep that thread open, and see what other maintainers think.
It appears in the form of comments on the files tab, when you have a successful build (which explains why it isn't available right now). |
a9d437a
to
a4bfaa3
Compare
Everything passed now |
b02f1b2
to
d381656
Compare
@greg0ire Can you point me to a place where tests that cover |
I'm on my phone so no. Have you tried throwing an exception in nearby code and running the test suite. |
I figured out how to check that part of the code. I need more time for that and I'll let you know when it will be finished |
Any news? Faced same problem with |
There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days. |
Still actual problem. |
I'm faced too many issues in entity management when working on covering code with tests so I gave up. Maybe someone else based on my changes will have better idea how to solve it proper. AFAIR main issue was: to treat datetime field as part of key you must cast it to string, but you can't cast it to string because it has to be object field in other processes like persistence. With |
I've added implementation for the attached previously use-case.
The whole description can be found in the linked issue #10831