Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Approval tests #687

Closed
wants to merge 229 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
229 commits
Select commit Hold shift + click to select a range
6e72217
fix tests
marhoily Aug 26, 2023
271c84b
Update nuget
marhoily Aug 26, 2023
4600fb3
let resharper cleanup code
marhoily Aug 26, 2023
7bde307
Introduce end-of-line normalization
marhoily Aug 26, 2023
1aed12d
address resharper warnings
marhoily Aug 26, 2023
bae7c5b
again
marhoily Aug 26, 2023
cdff3f5
no more warnings
marhoily Aug 26, 2023
d3907dd
initial refactoring
marhoily Aug 26, 2023
eef4b4d
fix bug
marhoily Aug 26, 2023
2df72b2
another bug
marhoily Aug 26, 2023
4ddf03f
refactor test
marhoily Aug 26, 2023
a019303
reformat test
marhoily Aug 26, 2023
f9badc1
fix some tests
marhoily Aug 26, 2023
44ad34f
fix test
marhoily Aug 26, 2023
31d95cf
all tests pass
marhoily Aug 26, 2023
3f5d17f
fix warnings
marhoily Aug 26, 2023
c628372
refactor
marhoily Aug 26, 2023
894b4c7
Introducing nullability
marhoily Aug 27, 2023
7ae296d
AbstractClause: made Engine and Component required
marhoily Aug 27, 2023
1aec9ed
fighting nullability warnings
marhoily Aug 27, 2023
06e0944
fighting null-checker
marhoily Aug 27, 2023
8e5ee6d
refactor CteFinder
marhoily Aug 27, 2023
4c7bdc2
fighting null-checker
marhoily Aug 27, 2023
d84a7b8
+ AsArray
marhoily Aug 27, 2023
15b9735
+ AsArray
marhoily Aug 27, 2023
893708d
fight null-checker
marhoily Aug 27, 2023
496339a
fighting null-checker -23
marhoily Aug 27, 2023
467be7c
refactor
marhoily Aug 27, 2023
6a651a6
fighting null-checker -20
marhoily Aug 27, 2023
a1e878b
refactor
marhoily Aug 27, 2023
1101fb3
refactor
marhoily Aug 27, 2023
f5fbbd2
Extract CompilationExtensions
marhoily Aug 27, 2023
3544ea5
refactor CompilationExtensions
marhoily Aug 27, 2023
5ef4f29
refactor
marhoily Aug 27, 2023
d7872b9
comment
marhoily Aug 27, 2023
0e182d0
refactor
marhoily Aug 27, 2023
23072db
refactor
marhoily Aug 27, 2023
bc82c39
refactor
marhoily Aug 27, 2023
ef41b62
refactor
marhoily Aug 27, 2023
62ccbf7
reorganize files
marhoily Aug 27, 2023
f71c4e3
refactor
marhoily Aug 27, 2023
d87ec02
refactor
marhoily Aug 27, 2023
caad4a7
refactor
marhoily Aug 27, 2023
bdbf297
refactor escape character string? -> char?
marhoily Aug 27, 2023
b5e16a6
refactor
marhoily Aug 28, 2023
a49b104
introduce XService
marhoily Aug 28, 2023
223546e
Move GetInsertColumnsList to clause
marhoily Aug 28, 2023
6628915
Introduce Q and implement Render
marhoily Aug 28, 2023
4a807fc
introduce BindingMode
marhoily Aug 28, 2023
d6447fa
Introduce QueryBuilder
marhoily Aug 28, 2023
c3ef425
Compare all engines
marhoily Aug 28, 2023
773e5c2
One more case in insert
marhoily Aug 28, 2023
e55f884
compare exceptions
marhoily Aug 28, 2023
2cc8487
first select passes
marhoily Aug 28, 2023
757e481
more select conditions
marhoily Aug 28, 2023
4e7a8dd
refactor
marhoily Aug 28, 2023
8df56ac
+ BooleanCondition
marhoily Aug 28, 2023
3c9f7f0
+ WhereFalse
marhoily Aug 28, 2023
42abd8e
more tests
marhoily Aug 28, 2023
5e8f870
Fix not inconsistencies
marhoily Aug 28, 2023
a073b01
COUNT(*) works
marhoily Aug 28, 2023
24dac64
DISTINCT
marhoily Aug 28, 2023
7bc3b1a
refactor
marhoily Aug 28, 2023
3c14c4d
refactor
marhoily Aug 28, 2023
686ac49
Split QValueInsert
marhoily Aug 28, 2023
427dfb8
refactor
marhoily Aug 28, 2023
8c7e5c7
refactored CompileValueInsert
marhoily Aug 28, 2023
ff6518f
refactor
marhoily Aug 28, 2023
e8b826a
Handle RawCondition
marhoily Aug 28, 2023
d61fdb7
CompileUnion
marhoily Aug 28, 2023
b7b0f54
RawUnionWithBindings
marhoily Aug 28, 2023
c1bdaaf
Compile limits
marhoily Aug 29, 2023
0dfe39a
uncomment test
marhoily Aug 29, 2023
cebb9d4
refactor: removed ConditionsCompilerProvider
marhoily Aug 29, 2023
937a958
refactor 1-st stage: replace RawSql with StringBuilder
marhoily Aug 29, 2023
ba63295
refactor push sb.ReplaceRaw() down to 8
marhoily Aug 29, 2023
f78a66b
+comment
marhoily Aug 29, 2023
57f210e
refactor CompileColumns
marhoily Aug 29, 2023
30b11b1
CompileColumn(..., + writer, ..)
marhoily Aug 29, 2023
58dd474
refactor CompileFrom
marhoily Aug 29, 2023
9b646a1
add useless writer in many places
marhoily Aug 29, 2023
140807b
CompileTableExpression uses Writer
marhoily Aug 29, 2023
6d4af40
CompileJoin
marhoily Aug 29, 2023
7c2c6f9
CompileTableExpression
marhoily Aug 29, 2023
64018ae
CompileJoins
marhoily Aug 29, 2023
533fba4
CompileHaving
marhoily Aug 29, 2023
32295d2
Fix fucking 20 tests :(
marhoily Aug 29, 2023
a8b1755
CompileLimit
marhoily Aug 29, 2023
948aadc
Done using writer in CompileSelectQuery()!
marhoily Aug 29, 2023
6c9037d
refactor: cleanup a bit
marhoily Aug 29, 2023
facfe28
CompileCteQuery
marhoily Aug 29, 2023
91dd1f6
+ test
marhoily Aug 29, 2023
37e489c
CompileCte
marhoily Aug 29, 2023
e2dbdd1
refactor CompileTableExpression
marhoily Aug 29, 2023
9e660f7
Added writer to all CompileCondition
marhoily Aug 29, 2023
8b08444
Fix base conditions
marhoily Aug 29, 2023
acb358c
Done with overriden conditions
marhoily Aug 29, 2023
d6311d5
CompileNestedCondition
marhoily Aug 29, 2023
02922b8
CompileConditions
marhoily Aug 29, 2023
9163b63
string -> void on conditions
marhoily Aug 29, 2023
2c460bc
+ WhereDate_When_Unknown_DatePart
marhoily Aug 29, 2023
acaafff
CompileCondition
marhoily Aug 29, 2023
9dfdfb0
CompileConditions
marhoily Aug 29, 2023
d7fd909
+ Writer.BindMany
marhoily Aug 30, 2023
36a0b6e
Pass writer everywhere
marhoily Aug 30, 2023
fdb9f0e
writer.SetCtx(ctx);
marhoily Aug 30, 2023
26df273
Bind context
marhoily Aug 30, 2023
4528de0
Sql result -> readonly Bindings
marhoily Aug 30, 2023
ca94ffd
Parametrize(..., +writer, ...)
marhoily Aug 30, 2023
d8b75b6
warnings
marhoily Aug 30, 2023
26890a5
more asserts
marhoily Aug 30, 2023
f3690f1
Wrap writer.S
marhoily Aug 30, 2023
ca5a778
Simplify CompileAggregatedColumn
marhoily Aug 30, 2023
7502f34
refactor CompileAggregatedColumn
marhoily Aug 30, 2023
7be928f
remove some writer.Sub() calls
marhoily Aug 30, 2023
3182586
refactor CompileTableExpression
marhoily Aug 30, 2023
21b6e19
remove sub
marhoily Aug 30, 2023
5f04a45
+= writer.Pop
marhoily Aug 30, 2023
b8706bf
refactor SqlServerCompiler.CompileSelectQuery
marhoily Aug 30, 2023
e36a455
write binding to writer
marhoily Aug 30, 2023
ebbba2c
CompileSelectQueryInner
marhoily Aug 30, 2023
d66fe2e
CompileInsertQueryInner
marhoily Aug 30, 2023
15e4c72
CompileUpdateQuery
marhoily Aug 30, 2023
3b88307
CompileDeleteQuery
marhoily Aug 30, 2023
18c23f8
refactor CompileRaw
marhoily Aug 30, 2023
fe7f637
no warnings!
marhoily Aug 30, 2023
7b38f57
minor refactoring
marhoily Aug 30, 2023
d811668
cleanup
marhoily Aug 30, 2023
e37e70c
using writer in update
marhoily Aug 30, 2023
53e9c17
CompileIncrement
marhoily Aug 30, 2023
2116d98
writer in CompileUpdate
marhoily Aug 30, 2023
5e5d0df
CompileIncrement
marhoily Aug 30, 2023
c94e03a
CompileUpdate
marhoily Aug 30, 2023
9b05544
CompileUpdateQuery
marhoily Aug 30, 2023
e10d159
CompileValueInsertClauses
marhoily Aug 30, 2023
db3ead0
CompileValueInsertClauses
marhoily Aug 30, 2023
efef483
prepare to CompileRemainingInsertClauses
marhoily Aug 30, 2023
f71a7af
CompileRemainingInsertClauses
marhoily Aug 30, 2023
cb1b26c
oracle
marhoily Aug 30, 2023
d015139
FirebirdCompiler.CompileInsertQuery
marhoily Aug 30, 2023
e8a6651
don't writer.sub() in insert
marhoily Aug 30, 2023
24589bc
CompileInsertQueryClause
marhoily Aug 30, 2023
10c4775
CompileInsertQuery
marhoily Aug 30, 2023
f5331b0
WriteTable
marhoily Aug 30, 2023
63f414b
cleanup
marhoily Aug 30, 2023
883e6f9
move WriteTable
marhoily Aug 30, 2023
2312a4c
refactor CompileDeleteQuery
marhoily Aug 30, 2023
a699e74
Alias?
marhoily Aug 30, 2023
71eb2eb
refactor CompileDeleteQuery
marhoily Aug 30, 2023
988c90d
No sub() in CompileDeleteQuery!
marhoily Aug 30, 2023
b121460
No subs in CompileUnion!
marhoily Aug 30, 2023
84d0dd1
cleanup
marhoily Aug 30, 2023
1df747c
refactor CompileColumns
marhoily Aug 30, 2023
130e6d0
- sub in firebird
marhoily Aug 30, 2023
f2c82a5
no sub in SqlServerCompiler
marhoily Aug 30, 2023
5d844a5
No sub in CompileCte()
marhoily Aug 30, 2023
991a76d
When writer.Assert is disabled, all tests pass!
marhoily Aug 30, 2023
01b8765
more asserts
marhoily Aug 30, 2023
7cdf65a
36 tests fail
marhoily Aug 30, 2023
cf8a5be
35
marhoily Aug 30, 2023
9b0a86e
34
marhoily Aug 30, 2023
761c493
29
marhoily Aug 30, 2023
0baf47f
19
marhoily Aug 30, 2023
51591d8
11
marhoily Aug 30, 2023
6a6aaf6
4
marhoily Aug 30, 2023
ab71871
0
marhoily Aug 30, 2023
0308c86
refactor
marhoily Aug 30, 2023
1a7b742
+ cover test for compile multiple
marhoily Aug 30, 2023
825466a
refactor "compile many"
marhoily Aug 31, 2023
70fdb2f
remove extra bindings from writer
marhoily Aug 31, 2023
fe5c6a5
refactor
marhoily Aug 31, 2023
5e3b4e5
refactor WriteInsertColumnsList
marhoily Aug 31, 2023
a9e3e3c
refactor CompileAdHocQuery
marhoily Aug 31, 2023
d4adb65
use AppendRaw()
marhoily Aug 31, 2023
ce333f6
Writer.BindOne check AsArray
marhoily Aug 31, 2023
780963a
retiering BindOne()
marhoily Aug 31, 2023
20dbe55
Retiring old Parameter()
marhoily Aug 31, 2023
4be2168
CompileBasicDateCondition
marhoily Aug 31, 2023
09d8e26
OracleLegacyLimitTests
marhoily Aug 31, 2023
08ed8d6
rewrite ApplyLegacyLimit
marhoily Aug 31, 2023
35ebcdc
simplify BindingsAddRange
marhoily Aug 31, 2023
4c8e4bd
Check SqlRaw with Writer
marhoily Aug 31, 2023
6758b59
retiring SqlResult parts
marhoily Aug 31, 2023
98a9f2e
removing the scaffolding
marhoily Aug 31, 2023
3a892f3
remove HELPER functions in WRITER
marhoily Aug 31, 2023
1f6e30f
removing SqlResult as args
marhoily Aug 31, 2023
6dcce73
refactor ModifyQuery
marhoily Aug 31, 2023
6def739
fixings bugs
marhoily Aug 31, 2023
4057670
fix bugs
marhoily Aug 31, 2023
8b786d9
Remove Q and its tests
marhoily Aug 31, 2023
6749607
cleanup
marhoily Aug 31, 2023
3b80db8
get rid of direct Compiler.Parameter calls
marhoily Aug 31, 2023
91ba5b6
Get rid of it
marhoily Aug 31, 2023
1fa1f5f
Add diagnostics to detect wrong bindings
marhoily Aug 31, 2023
0f8439a
Fix binding
marhoily Aug 31, 2023
e45dd01
No more failing tests
marhoily Aug 31, 2023
2d00884
getting rid of direct XService method calls
marhoily Aug 31, 2023
78f6f2e
refactor
marhoily Aug 31, 2023
fbd6f21
refactor
marhoily Aug 31, 2023
e0d684d
refactor
marhoily Aug 31, 2023
67cd3e2
refactor CompileCteQuery
marhoily Aug 31, 2023
0b06851
CompileCteQuery
marhoily Aug 31, 2023
0768205
refactor
marhoily Aug 31, 2023
cc72237
refactor
marhoily Aug 31, 2023
8566cbb
refactor writer, x
marhoily Aug 31, 2023
4da970a
refactor
marhoily Aug 31, 2023
a39405c
verify
marhoily Aug 31, 2023
5cfd443
First real test
marhoily Sep 1, 2023
4f5206a
refactor
marhoily Sep 1, 2023
0f716c1
CompileColumnList tests
marhoily Sep 1, 2023
fb989f9
more tests
marhoily Sep 1, 2023
da0dda7
Change scrubber
marhoily Sep 1, 2023
61fa2f8
more cases
marhoily Sep 1, 2023
bf29f6f
more test cases
marhoily Sep 1, 2023
bfadb5e
refactor
marhoily Sep 1, 2023
06c6f5e
more test cases
marhoily Sep 1, 2023
4068fa1
more test cases
marhoily Sep 1, 2023
9a5a5cb
+ D
marhoily Sep 1, 2023
9bf0995
manual merge
marhoily Sep 2, 2023
4a7cda0
manual merge
marhoily Sep 2, 2023
176df18
Merge branch 'approval-tests' of https://github.com/marhoily/QueryBui…
marhoily Sep 2, 2023
2394303
more test caces
marhoily Sep 2, 2023
5bb83fd
refactor
marhoily Sep 2, 2023
0a045dc
more test cases
marhoily Sep 2, 2023
2206dd7
more test cases
marhoily Sep 2, 2023
79317d8
more test cases
marhoily Sep 2, 2023
d955817
manual merge
marhoily Sep 2, 2023
1b094c9
fixing code to match the old master
marhoily Sep 2, 2023
d7cadc1
all tests pass on the master
marhoily Sep 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
67 changes: 65 additions & 2 deletions .editorconfig
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ root = true

[*]
charset = utf-8
end_of_line = lf
end_of_line = crlf
# Note: the trim_trailing_whitespace option is br0ken in visualstudio, it
# simply does not follow the EditorConfig specification. Therefor you are
# strongly encouraged to not rely on this setting alone, but please install
Expand All @@ -16,13 +16,76 @@ end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab
indent_size = 2
indent_size = 4


[*.cs] # To match existing style
indent_style = space
indent_size = 4
csharp_indent_labels = no_change
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_space_around_binary_operators = before_and_after


[*.yml]
indent_style = space

[*.{cs,vb}]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,4 @@ __pycache__/

# Thumbs
Thumbs.db
*.received.*
67 changes: 10 additions & 57 deletions Program/Program.cs
Original file line number Diff line number Diff line change
@@ -1,59 +1,28 @@
using System;
using System.Collections.Generic;
using SqlKata;
using SqlKata.Compilers;
using SqlKata.Execution;
using System.Data.SqlClient;
using System.Threading.Tasks;
using System.Linq;
using Newtonsoft.Json;
using Npgsql;
using System.Data;
using Dapper;
using System.Data.SQLite;
using static SqlKata.Expressions;
using System.IO;

namespace Program
{
class Program
{
private class Loan

static void Main()
{
public string Id { get; set; }
public string Name { get; set; }
public List<Installment> Installments { get; set; } = new List<Installment>();
}

private class Installment
{
public string Id { get; set; }
public string LoanId { get; set; }
public int DaysCount { get; set; }
}

static void Main(string[] args)
{
using (var db = SqlLiteQueryFactory())
{
var query = db.Query("accounts")
.Where("balance", ">", 0)
.GroupBy("balance")
using var db = SqlLiteQueryFactory();
var query = db.Query("accounts")
.Where("balance", ">", 0)
.GroupBy("balance")
.Limit(10);

var accounts = query.Clone().Get();
Console.WriteLine(JsonConvert.SerializeObject(accounts, Formatting.Indented));
var accounts = query.Clone().Get();
Console.WriteLine(JsonConvert.SerializeObject(accounts, Formatting.Indented));

var exists = query.Clone().Exists();
Console.WriteLine(exists);
}
}

private static void log(Compiler compiler, Query query)
{
var compiled = compiler.Compile(query);
Console.WriteLine(compiled.ToString());
Console.WriteLine(JsonConvert.SerializeObject(compiled.Bindings));
var exists = query.Clone().Exists();
Console.WriteLine(exists);
}

private static QueryFactory SqlLiteQueryFactory()
Expand Down Expand Up @@ -93,22 +62,6 @@ private static QueryFactory SqlLiteQueryFactory()

}

private static QueryFactory SqlServerQueryFactory()
{
var compiler = new PostgresCompiler();
var connection = new SqlConnection(
"Server=tcp:localhost,1433;Initial Catalog=Lite;User ID=sa;Password=P@ssw0rd"
);

var db = new QueryFactory(connection, compiler);

db.Logger = result =>
{
Console.WriteLine(result.ToString());
};

return db;
}

}
}
10 changes: 5 additions & 5 deletions Program/Program.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Npgsql" Version="4.0.4" />
<PackageReference Include="System.Data.SqlClient" Version="4.5.1" />
<PackageReference Include="System.Data.SQLite" Version="1.0.109.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql" Version="7.0.4" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

