[DBAL-484] [GH-298] Fix SQL Server default constraints Created: 04/Apr/13  Updated: 16/Sep/13  Resolved: 06/Apr/13

Status: Resolved
Project: Doctrine DBAL
Component/s: None
Affects Version/s: None
Fix Version/s: 2.4
Security Level: All

Type: Bug Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/dbal/pull/298

Message:

This PR fixes altering column default values. In SQL Server column default values are stored in constraints. <code>CREATE TABLE</code> statements with column declarations like <code>some_column NVARCHAR(50) NOT NULL DEFAULT 'default value'</code> internally creates a default constraint with an automatically generated name in the the system table `sys.default_constraints`. <code>ALTER TABLE</code> statements do not support the <code>DEFAULT</code> clause in column alteration declarations, leading in SQL syntax errors. Thus changing a column's default value is currently not possible.
To alter a column's default value, the old column's default constraint hast to be dropped and recreated again. As a default constraint has to be referenced by name to be dropped, we need to create each default constraint with an own unique name. This PR generates separate statements for default constraint declarations. It generates a unique name consisting of the table name and the column name the default constraint is created for.
<code>DF_TABLE_NAME_HASH%_%COLUMN_NAME_HASH%</code>



 Comments   
Comment by Benjamin Eberlei [ 06/Apr/13 ]

A related Github Pull-Request [GH-298] was closed
https://github.com/doctrine/dbal/pull/298

Comment by Doctrine Bot [ 16/Sep/13 ]

A related Github Pull-Request [GH-298] was closed:
https://github.com/doctrine/common/pull/298

Generated at Sat Apr 19 22:37:41 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.