The reason for this is because the ORM won't map unsigned ints for me. Combined with this is an event listener for the class metadata. Something like this:

/**
* Maps additional metadata.
*
* Specifically, if there exist an unsigned integer field, attach the
* "unsigned" option to it. This is required because the Doctrine ORM does
* not dothis and we are using "UNSIGNED INT"s in our MySQL columns.
* Without this. the Doctrine Schema Tool will complain about column
* differences.
*
* Note: there is no performance impact in doing this because the class
* metadata should be cached after the first request.
*
* @param LoadClassMetadataEventArgs $eventArgs
*/
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
{
foreach ($eventArgs->getClassMetadata()->fieldMappings as &$mapping) {
if (isset($mapping['type']) && UnsignedIntegerType::UNSIGNED_INTEGER === $mapping['type']) {
if (!isset($mapping['options'])) {
$mapping['options'] = array();
}
$mapping['options']['unsigned'] = true;
}
}
}

Now, in the example table above, the schema tool will honour the "id" column, however it won't honour the association join column no matter what I do. My attempts include adding an event listener for class meta data as above (basically tricking the ORM) and also adding an event listener for the schema events.

Also, comments and issues on the Jira tracker have said how there's legacy code related to "unsigned" and "default", but I can't tell what's legacy and what's allowed, especially when there's a commit like that one above.

By the way, I have found that the simple unsigned field mapping works. E.g.:

Is it possible to 1) fix this or 2) let me know if I'm just doing something wrong?

Note: as I said above, I know that Doctrine DBAL and ORM does not care so much for unsigned ints because of portability, etc. but it seems that because of that commit above (24 days ago), there's a half-implememented/legacy solution going on here.

Gaetan Rousseau
added a comment - 03/May/13 7:24 AM - edited This was not fixed. We can use the option "unsigned" for the fields but not the id.
If someone has a solution or if you can fix this, that would be really cool !

Gaetan Rousseau
added a comment - 03/May/13 2:37 PM After some research with a co-worker we've found a solution to our little problem.
To fix this you just have to add these lines in the YamlDriver (Doctrine/ORM/Mapping/Driver/YamlDriver.php) in the function "loadMetadataForClass", line 265 in the 2.3.3 version of Doctrine ORM :
if (isset($idElement['options'])) {
$mapping['options'] = $idElement['options'];
}
Just before the :
$metadata->mapField($mapping);
And that an example of schema :
Entities\Test:
type: entity
table: Test
id:
id:
type: integer
options:
unsigned: true
generator:
strategy: AUTO
fields:
testField:
type: smallint
options:
unsigned: true
With this, the id can be unsigned without using special type of column, and yes just with this little if
It has been tested in more complexes schemas and all is going well.
In fact, maybe it could be interesting to use the function "columnToArray" like it's used for the other fields.
In the two cases you must care about what you put in your "options" section.

Gaetan Rousseau i just now found this additional bug report here in the comments. I opened DDC-2661 for it and fixed it. Will be included in 2.4.1. Please don't report additional bugs in already closed issues in the future, because they can easily get lost.

Benjamin Eberlei
added a comment - 08/Sep/13 8:39 AM Gaetan Rousseau i just now found this additional bug report here in the comments. I opened DDC-2661 for it and fixed it. Will be included in 2.4.1. Please don't report additional bugs in already closed issues in the future, because they can easily get lost.