-
-
Notifications
You must be signed in to change notification settings - Fork 524
Expand file tree
/
Copy pathMySqlIndexHintTests.cs
More file actions
53 lines (42 loc) · 1.51 KB
/
MySqlIndexHintTests.cs
File metadata and controls
53 lines (42 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using SqlKata.Compilers;
using SqlKata.Tests.Infrastructure;
using Xunit;
namespace SqlKata.Tests.MySql
{
public class MySqlIndexHintTests : TestSupport
{
private readonly MySqlCompiler compiler;
public MySqlIndexHintTests()
{
compiler = Compilers.Get<MySqlCompiler>(EngineCodes.MySql);
}
[Fact]
public void WithNoIndexHint()
{
var query = new Query("Table");
var ctx = new SqlResult { Query = query };
Assert.Equal("FROM `Table`", compiler.CompileFrom(ctx));
}
[Fact]
public void WithIndexHint()
{
var query = new Query("Table", indexHint: "index1");
var ctx = new SqlResult { Query = query };
Assert.Equal("FROM `Table` USE INDEX(index1)", compiler.CompileFrom(ctx));
}
[Fact]
public void JoinWithNoIndexHint()
{
var query = new Query("Table").Join("TableA", "Column1", "ColumnA");
var ctx = new SqlResult { Query = query };
Assert.Equal("\nINNER JOIN `TableA` ON `Column1` = `ColumnA`", compiler.CompileJoins(ctx));
}
[Fact]
public void JoinWithIndexHint()
{
var query = new Query("Table").Join("TableA", "Column1", "ColumnA", indexHint: "index1");
var ctx = new SqlResult { Query = query };
Assert.Equal("\nINNER JOIN `TableA` USE INDEX(index1) ON `Column1` = `ColumnA`", compiler.CompileJoins(ctx));
}
}
}