Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

[Validator] Fixing UniqueEntityValidator bug when using Oracle database #4730

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets:
Todo:
License of the code: MIT
Documentation PR:

Summary

When using Symfony/Doctrine with Oracle database a type conversion bug might appear when using the UniqueEntity constraint. The pair field type and value type is not checked before calling database for unicity check causing Oracle to throw exceptions.

Details

An entity containing an numeric id fields.

<?php 
     /**
     * @ORM\Id
     * @ORM\Column(type = "integer")
     */
    private $id;

An UniqueEntity based on the id.

<?php 
    /**
     * @DoctrineAssert\UniqueEntity(fields = {"id"})
     */
    class MyEntity

If in a form you enter a string value for the id, the call to the database is done anyway. When using MySQL this behaviour seems to be ok (Comparison of strings and integer). While Oracle is throwing an ORA-01722 error.

Solution

Adding a string-numeric conversion check before submitting it to the database.

Member

stof commented Jul 3, 2012

@beberlei isn't it a bug in the ORM missing a type conversion ?

Contributor

beberlei commented Jul 3, 2012

What Oracle error is thrown? The change here is not really good, it just fights a sympton not the root cause.

Member

stof commented Jul 3, 2012

and this change is also likely to break the validator when using the MongoDB or CouchDB ODMs btw.

What Oracle error is thrown? The change here is not really good, it just fights a sympton not the root cause.

ORA-01722 as shown in the PR body.

and this change is also likely to break the validator when using the MongoDB or CouchDB ODMs btw.

Hm why would it?

Member

stof commented Jul 3, 2012

@iammichiel because you are accessing the internal representation of the metadata, not only the common api.

In that case, what is the next move?

Member

stof commented Jul 5, 2012

@iammichiel fixing Doctrine to avoid triggering this oracle issue in its findBy method

Owner

fabpot commented Jul 9, 2012

Can I close this PR? Has someone created a ticket for Doctrine?

Contributor

asm89 commented Jul 12, 2012

@fabpot This PR can be closed. I created a ticket here: http://www.doctrine-project.org/jira/browse/DDC-1923.

@beberlei beberlei closed this Jul 12, 2012

@stof Thanks for the ticket.

@doctrinebot doctrinebot referenced this pull request in doctrine/doctrine2 Dec 6, 2015

Open

DDC-1923: Type conversion error with oracle #2592

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment