Skip to content

Commit

Permalink
fix unit test TestPTOSC
Browse files Browse the repository at this point in the history
  • Loading branch information
LordofAvernus committed Jan 24, 2025
1 parent cd510cb commit a30e8b1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sqle/driver/mysql/pt_osc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestPTOSC(t *testing.T) {
plocale.Bundle.LocalizeMsgByLang(language.Chinese, plocale.PTOSCAvoidNoDefaultValueOnNotNullColumn))

runOSCCase(t, "not pk and unique key",
"alter table exist_tb_3 add column v3 varchar(255);",
"alter table exist_tb_13 add column v4 varchar(255);",
plocale.Bundle.LocalizeMsgByLang(language.Chinese, plocale.PTOSCNoUniqueIndexOrPrimaryKey))

runOSCCase(t, "rename table",
Expand Down
27 changes: 27 additions & 0 deletions sqle/driver/mysql/session/mock_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ func NewMockContext(e *executor.Executor) *Context {
Size: 1,
OriginalTable: getTestCreateTableStmt12(),
},
"exist_tb_13": {
sizeLoad: true,
isLoad: true,
Size: 1,
OriginalTable: getTestCreateTableStmt13(),
},
},
},
"myisam_utf8_db": {
Expand Down Expand Up @@ -286,6 +292,12 @@ func NewMockContextForTestTableSize(e *executor.Executor, tableSize map[string]
Size: float64(tableSize["exist_tb_12"]),
OriginalTable: getTestCreateTableStmt12(),
},
"exist_tb_13": {
sizeLoad: true,
isLoad: true,
Size: float64(tableSize["exist_tb_13"]),
OriginalTable: getTestCreateTableStmt13(),
},
},
},
"myisam_utf8_db": {
Expand Down Expand Up @@ -550,6 +562,21 @@ PRIMARY KEY (id) USING BTREE
stmt, _ := node.(*ast.CreateTableStmt)
return stmt
}
func getTestCreateTableStmt13() *ast.CreateTableStmt {
baseCreateQuery := `
CREATE TABLE exist_db.exist_tb_13 (
id bigint(10) unsigned NOT NULL AUTO_INCREMENT COMMENT "unit test",
v1 blob,
v2 int
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT="unit test";
`
node, err := util.ParseOneSql(baseCreateQuery)
if err != nil {
panic(err)
}
stmt, _ := node.(*ast.CreateTableStmt)
return stmt
}

type AIMockContext struct {
createContextSqls []string
Expand Down

0 comments on commit a30e8b1

Please sign in to comment.