Skip to content

Commit c618ab5

Browse files
authored
Merge branch 'main' into angelamayxie-87bce348
2 parents 2f5a242 + 5203d53 commit c618ab5

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

enginetest/queries/alter_table_queries.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,20 @@ var ModifyColumnScripts = []ScriptTest{
22732273
},
22742274
},
22752275
},
2276+
{
2277+
// https://github.com/dolthub/dolt/issues/9591
2278+
Name: "Add check constraint when modifying column",
2279+
SetUpScript: []string{
2280+
"create table t(pk int primary key)",
2281+
"alter table t modify column pk int check(pk < 10)",
2282+
},
2283+
Assertions: []ScriptTestAssertion{
2284+
{
2285+
Query: "insert into t values (20)",
2286+
ExpectedErr: sql.ErrCheckConstraintViolated,
2287+
},
2288+
},
2289+
},
22762290
{
22772291
Name: "error cases",
22782292
SetUpScript: []string{},

sql/analyzer/validate_create_table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ func ValidateModifyColumn(ctx *sql.Context, initialSch sql.Schema, schema sql.Sc
458458
// It cannot have been renamed in the same statement.
459459
oldColName := mc.Column()
460460
if !schema.Contains(oldColName, tableName) || !initialSch.Contains(oldColName, tableName) {
461-
return nil, sql.ErrTableColumnNotFound.New(table, oldColName)
461+
return nil, sql.ErrTableColumnNotFound.New(tableName, oldColName)
462462
}
463463

464464
newCol := mc.NewColumn()

0 commit comments

Comments
 (0)