Skip to content

Fix SQL Server default constraints #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

deeky666
Copy link
Member

@deeky666 deeky666 commented Apr 4, 2013

This PR fixes altering column default values. In SQL Server column default values are stored in constraints. CREATE TABLE statements with column declarations like some_column NVARCHAR(50) NOT NULL DEFAULT 'default value' internally creates a default constraint with an automatically generated name in the the system table sys.default_constraints. 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.
DF_TABLE_NAME_HASH%_%COLUMN_NAME_HASH%

@doctrinebot
Copy link

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DBAL-484

beberlei added a commit that referenced this pull request Apr 6, 2013
…alue-alteration

Fix SQL Server default constraints
@beberlei beberlei merged commit fe04d1f into doctrine:master Apr 6, 2013
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants