Skip to content

Commit

Permalink
Merge pull request #1005 from dolthub/fulghum/dolt-3388
Browse files Browse the repository at this point in the history
Allowing "DEFAULT NULL" for blob column definitions
  • Loading branch information
fulghum authored May 11, 2022
2 parents 35526b9 + 739663c commit ddabb4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions enginetest/enginetests.go
Original file line number Diff line number Diff line change
Expand Up @@ -2653,6 +2653,15 @@ func TestCreateTable(t *testing.T, harness Harness) {
_, _, err = e.Query(ctx, "CREATE TABLE unsupported_charset (pk int NOT NULL, col1 blob DEFAULT (_latin1'abc'))")
require.Error(t, err)
})

t.Run("create table with blob column with null default", func(t *testing.T) {
TestQuery(t, harness, e, "CREATE TABLE t_blob_default_null(c BLOB DEFAULT NULL)",
[]sql.Row{{sql.NewOkResult(0)}}, nil)

RunQuery(t, e, harness, "INSERT INTO t_blob_default_null VALUES ()")
TestQuery(t, harness, e, "SELECT * FROM t_blob_default_null",
[]sql.Row{{nil}}, nil)
})
}

func TestDropTable(t *testing.T, harness Harness) {
Expand Down
2 changes: 1 addition & 1 deletion sql/analyzer/resolve_column_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ func resolveColumnDefaultsOnWrapper(ctx *sql.Context, col *sql.Column, e *expres
return e, transform.SameTree, nil
}

if sql.IsTextBlob(col.Type) && newDefault.IsLiteral() {
if sql.IsTextBlob(col.Type) && newDefault.IsLiteral() && newDefault.Type() != sql.Null {
return nil, transform.SameTree, sql.ErrInvalidTextBlobColumnDefault.New()
}

Expand Down

0 comments on commit ddabb4a

Please sign in to comment.