Skip to content

Commit

Permalink
Don't try to drop a default twice when changing a column's type on Mi…
Browse files Browse the repository at this point in the history
…crosoft SQL Server

This broke when the code to drop a default before changing a default
was added a couple days ago.
  • Loading branch information
jeremyevans committed Sep 12, 2019
1 parent f13e9c2 commit 943350e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/sequel/adapters/shared/mssql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def alter_table_sql(table, op)
end
end
sqls << "ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{column_definition_sql(op)}"
sqls << alter_table_sql(table, op.merge(:op=>:set_column_default, :default=>default)) if default
sqls << alter_table_sql(table, op.merge(:op=>:set_column_default, :default=>default, :skip_drop_default=>true)) if default
sqls
when :set_column_null
sch = schema(table).find{|k,v| k.to_s == op[:name].to_s}.last
Expand All @@ -291,7 +291,7 @@ def alter_table_sql(table, op)
"ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(:type=>type)} #{'NOT ' unless op[:null]}NULL"
when :set_column_default
sqls = []
add_drop_default_constraint_sql(sqls, table, op[:name])
add_drop_default_constraint_sql(sqls, table, op[:name]) unless op[:skip_drop_default]
sqls << "ALTER TABLE #{quote_schema_table(table)} ADD CONSTRAINT #{quote_identifier("sequel_#{table}_#{op[:name]}_def")} DEFAULT #{literal(op[:default])} FOR #{quote_identifier(op[:name])}"
else
super(table, op)
Expand Down

0 comments on commit 943350e

Please sign in to comment.