Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,12 @@ def column_definitions(table_name)
else
type = case ci[:type]
when /smallint|int|bigint/ then ci[:_type]
when /bit/ then 'smallint'
else ci[:type]
end
value = default.match(/\A\((.*)\)\Z/m)[1]
value = select_value("SELECT CAST(#{value} AS #{type}) AS value", "SCHEMA")

[value, nil]
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/cases/column_test_sqlserver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def assert_obj_set_and_save(attribute, value)
_(col.sql_type).must_equal "bit"
_(col.type).must_equal :boolean
_(col.null).must_equal true
_(col.default).must_equal true
_(col.default).must_equal 1
_(obj.bit).must_equal true
_(col.default_function).must_be_nil
type = connection.lookup_cast_type_from_column(col)
Expand Down