DBAL-833: [GH-542] [DBAL-825] Drop default constraints before altering column type on SQL Server #2068

Closed
doctrinebot opened this Issue Mar 7, 2014 · 5 comments

2 participants

@doctrinebot

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of deeky666:

Url: #542

Message:

SQL Server implements column default values as constraints and therefore requires them to be dropped before a column type change.
This PR implements the recreation of default constraints on column type alterations.
Additionally some code in SQLServerPlatform::getAlterTableSQL() has been refactored to avoid code duplication and unnecessary SQL generation.
Please note that due to the issue's tests the PostgreSQL platform had to be altered to fulfill the same behaviour. PostgreSQL returned some strange default value like 666:smallint when reverse engineering a column type change with a default value of 666 from type smallint to integer. So I think this PR fixes a bug in this platform, too. Additionally I had to change the deprecated default value retrieval SQL in PostgreSQL in order to work flawlessly. See the documentation at the very end.

I would also like to note that this PR is definitely not the end of the line concerning default values and column alterations. Some weird errors were revealed on other platforms while fixing this issue. MySQL for example denies default values on BLOB/TEXT type columns, DB2 just throws non-understandable syntax errors around and Oracle seems to map decimal/numeric types without a defined scale to integer when reverse engineering (not really related to this issue but it came up while testing).

Otherwise the tests pass on all platforms.

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-536] was closed:
#536

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-542] was closed:
#542

@doctrinebot

Comment created by @deeky666:

Fixed in commit: 171a876

@doctrinebot

Issue was closed with resolution "Duplicate"

@doctrinebot doctrinebot added the Bug label Dec 7, 2015
@deeky666 deeky666 was assigned by doctrinebot Dec 7, 2015
@doctrinebot doctrinebot added this to the 2.5 milestone Dec 7, 2015
@doctrinebot doctrinebot closed this Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment