@@ -41,12 +41,17 @@ func TestInsertOnUpdateBeforeImageSQL(t *testing.T) {
4141 index2 = make (map [string ]types.IndexMeta )
4242 columnMeta1 []types.ColumnMeta
4343 columnMeta2 []types.ColumnMeta
44+ columnMeta3 []types.ColumnMeta
4445 ColumnNames []string
4546 )
4647 columnId := types.ColumnMeta {
4748 ColumnDef : nil ,
4849 ColumnName : "id" ,
4950 }
51+ columnCapitalId := types.ColumnMeta {
52+ ColumnDef : nil ,
53+ ColumnName : "CAPITALIZED_ID" ,
54+ }
5055 columnName := types.ColumnMeta {
5156 ColumnDef : nil ,
5257 ColumnName : "name" ,
@@ -56,10 +61,12 @@ func TestInsertOnUpdateBeforeImageSQL(t *testing.T) {
5661 ColumnName : "age" ,
5762 }
5863 columns ["id" ] = columnId
64+ columns ["CAPITALIZED_ID" ] = columnCapitalId
5965 columns ["name" ] = columnName
6066 columns ["age" ] = columnAge
6167 columnMeta1 = append (columnMeta1 , columnId )
6268 columnMeta2 = append (columnMeta2 , columnName , columnAge )
69+ columnMeta3 = append (columnMeta3 , columnCapitalId )
6370 index ["id" ] = types.IndexMeta {
6471 Name : "PRIMARY" ,
6572 IType : types .IndexTypePrimaryKey ,
@@ -70,6 +77,11 @@ func TestInsertOnUpdateBeforeImageSQL(t *testing.T) {
7077 IType : types .IndexUnique ,
7178 Columns : columnMeta2 ,
7279 }
80+ index ["capitalized_id_index" ] = types.IndexMeta {
81+ Name : "CAPITALIZED_ID_INDEX" ,
82+ IType : types .IndexUnique ,
83+ Columns : columnMeta3 ,
84+ }
7385
7486 ColumnNames = []string {"id" , "name" , "age" }
7587 tableMeta1 = types.TableMeta {
@@ -117,12 +129,34 @@ func TestInsertOnUpdateBeforeImageSQL(t *testing.T) {
117129 Query : "insert into t_user(id, name, age) values(1,'Jack1',?) on duplicate key update name = 'Michael',age = ?" ,
118130 MetaDataMap : map [string ]types.TableMeta {"t_user" : tableMeta1 },
119131 },
120- sourceQueryArgs : []driver.Value {81 , "Link" , 18 },
132+ sourceQueryArgs : []driver.Value {81 , "Link" },
133+ expectQuery1 : "SELECT * FROM t_user WHERE (id = ? ) OR (name = ? and age = ? ) " ,
134+ expectQueryArgs1 : []driver.Value {int64 (1 ), "Jack1" , 81 },
135+ expectQuery2 : "SELECT * FROM t_user WHERE (name = ? and age = ? ) OR (id = ? ) " ,
136+ expectQueryArgs2 : []driver.Value {"Jack1" , 81 , int64 (1 )},
137+ },
138+ {
139+ execCtx : & types.ExecContext {
140+ Query : "insert into t_user(ID, name, age) values(1,'Jack1',?) on duplicate key update name = 'Michael',age = ?" ,
141+ MetaDataMap : map [string ]types.TableMeta {"t_user" : tableMeta1 },
142+ },
143+ sourceQueryArgs : []driver.Value {81 , "Link" },
121144 expectQuery1 : "SELECT * FROM t_user WHERE (id = ? ) OR (name = ? and age = ? ) " ,
122145 expectQueryArgs1 : []driver.Value {int64 (1 ), "Jack1" , 81 },
123146 expectQuery2 : "SELECT * FROM t_user WHERE (name = ? and age = ? ) OR (id = ? ) " ,
124147 expectQueryArgs2 : []driver.Value {"Jack1" , 81 , int64 (1 )},
125148 },
149+ {
150+ execCtx : & types.ExecContext {
151+ Query : "insert into t_user(ID, capitalized_id) values(1, 11) on duplicate key update name = 'Michael',age = ?" ,
152+ MetaDataMap : map [string ]types.TableMeta {"t_user" : tableMeta1 },
153+ },
154+ sourceQueryArgs : []driver.Value {"Jack1" },
155+ expectQuery1 : "SELECT * FROM t_user WHERE (id = ? ) OR (CAPITALIZED_ID = ? ) " ,
156+ expectQueryArgs1 : []driver.Value {int64 (1 ), int64 (11 )},
157+ expectQuery2 : "SELECT * FROM t_user WHERE (CAPITALIZED_ID = ? ) OR (id = ? ) " ,
158+ expectQueryArgs2 : []driver.Value {int64 (11 ), int64 (1 )},
159+ },
126160 // multi insert one index
127161 {
128162 execCtx : & types.ExecContext {
0 commit comments