Skip to content

Commit e1ee4f9

Browse files
elianddbclaude
andcommitted
Improve charset validation test to focus on customer scenario
Replace overly complex customer scenario simulation with a focused test that directly addresses the customer's issue from #8893: - Test inserting latin1-encoded "DoltLab®" into utf8mb4 column - Verify error shows column name (not "<unknown>") - Demonstrate non-strict mode migration solution - Confirm data truncation and queryability The test is now concise (5 assertions vs 12) and specifically validates the customer's problem and our fix. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent d955523 commit e1ee4f9

File tree

1 file changed

+13
-50
lines changed

1 file changed

+13
-50
lines changed

enginetest/queries/script_queries.go

Lines changed: 13 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7301,77 +7301,40 @@ where
73017301
},
73027302
},
73037303
{
7304-
Name: "charset validation customer scenario simulation",
7304+
Name: "charset validation issue #8893 - customer scenario",
73057305
SetUpScript: []string{
73067306
"create table products (id int primary key, name text character set utf8mb4);",
73077307
},
73087308
Assertions: []ScriptTestAssertion{
7309+
// Customer's problem: inserting latin1-encoded "DoltLab®" into utf8mb4 column
7310+
// Before fix: error showed "<unknown>" instead of column name
73097311
{
7310-
Query: "set sql_mode = '';",
7311-
Expected: []sql.Row{{types.OkResult{RowsAffected: 0}}},
7312-
},
7313-
{
7314-
Query: "insert into products values (1, UNHEX('446F6C744C6162AE'));",
7315-
Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}},
7312+
Query: "insert into products values (1, UNHEX('446F6C744C6162AE'));", // "DoltLab®" as latin1 bytes
7313+
ExpectedErrStr: "Incorrect string value: '\\xAE' for column 'name' at row 1",
73167314
},
7315+
// Customer's solution: use non-strict mode to clean up data
73177316
{
7318-
Query: "insert into products values (2, UNHEX('4D7953514CAE'));",
7319-
Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}},
7317+
Query: "set sql_mode = '';",
7318+
Expected: []sql.Row{{types.OkResult{RowsAffected: 0}}},
73207319
},
73217320
{
7322-
Query: "insert into products values (3, UNHEX('43C3A9666561AE'));",
7321+
Query: "insert into products values (1, UNHEX('446F6C744C6162AE'));", // Now succeeds with truncation
73237322
Expected: []sql.Row{{types.OkResult{RowsAffected: 1}}},
73247323
},
7324+
// Verify data was truncated at invalid byte (MySQL behavior)
73257325
{
7326-
Query: "select id, name, HEX(name), LENGTH(name) from products order by id;",
7327-
Expected: []sql.Row{
7328-
{1, "DoltLab", "446F6C744C6162", 7},
7329-
{2, "MySQL", "4D7953514C", 5},
7330-
{3, "Céfea", "43C3A9666561", 6},
7331-
},
7332-
},
7333-
{
7334-
Query: "select 'Data cleanup successful - all rows queryable:';",
7326+
Query: "select id, name, HEX(name) from products;",
73357327
Expected: []sql.Row{
7336-
{"Data cleanup successful - all rows queryable:"},
7328+
{1, "DoltLab", "446F6C744C6162"}, // Invalid byte 0xAE was truncated
73377329
},
73387330
},
7331+
// Customer can now query and work with the data
73397332
{
73407333
Query: "select id, name from products where name like '%Lab%';",
73417334
Expected: []sql.Row{
73427335
{1, "DoltLab"},
73437336
},
73447337
},
7345-
{
7346-
Query: "select id, name from products where name like '%SQL%';",
7347-
Expected: []sql.Row{
7348-
{2, "MySQL"},
7349-
},
7350-
},
7351-
{
7352-
Query: "select id, CONCAT(name, ' - cleaned') as cleaned_name from products;",
7353-
Expected: []sql.Row{
7354-
{1, "DoltLab - cleaned"},
7355-
{2, "MySQL - cleaned"},
7356-
{3, "Céfea - cleaned"},
7357-
},
7358-
},
7359-
{
7360-
Query: "select 'Customer migration pattern:';",
7361-
Expected: []sql.Row{
7362-
{"Customer migration pattern:"},
7363-
},
7364-
},
7365-
{
7366-
Query: "create table products_clean as select * from products;",
7367-
Expected: []sql.Row{{types.OkResult{RowsAffected: 3}}},
7368-
},
7369-
{
7370-
Query: "select count(*) as migrated_rows from products_clean;",
7371-
Expected: []sql.Row{
7372-
{3},
7373-
},
7374-
},
73757338
},
73767339
},
73777340
{

0 commit comments

Comments
 (0)