DBAL-484: [GH-298] Fix SQL Server default constraints #1685

doctrinebot opened this Issue Apr 4, 2013 · 3 comments

2 participants


Jira issue originally created by user @beberlei:

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

Url: #298


This PR fixes altering column default values. In SQL Server column default values are stored in constraints. CREATE TABLE statements with column declarations like somecolumn NVARCHAR(50) NOT NULL DEFAULT 'default value' internally creates a default constraint with an automatically generated name in the the system table `sys.defaultconstraints`. ALTER TABLE statements do not support the DEFAULT 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.


Comment created by @beberlei:

A related Github Pull-Request [GH-298] was closed


Issue was closed with resolution "Fixed"


Comment created by @doctrinebot:

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

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