mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-110: Oracle DateTime Type support mismatch of DateTime Format and Database value lets conversion fail #136
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Nov 4, 2009).
Originally assigned to: @jwage on GitHub.
Jira issue originally created by user @beberlei:
I get a fatal error on the Oracle Testsuite:
@doctrinebot commented on GitHub (Nov 4, 2009):
@doctrinebot commented on GitHub (Nov 4, 2009):
Comment created by @beberlei:
Simple Fix would be:
However i think Oracle and Date fields doesn't work correctly, I'll investigate more.
@doctrinebot commented on GitHub (Nov 4, 2009):
Comment created by @beberlei:
Correct, DateTime Type support in Oracle is broken:
in convertToPHPValue i get as value: 04-NOV09 11.35.15 AM +01.00
as Platform DateTime Format I get: Y-m-d H:i:sP
This combination returns false in DateTime::createFromFormat()
@doctrinebot commented on GitHub (Nov 4, 2009):
Comment created by @beberlei:
Renamed bug title
@doctrinebot commented on GitHub (Nov 5, 2009):
Comment created by romanb:
This is actually a known issue and I dont think there is an easy solution for this. The point is, the format returned by oracle must match the format defined in the platform class.
For mysql or postgresql this is no problem because they accept a wide range of different formats as input. Oracle, however, only exactly the format that is configured.
Also, the default format of oracle can depend on the installation, locale/language, etc. So the only way to make datetime/date/time types work on oracle is to make the formats match. That means you either change the database format, or you change the format in the platform. The latter can happen through writing a custom platform class that inherits from oracle platform and overrides the respective methods. Alternatively we could provider setters on the platform classes for these formats (setTimeFormat... etc).
To change the format used by oracle to match the default format used by doctrine, put the following in your initXE.ora (assuming Oracle XE):
Hopefully, whoever uses oracle in production has a DBA at his side anyway ;)
@doctrinebot commented on GitHub (Nov 7, 2009):
Comment created by @guilhermeblanco:
Isn't it possible to get the configuration format from Database during Config initialization?
@doctrinebot commented on GitHub (Nov 11, 2009):
Comment created by @jwage:
We need to just document this. The default format Oracle has configured cannot be parsed by strtotime() so they will always need to configure it.
@doctrinebot commented on GitHub (Nov 11, 2009):
Issue was closed with resolution "Invalid"
@doctrinebot commented on GitHub (Jan 31, 2010):
Comment created by @beberlei:
lsmith made a statement in IRC that MDB2 has a configuration option for this, there should be an event in "Doctrine\DBAL\Connection::connect()" where you get passed the driver and can execute driver specific code.
Additionally I'll start an appendix section "Platform Quirks" - where we can document specifics of using a platform.
@doctrinebot commented on GitHub (Jan 31, 2010):
Comment created by @beberlei:
Patch attached that adds a new event "postDriverConnect". Arguments to this event is the Connection with convenience methods to retrieve driver, platform and schema manager.
Added a new namespace/package Doctrine\DBAL\Event\Listeners which for now holds a OracleSessionInit class which sets all the 4 enviroment variables required for Doctrine to run and allows to set even more if that would be necessary.
An enhancement to Doctrine\Tests\TestUtil now allows to register "event subscribers" by setting a "db_event_subscribers" option in the phpunit configuration with a comma-separated list of class-names.
@doctrinebot commented on GitHub (Jan 31, 2010):
Comment created by romanb:
The idea looks ok, just a couple of small changes from my side:
@doctrinebot commented on GitHub (Jan 13, 2012):
Comment created by marc.campeau@gmail.com:
I'm curious as to what happened with this issue. I don't see the contents of the patch in the latest releases. Has this been left off main release and should be patched by anyone using Oracle or has this been refactored into some other code in latter releases. I'm running into this situation using Oracle and Doctrine 2.1 and would like to know how to fix this. Thanks
@doctrinebot commented on GitHub (Jan 13, 2012):
Comment created by marc.campeau@gmail.com:
Sorry found what I was looking for.
For the record: Patch Code was refactored as suggested by Roman S. Borschel above:
See DBAL Documentation about Events for an example on how to integrate: [http://www.doctrine-project.org/docs/dbal/2.1/en/reference/events.html]
@doctrinebot commented on GitHub (Dec 13, 2015):
Imported 1 attachments from Jira into https://gist.github.com/ec44c2d663922db160a7