</Project>
126 changes: 64 additions & 62 deletions QueryBuilder.Tests/AggregateTests.cs
Original file line number Diff line number Diff line change
@@ -1,92 +1,94 @@
using SqlKata.Compilers;
using SqlKata.Tests.Infrastructure;
using Xunit;

namespace SqlKata.Tests
namespace SqlKata.Tests;

public class AggregateTests : TestSupport
{
public class AggregateTests : TestSupport
[Fact]
public void Count()
{
[Fact]
public void Count()
{
var query = new Query("A").AsCount();
var query = new Query("A").AsCount();

var c = Compile(query);
var c = Compile(query);

Assert.Equal("SELECT COUNT(*) AS [count] FROM [A]", c[EngineCodes.SqlServer]);
Assert.Equal("SELECT COUNT(*) AS `count` FROM `A`", c[EngineCodes.MySql]);
Assert.Equal("SELECT COUNT(*) AS \"count\" FROM \"A\"", c[EngineCodes.PostgreSql]);
Assert.Equal("SELECT COUNT(*) AS \"COUNT\" FROM \"A\"", c[EngineCodes.Firebird]);
}
Assert.Equal("SELECT COUNT(*) AS [count] FROM [A]", c[EngineCodes.SqlServer]);
Assert.Equal("SELECT COUNT(*) AS `count` FROM `A`", c[EngineCodes.MySql]);
Assert.Equal("SELECT COUNT(*) AS \"count\" FROM \"A\"", c[EngineCodes.PostgreSql]);
Assert.Equal("SELECT COUNT(*) AS \"COUNT\" FROM \"A\"", c[EngineCodes.Firebird]);
}

[Fact]
public void CountMultipleColumns()
{
var query = new Query("A").AsCount(new[] { "ColumnA", "ColumnB" });
[Fact]
public void CountMultipleColumns()
{
var query = new Query("A").AsCount(new[] { "ColumnA", "ColumnB" });

var c = Compile(query);
var c = Compile(query);

Assert.Equal("SELECT COUNT(*) AS [count] FROM (SELECT 1 FROM [A] WHERE [ColumnA] IS NOT NULL AND [ColumnB] IS NOT NULL) AS [countQuery]", c[EngineCodes.SqlServer]);
}
Assert.Equal(
"SELECT COUNT(*) AS [count] FROM (SELECT 1 FROM [A] WHERE [ColumnA] IS NOT NULL AND [ColumnB] IS NOT NULL) AS [countQuery]",
c[EngineCodes.SqlServer]);
}

[Fact]
public void DistinctCount()
{
var query = new Query("A").Distinct().AsCount();
[Fact]
public void DistinctCount()
{
var query = new Query("A").Distinct().AsCount();

var c = Compile(query);
var c = Compile(query);

Assert.Equal("SELECT COUNT(*) AS [count] FROM (SELECT DISTINCT * FROM [A]) AS [countQuery]", c[EngineCodes.SqlServer]);
}
Assert.Equal("SELECT COUNT(*) AS [count] FROM (SELECT DISTINCT * FROM [A]) AS [countQuery]",
c[EngineCodes.SqlServer]);
}

[Fact]
public void DistinctCountMultipleColumns()
{
var query = new Query("A").Distinct().AsCount(new[] { "ColumnA", "ColumnB" });
[Fact]
public void DistinctCountMultipleColumns()
{
var query = new Query("A").Distinct().AsCount(new[] { "ColumnA", "ColumnB" });

var c = Compile(query);
var c = Compile(query);

Assert.Equal("SELECT COUNT(*) AS [count] FROM (SELECT DISTINCT [ColumnA], [ColumnB] FROM [A]) AS [countQuery]", c[EngineCodes.SqlServer]);
}
Assert.Equal("SELECT COUNT(*) AS [count] FROM (SELECT DISTINCT [ColumnA], [ColumnB] FROM [A]) AS [countQuery]",
c[EngineCodes.SqlServer]);
}

[Fact]
public void Average()
{
var query = new Query("A").AsAverage("TTL");
[Fact]
public void Average()
{
var query = new Query("A").AsAverage("TTL");

var c = Compile(query);
var c = Compile(query);

Assert.Equal("SELECT AVG([TTL]) AS [avg] FROM [A]", c[EngineCodes.SqlServer]);
}
Assert.Equal("SELECT AVG([TTL]) AS [avg] FROM [A]", c[EngineCodes.SqlServer]);
}

[Fact]
public void Sum()
{
var query = new Query("A").AsSum("PacketsDropped");
[Fact]
public void Sum()
{
var query = new Query("A").AsSum("PacketsDropped");

var c = Compile(query);
var c = Compile(query);

Assert.Equal("SELECT SUM([PacketsDropped]) AS [sum] FROM [A]", c[EngineCodes.SqlServer]);
}
Assert.Equal("SELECT SUM([PacketsDropped]) AS [sum] FROM [A]", c[EngineCodes.SqlServer]);
}

[Fact]
public void Max()
{
var query = new Query("A").AsMax("LatencyMs");
[Fact]
public void Max()
{
var query = new Query("A").AsMax("LatencyMs");

var c = Compile(query);
var c = Compile(query);

Assert.Equal("SELECT MAX([LatencyMs]) AS [max] FROM [A]", c[EngineCodes.SqlServer]);
}
Assert.Equal("SELECT MAX([LatencyMs]) AS [max] FROM [A]", c[EngineCodes.SqlServer]);
}

[Fact]
public void Min()
{
var query = new Query("A").AsMin("LatencyMs");
[Fact]
public void Min()
{
var query = new Query("A").AsMin("LatencyMs");

var c = Compile(query);
var c = Compile(query);

Assert.Equal("SELECT MIN([LatencyMs]) AS [min] FROM [A]", c[EngineCodes.SqlServer]);
}
Assert.Equal("SELECT MIN([LatencyMs]) AS [min] FROM [A]", c[EngineCodes.SqlServer]);
}
}
Loading