Skip to content

specifying column Nullable() does not emit "NULL" to column creation DDL #767

Description

@pharapiak

ColumnBase.FormatNullable has the following:

if (column.IsNullable.HasValue && column.IsNullable.Value) {
				return string.Empty;
}

This might seem to be a reasonable default, but if the type of the column is a SQL Server user defined type with a default of NOT NULL, the net result is that the column gets created with NOT NULL, since the emitted DDL doesn't specify it.

For example, we make heavy use of this custom type:
exec sp_addtype instanceid, 'bigint', 'NOT NULL'

If I then do

          Create.Table("filecartItem")
//more columns
                .WithColumn("fileattachment_id").AsCustom("instanceid").Nullable();

the DDL will look like:

CREATE TABLE [dbo].[filecartitem] (
//other columns
[fileattachment_id] instanceid
 ))

and the resulting filecart_id column will end up with the default "NOT NULL" 'inherited' for type instanceid.

I think the code should omit the NULL / NOT NULL only if the migrator did not specify it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions