[DBAL-1087] Length of fixed string type (char) is ignored on Postgre schema update #751
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR should fix an issue for the fixed string type columns using PostgreSQL.
I've created a basic Symfony 2.6. Application and using a PostgreSQL 9.3. database. In this dummy project, I've created the following Entity:
The table is successfully created after a schema update, but when another schema update is executed without any changes to the entity, an ALTER query is executed:
After I searched in the code of doctrine dbal, I discovered that the length of the char column is not fetched correctly in
PostgreSqlSchemaManager::_getPortableTableColumnDefinition()
. In my example, length results asnull
and will be later set to 255 in theComparator
, which isn't the correct length from the database column. The comparation of the schemas results in a change of char-length.For simplicity, I extended the if-condition in
PostgreSqlSchemaManager
to:The fix I've contributed does help to parse the length in my case, but when I look into
PostgreSqlPlatform::initializeDoctrineTypeMappings()
there could be other types with the same problem, that are mapped to the doctrine string type.I guess we need to cover
char
and the others too.PostgreSqlSchemaManagerTest
also doesn't cover existing code. How is this going to be tested? Does the SchemaManagers need some tests in general?