Skip to content

Commit

Permalink
[no-release-notes] tighten up enum behavior (#2755)
Browse files Browse the repository at this point in the history
* [no-release-notes] tighten up enum behavior

* delete comment
  • Loading branch information
max-hoffman authored Nov 20, 2024
1 parent efb1484 commit 956c37d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
4 changes: 2 additions & 2 deletions enginetest/queries/script_queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ var ScriptTests = []ScriptTest{
},
{
Query: "alter table xy modify y enum('a')",
ExpectedErr: sql.ErrEnumTypeTruncated,
ExpectedErr: types.ErrConvertingToEnum,
},
},
},
Expand Down Expand Up @@ -7511,7 +7511,7 @@ where
},
{
Query: "alter table t modify column e enum('abc');",
ExpectedErr: sql.ErrEnumTypeTruncated,
ExpectedErr: types.ErrConvertingToEnum,
},
},
},
Expand Down
9 changes: 0 additions & 9 deletions sql/analyzer/validate_create_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,15 +470,6 @@ func validateModifyColumn(ctx *sql.Context, initialSch sql.Schema, schema sql.Sc
return nil, err
}

if e1, ok := newCol.Type.(sql.EnumType); ok {
oldCol := initialSch[initialSch.IndexOfColName(oldColName)]
if e2, ok := oldCol.Type.(sql.EnumType); ok {
if len(e1.Values()) < len(e2.Values()) {
return nil, sql.ErrEnumTypeTruncated.New()
}
}
}

// TODO: When a column is being modified, we should ideally check that any existing table check constraints
// are still valid (e.g. if the column type changed) and throw an error if they are invalidated.
// That would be consistent with MySQL behavior.
Expand Down

0 comments on commit 956c37d

Please sign in to comment.