@@ -41,12 +41,17 @@ func TestInsertOnUpdateBeforeImageSQL(t *testing.T) {
41
41
index2 = make (map [string ]types.IndexMeta )
42
42
columnMeta1 []types.ColumnMeta
43
43
columnMeta2 []types.ColumnMeta
44
+ columnMeta3 []types.ColumnMeta
44
45
ColumnNames []string
45
46
)
46
47
columnId := types.ColumnMeta {
47
48
ColumnDef : nil ,
48
49
ColumnName : "id" ,
49
50
}
51
+ columnCapitalId := types.ColumnMeta {
52
+ ColumnDef : nil ,
53
+ ColumnName : "CAPITALIZED_ID" ,
54
+ }
50
55
columnName := types.ColumnMeta {
51
56
ColumnDef : nil ,
52
57
ColumnName : "name" ,
@@ -56,10 +61,12 @@ func TestInsertOnUpdateBeforeImageSQL(t *testing.T) {
56
61
ColumnName : "age" ,
57
62
}
58
63
columns ["id" ] = columnId
64
+ columns ["CAPITALIZED_ID" ] = columnCapitalId
59
65
columns ["name" ] = columnName
60
66
columns ["age" ] = columnAge
61
67
columnMeta1 = append (columnMeta1 , columnId )
62
68
columnMeta2 = append (columnMeta2 , columnName , columnAge )
69
+ columnMeta3 = append (columnMeta3 , columnCapitalId )
63
70
index ["id" ] = types.IndexMeta {
64
71
Name : "PRIMARY" ,
65
72
IType : types .IndexTypePrimaryKey ,
@@ -70,6 +77,11 @@ func TestInsertOnUpdateBeforeImageSQL(t *testing.T) {
70
77
IType : types .IndexUnique ,
71
78
Columns : columnMeta2 ,
72
79
}
80
+ index ["capitalized_id_index" ] = types.IndexMeta {
81
+ Name : "CAPITALIZED_ID_INDEX" ,
82
+ IType : types .IndexUnique ,
83
+ Columns : columnMeta3 ,
84
+ }
73
85
74
86
ColumnNames = []string {"id" , "name" , "age" }
75
87
tableMeta1 = types.TableMeta {
@@ -117,12 +129,34 @@ func TestInsertOnUpdateBeforeImageSQL(t *testing.T) {
117
129
Query : "insert into t_user(id, name, age) values(1,'Jack1',?) on duplicate key update name = 'Michael',age = ?" ,
118
130
MetaDataMap : map [string ]types.TableMeta {"t_user" : tableMeta1 },
119
131
},
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" },
121
144
expectQuery1 : "SELECT * FROM t_user WHERE (id = ? ) OR (name = ? and age = ? ) " ,
122
145
expectQueryArgs1 : []driver.Value {int64 (1 ), "Jack1" , 81 },
123
146
expectQuery2 : "SELECT * FROM t_user WHERE (name = ? and age = ? ) OR (id = ? ) " ,
124
147
expectQueryArgs2 : []driver.Value {"Jack1" , 81 , int64 (1 )},
125
148
},
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
+ },
126
160
// multi insert one index
127
161
{
128
162
execCtx : & types.ExecContext {
0 commit comments