Skip to content

Incorrect ColumnType Nullable default #158

Open
@ChrisPortman

Description

@ChrisPortman

Description

Sqlite coumns that are neither NOT NULL or NULL are nullable by default. However, .Nullable() defaults to false and is only set true if the CREATE TABLE sql explicitly denotes the column as NULL

columnType := migrator.ColumnType{

columnType := migrator.ColumnType{
    <snip>
    NullableValue:     sql.NullBool{Valid: true},    //<--- .Bool implicitly false, i.e. NOT NULL 
    <snip>
}

matchUpper := strings.ToUpper(matches[3])
if strings.Contains(matchUpper, " NOT NULL") {
	columnType.NullableValue = sql.NullBool{Bool: false, Valid: true}
} else if strings.Contains(matchUpper, " NULL") {
	columnType.NullableValue = sql.NullBool{Bool: true, Valid: true}
}
...

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions