8000 Remove incompatibility between \DateTime and \DateTimeImmutable by neomerx · Pull Request #2678 · doctrine/dbal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Remove incompatibility 8000 between \DateTime and \DateTimeImmutable #2678

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

Closed
wants to merge 1 commit into from
Closed

Conversation

neomerx
Copy link
@neomerx neomerx commented Mar 17, 2017

... by using \DateTimeInterface instead.

Current implementation forbids using \DateTimeImmutable.

As only format method defined in \DateTimeInterface is really used it makes sense to use interface instead of the class.

@lcobucci
Copy link
Member

That cannot be done in this way since it will always create an instance of the mutable one when retrieving from database.

#2450 solves that by adding new types for the immutable DateTime.

@lcobucci lcobucci closed this Mar 17, 2017
@neomerx
Copy link
Author
neomerx commented Mar 17, 2017

@lcobucci The request is not intended to replace #2450 but rather make the lib usable with \DateTimeImmutable.

Currently you declare master branch compatible with 2.6 which is not in fact (I'd rather call it a bug btw) for the reason you require dates to be \DateTime where \DateTimeImmutable is enough. And this causes inompatibility between 2.6 and master.

UPD: I meant 2.5 and master

Can you please reconsider it? I believe the change worth merging.

@neomerx
Copy link
Author
neomerx commented Mar 17, 2017

Aha-ha 😄 I thought 2.6 is declared as stable (or at least compatible with 2.5). My bad ) But still I think it worth merging.

@Ocramius
Copy link
Member

The approach in this PR is wrong because a user may map a field as DateTime, store a DateTimeImmutable, then clear the UoW, reload the entity and have a DateTime in that field. The asimmetricity makes this PR invalid.

@neomerx
Copy link
Author
neomerx commented Mar 18, 2017

That's up to you guys. I don't see it as problem if user 'map a field as DateTime' and then 'have a DateTime in that field' even if a \DateTimeImmutable was passed for storing to database.
The current code requires much more from input data than it actually needs. Does it serve a purpose? You say it does however obviously not its own purpose. Is it a way it should be designed? That's you to decide.

@Ocramius
Copy link
Member
Ocramius commented Mar 19, 2017 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0