Skip to content

fix date format on oracle#557

Closed
Tobion wants to merge 1 commit intodoctrine:masterfrom
Tobion:patch-3
Closed

fix date format on oracle#557
Tobion wants to merge 1 commit intodoctrine:masterfrom
Tobion:patch-3

Conversation

@Tobion
Copy link
Contributor

@Tobion Tobion commented Mar 28, 2014

The expected format for DATE columns is 01-MAR-14. See http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT413

It also works with 01-Mar-2014 as this PR uses.

We found the problem when trying something like

$this->oci8Con->executeQuery(
    'SELECT * FROM table WHERE datefield > ?',
    array(new \DateTime()),
    array(Type::DATE)
);

which was raising an oracle error that the date could not be parsed.

The time format in getTimeFormatString is also wrong because according to the above doc, times can only be passed by using TO_DATE('13-AUG-66 12:56 A.M.','DD-MON-YY HH:MI A.M.').
So this requires wrapping the SQL with a TO_DATE function.

@doctrinebot
Copy link

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DBAL-852

We use Jira to track the state of pull requests and the versions they got
included in.

@Tobion Tobion mentioned this pull request Mar 28, 2014
@deeky666
Copy link
Member

You have to use OracleSessionInit to get the date formats right. See the documentation.
I cannot remember anymore why this is necessary but there definitely is a reason for this. I think it's because Doctrine requires some convenient format for date type columns. However this is the way users are handling this kind of problem and we won't be able to change this behaviour anyways in 2.x as it would break users' applications badly. So please bare with me closing this issue. Use the OracleSessionInit listener and it will fix your issue. If you have further question I will help you :)

@deeky666 deeky666 closed this Mar 28, 2014
@Tobion
Copy link
Contributor Author

Tobion commented Mar 29, 2014

Thanks for the answer. Is it gonna be fixed in 3.0? Imho it should work out-of-the-box and not require some listeners to be activated manually.

@Tobion Tobion deleted the patch-3 branch November 5, 2014 10:49
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 25, 2022
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