symfony/symfony — pull request #4730 by iammichiel (2012-07-03 15:54:19+00:00)
Title: Fixing UniqueEntityValidator bug when using Oracle database

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.

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

An UniqueEntity based on the id.

/**
* @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.