You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/WP_SQLite_Driver_Translation_Tests.php
+62Lines changed: 62 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1248,6 +1248,68 @@ public function testConcatFunction(): void {
1248
1248
);
1249
1249
}
1250
1250
1251
+
publicfunctiontestIndexHints(): void {
1252
+
// USE INDEX
1253
+
$this->assertQuery(
1254
+
'SELECT * FROM `t`',
1255
+
'SELECT * FROM t USE INDEX (i)'
1256
+
);
1257
+
1258
+
// USE KEY
1259
+
$this->assertQuery(
1260
+
'SELECT * FROM `t`',
1261
+
'SELECT * FROM t USE KEY (k)'
1262
+
);
1263
+
1264
+
// FORCE INDEX
1265
+
$this->assertQuery(
1266
+
'SELECT * FROM `t`',
1267
+
'SELECT * FROM t FORCE INDEX (i)'
1268
+
);
1269
+
1270
+
// FORCE KEY
1271
+
$this->assertQuery(
1272
+
'SELECT * FROM `t`',
1273
+
'SELECT * FROM t FORCE KEY (k)'
1274
+
);
1275
+
1276
+
// IGNORE INDEX
1277
+
$this->assertQuery(
1278
+
'SELECT * FROM `t`',
1279
+
'SELECT * FROM t IGNORE INDEX (i)'
1280
+
);
1281
+
1282
+
// IGNORE KEY
1283
+
$this->assertQuery(
1284
+
'SELECT * FROM `t`',
1285
+
'SELECT * FROM t IGNORE KEY (k)'
1286
+
);
1287
+
1288
+
// FOR JOIN
1289
+
$this->assertQuery(
1290
+
'SELECT * FROM `t` JOIN `j` ON `t`.`id` = `j`.`t_id`',
1291
+
'SELECT * FROM t USE INDEX FOR JOIN (i) JOIN j ON t.id = j.t_id'
1292
+
);
1293
+
1294
+
// FOR ORDER BY
1295
+
$this->assertQuery(
1296
+
'SELECT * FROM `t` ORDER BY `id` DESC',
1297
+
'SELECT * FROM t USE INDEX FOR ORDER BY (i) ORDER BY id DESC'
1298
+
);
1299
+
1300
+
// FOR GROUP BY
1301
+
$this->assertQuery(
1302
+
'SELECT * FROM `t` GROUP BY `id` HAVING `id` = 1',
1303
+
'SELECT * FROM t USE INDEX FOR GROUP BY (i) GROUP BY id HAVING id = 1'
1304
+
);
1305
+
1306
+
// A complex query with multiple hints and conditions.
1307
+
$this->assertQuery(
1308
+
'SELECT * FROM `t` JOIN `j` ON `t`.`id` = `j`.`t_id` WHERE `id` = 1 GROUP BY `id` HAVING `id` = 1 ORDER BY `id` DESC',
1309
+
'SELECT * FROM `t` USE INDEX (i) USE INDEX FOR JOIN (j) USE KEY FOR ORDER BY (o) IGNORE INDEX FOR GROUP BY (g) JOIN j ON t.id = j.t_id WHERE id = 1 GROUP BY id HAVING id = 1 ORDER BY id DESC'
0 commit comments