You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With MSSQL it is not possible to drop or alter a column with an existing constraint.
This constraint has to be removed before the drop or alter takes place.
In 'datadict-mssqlnative.inc.php' AlterColumnSQL is commented out and DropColumnSQL
doesn't care.
The attached patch tries to remedy this with the smallest possible impact.
Fix DropColumnSQL, to allow the drop even with a constraint on that given column.
We drop so any default doesn't matter.
Fix AlterColumnSql, to allow changes if and only if(!) either a 'new' default is
given for an existing default, or there is no existing one at all. So something
like 'ALTER TABLE t ALTER COLUMN c INT NOT NULL' with an existing constraint on c
will still fail. I can't decide, if keep or remove the constraint is implied here.
@obmsch Thanks for your contribution. If you can, it would be more convenient for us if you could provide your patch as a pull request instead of an attachment.
Revised patch attached, with handles altering the column with no 'new' default and
an existing default constraint on that column. The existing constraint is dropped now.
With MSSQL it is not possible to drop or alter a column with an
existing constraint. The constraint has to be removed before the
operation takes place.
In 'datadict-mssqlnative.inc.php' AlterColumnSQL is commented out and
DropColumnSQL doesn't care.
This tries to fix the problem with the smallest possible impact:
- Fix DropColumnSQL(), to allow the drop even with a constraint on that
given column. We drop, so any default doesn't matter.
- Fix AlterColumnSql(), to allow changes if (and only if !) either a
'new' default is given for an existing default, or there is no
existing one at all. So something like
'ALTER TABLE t ALTER COLUMN c INT NOT NULL'
with an existing constraint on c will still fail since it can't be
determined if keeping or removing the constraint is implied here.
Fixes#290 via #297
Changes to original commit:
- split long lines, whitespace
- Added commit message text from issue #290's description
Signed-off-by: Damien Regad <dregad@mantisbt.org>
With MSSQL it is not possible to drop or alter a column with an existing constraint.
This constraint has to be removed before the drop or alter takes place.
In 'datadict-mssqlnative.inc.php' AlterColumnSQL is commented out and DropColumnSQL
doesn't care.
The attached patch tries to remedy this with the smallest possible impact.
Fix DropColumnSQL, to allow the drop even with a constraint on that given column.
We drop so any default doesn't matter.
Fix AlterColumnSql, to allow changes if and only if(!) either a 'new' default is
given for an existing default, or there is no existing one at all. So something
like 'ALTER TABLE t ALTER COLUMN c INT NOT NULL' with an existing constraint on c
will still fail. I can't decide, if keep or remove the constraint is implied here.
datadict-mssqlnative.inc.php.patch.txt
The text was updated successfully, but these errors were encountered: