{"action":"created","issue":{"url":"https://api.github.com/repos/VasekPurchart/Doctrine-Date-Time-Immutable-Types/issues/7","repository_url":"https://api.github.com/repos/VasekPurchart/Doctrine-Date-Time-Immutable-Types","labels_url":"https://api.github.com/repos/VasekPurchart/Doctrine-Date-Time-Immutable-Types/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/VasekPurchart/Doctrine-Date-Time-Immutable-Types/issues/7/comments","events_url":"https://api.github.com/repos/VasekPurchart/Doctrine-Date-Time-Immutable-Types/issues/7/events","html_url":"https://github.com/VasekPurchart/Doctrine-Date-Time-Immutable-Types/issues/7","id":153606363,"number":7,"title":"Seems you are missing convertToDatabaseValue","user":{"login":"basz","id":143068,"avatar_url":"https://avatars.githubusercontent.com/u/143068?v=3","gravatar_id":"","url":"https://api.github.com/users/basz","html_url":"https://github.com/basz","followers_url":"https://api.github.com/users/basz/followers","following_url":"https://api.github.com/users/basz/following{/other_user}","gists_url":"https://api.github.com/users/basz/gists{/gist_id}","starred_url":"https://api.github.com/users/basz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basz/subscriptions","organizations_url":"https://api.github.com/users/basz/orgs","repos_url":"https://api.github.com/users/basz/repos","events_url":"https://api.github.com/users/basz/events{/privacy}","received_events_url":"https://api.github.com/users/basz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-05-07T17:26:34Z","updated_at":"2016-05-08T16:54:27Z","closed_at":null,"body":"without adding the following an exception is still thrown\r\n\r\n```\r\n// src/DateImmutableType.php\r\n\r\n\t/**\r\n\t * {@inheritdoc}\r\n\t */\r\n\tpublic function convertToDatabaseValue($value, AbstractPlatform $platform)\r\n\t{\r\n\t\tif (null === $value) {\r\n\t\t\treturn $value;\r\n\t\t}\r\n\r\n\t\tif ($value instanceof DateTimeImmutable) {\r\n\t\t\treturn $value->format($platform->getDateTimeFormatString());\r\n\t\t}\r\n\r\n\t\tthrow ConversionException::conversionFailedInvalidType($value, $this->getName(), ['null', 'DateTimeImmutable']);\r\n\t}\r\n```"},"comment":{"url":"https://api.github.com/repos/VasekPurchart/Doctrine-Date-Time-Immutable-Types/issues/comments/217732716","html_url":"https://github.com/VasekPurchart/Doctrine-Date-Time-Immutable-Types/issues/7#issuecomment-217732716","issue_url":"https://api.github.com/repos/VasekPurchart/Doctrine-Date-Time-Immutable-Types/issues/7","id":217732716,"user":{"login":"VasekPurchart","id":406821,"avatar_url":"https://avatars.githubusercontent.com/u/406821?v=3","gravatar_id":"","url":"https://api.github.com/users/VasekPurchart","html_url":"https://github.com/VasekPurchart","followers_url":"https://api.github.com/users/VasekPurchart/followers","following_url":"https://api.github.com/users/VasekPurchart/following{/other_user}","gists_url":"https://api.github.com/users/VasekPurchart/gists{/gist_id}","starred_url":"https://api.github.com/users/VasekPurchart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VasekPurchart/subscriptions","organizations_url":"https://api.github.com/users/VasekPurchart/orgs","repos_url":"https://api.github.com/users/VasekPurchart/repos","events_url":"https://api.github.com/users/VasekPurchart/events{/privacy}","received_events_url":"https://api.github.com/users/VasekPurchart/received_events","type":"User","site_admin":false},"created_at":"2016-05-08T16:54:27Z","updated_at":"2016-05-08T16:54:27Z","body":"Hi, thanks for letting me know about this, I searched when this got changed and the originating PR seems to be https://github.com/doctrine/dbal/pull/869.\r\n\r\nI have always tried to keep the code in the immutable types as close as possible to the original one (to provide easiest migration path), but with this change I am not sure how to approach it. The problem is the new validation logic is using previously not existing method `ConversionException::conversionFailedInvalidType`, which means if the logic is going to change, then also the minimum requirement on DBAL has to be changed. Which I think is currently not a good idea since it is not a stable release. Other option would be testing the `ConversionException` in runtime, whether the method exists, which I don't like, because this is 1) not really pretty, 2) drifts the code apart from the original version.\r\n\r\nOther option, which comes to my mind is proposing in DBAL, that they change the check to DateTimeInterface, because that is what is really needed by the implementation, but I am not sure If they would accept it. Although introducing that check is essentially a BC break, because there was no documented type before. I would like this solution best, because even after this lands in (presumably) 2.6 it would force the users of this library to choose if they use a \"before 2.6\" version, or an \"after 2.6\" version :(."}}