Skip to content

Commit 9607c55

Browse files
author
James Cor
committed
Merge branch 'main' into james/group
2 parents 3b155f5 + 2f1daeb commit 9607c55

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

enginetest/queries/script_queries.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8078,6 +8078,27 @@ where
80788078
},
80798079
},
80808080
},
8081+
{
8082+
Name: "ensure that special case does not apply for nullable enums",
8083+
Dialect: "mysql",
8084+
SetUpScript: []string{
8085+
"create table t (i int primary key, e enum('abc', 'def', 'ghi'));",
8086+
},
8087+
Assertions: []ScriptTestAssertion{
8088+
{
8089+
Query: "insert into t(i) values (1)",
8090+
Expected: []sql.Row{
8091+
{types.NewOkResult(1)},
8092+
},
8093+
},
8094+
{
8095+
Query: "select * from t;",
8096+
Expected: []sql.Row{
8097+
{1, nil},
8098+
},
8099+
},
8100+
},
8101+
},
80818102
{
80828103
Name: "not expression optimization",
80838104
Dialect: "mysql",

sql/rowexec/insert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (i *insertIter) Next(ctx *sql.Context) (returnRow sql.Row, returnErr error)
8787
break
8888
}
8989
_, isColDefVal := i.insertExprs[idx].(*sql.ColumnDefaultValue)
90-
if row[idx] == nil && types.IsEnum(col.Type) && isColDefVal {
90+
if row[idx] == nil && !col.Nullable && types.IsEnum(col.Type) && isColDefVal {
9191
row[idx] = 1
9292
}
9393
}

0 commit comments

Comments
 (0)