Skip to content

Commit

Permalink
More complete fix for #291
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Apr 6, 2010
1 parent a8d2fa6 commit c7a604a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/sequel/adapters/shared/mssql.rb
Expand Up @@ -64,9 +64,11 @@ def alter_table_sql(table, op)
"ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(op)}"
when :set_column_null
sch = schema(table).find{|k,v| k.to_s == op[:name].to_s}.last
type = {:type=>sch[:db_type]}
type[:type] += "(#{sch[:max_chars]})" if sch[:max_chars]
"ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(type)} #{'NOT ' unless op[:null]}NULL"
type = sch[:db_type]
if size = sch[:max_chars] || sch[:column_size]
type += "(#{size})"
end
"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
"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
Expand Down

0 comments on commit c7a604a

Please sign in to comment.