-
-
Notifications
You must be signed in to change notification settings - Fork 512
/
Copy pathWhereTests.cs
33 lines (27 loc) · 1.04 KB
/
WhereTests.cs
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
using SqlKata.Compilers;
using SqlKata.Tests.Infrastructure;
using Xunit;
namespace SqlKata.Tests
{
public class WhereTests : TestSupport
{
[Fact]
public void GroupedWhereFilters()
{
var q = new Query("Table1")
.Where(q => q.Or().Where("Column1", 10).Or().Where("Column2", 20))
.Where("Column3", 30);
var c = Compile(q);
Assert.Equal(@"SELECT * FROM ""Table1"" WHERE (""Column1"" = 10 OR ""Column2"" = 20) AND ""Column3"" = 30", c[EngineCodes.PostgreSql]);
}
[Fact]
public void GroupedHavingFilters()
{
var q = new Query("Table1")
.Having(q => q.Or().HavingRaw("SUM([Column1]) = ?", 10).Or().HavingRaw("SUM([Column2]) = ?", 20))
.HavingRaw("SUM([Column3]) = ?", 30);
var c = Compile(q);
Assert.Equal(@"SELECT * FROM ""Table1"" HAVING (SUM(""Column1"") = 10 OR SUM(""Column2"") = 20) AND SUM(""Column3"") = 30", c[EngineCodes.PostgreSql]);
}
}
}