Closed pdufour closed 7 months ago
Hey @pdufour, thanks for reporting this issue!
I was able to reproduce the bug, and can confirm that the presence of the PRIMARY KEY
definition (specifically the order) is messing with how we validate the column type length restrictions. Interestingly, this doesn't seem to be an issue in dolt.
This is a ScriptTest repro for whoever is going to tackle this issue:
var scripts = []queries.ScriptTest{
{
Name: "tmp script test",
SetUpScript: []string{
"create table t (a varchar(5), b varchar(100), primary key(b, a));",
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "insert into t (b, a) values ('123456', '')",
Expected: []sql.Row{
},
},
{
Query: "select a, b from t",
Expected: []sql.Row{
},
},
},
},
}
We will get started on the fix ASAP.
The order of keys in the primary key line seem to be messing with the order columns are inserted.
For example:
Table structure:
Insert:
This gives the error:
Swap the column order back in the primary key line:
Doesn't throw an error.
While you would expect column keys specified in the PK to be in the same column order as the original table, this is not a requirement of mysql.
Complete reproducible example: