activerecord-sqlserver-adapter icon indicating copy to clipboard operation
activerecord-sqlserver-adapter copied to clipboard

change_column_default cannot drop default constraint

Open nemesit opened this issue 2 years ago • 0 comments

Issue

change_column_default and similar methods not working as intended

Expected behavior

according to the documentation change_column_default(:users, :email, nil)

change_column_default("SomeTable", "SomeColumn", nil)

should drop the default constraint on SomeColumn.

Actual behavior

ALTER TABLE [SomeTable] ADD CONSTRAINT DF_SomeTable_SomeColumn DEFAULT NULL FOR [SomeColumn]

gets executed which results in a (Null) default constraint.

How to reproduce

use change_column_default("SomeTable", "SomeColumn", nil)

Details

  • Rails version: 7.0.1
  • SQL Server adapter version: 7.0.0.0
  • TinyTDS version: 2.1.5

nemesit avatar Jul 20 '22 11:07 nemesit