-
-
Notifications
You must be signed in to change notification settings - Fork 519
Test Improvements & Benchmarks for SqlKata Compiler #738
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
Conversation
Hey @faddiv thanks for your contribution, I would take a bit of time to review it, but it seems interesting, |
Hi @ahmad-moussawi , I added the description. It simply can run with the following command: |
This workflow automates the build and test process for a .NET project on push and pull request events to the main branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR significantly improves test infrastructure and adds performance benchmarking for SqlKata's query compiler by restructuring existing tests to use Theory
and InlineData
attributes and introducing BenchmarkDotNet-based performance tests.
- Replaced centralized compiler container with direct compiler creation methods for better test isolation
- Refactored test methods to use parameterized tests with
Theory
andInlineData
for better test granularity - Added comprehensive benchmark project with memory diagnostics for compiler performance analysis
Reviewed Changes
Copilot reviewed 48 out of 48 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
sqlkata.sln | Adds benchmark project to solution |
QueryBuilder.Tests/*.cs | Restructures tests from single multi-engine methods to parameterized tests |
QueryBuilder.Tests/Infrastructure/ | Replaces TestCompilersContainer with direct compiler creation methods |
QueryBuilder.Benchmarks/ | New benchmark project with infrastructure and test validation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
QueryBuilder.Tests/UpdateTests.cs
Outdated
|
||
var query = new Query("Books") | ||
.With("OldBooks", q => q.From("Books").Where("Date", "<", now)) | ||
.With("OldBooks", q => q.From("Books").Where("Date", "<", "2024-05-24")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded date value '2024-05-24' should be replaced with a more maintainable approach, such as using a DateTime constant or variable, to make the test more readable and easier to maintain.
Copilot uses AI. Check for mistakes.
QueryBuilder.Tests/SelectTests.cs
Outdated
"SELECT * FROM \"Phones\" UNION SELECT * FROM \"Laptops\" WHERE \"Type\" = 'A'")] | ||
[InlineData(EngineCodes.MySql, "SELECT * FROM `Phones` UNION SELECT * FROM `Laptops` WHERE `Type` = 'A'")] | ||
[InlineData(EngineCodes.Firebird, | ||
"SELECT * FROM \"PHONES\" UNION SELECT * FROM \"Laptops\" WHERE \"Type\" = 'A'")] // Is this good? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment '// Is this good?' suggests uncertainty about the test case. Either remove the comment if the test case is correct, or investigate and fix the case if there's an issue with the expected SQL output.
"SELECT * FROM \"PHONES\" UNION SELECT * FROM \"Laptops\" WHERE \"Type\" = 'A'")] // Is this good? | |
"SELECT * FROM \"PHONES\" UNION SELECT * FROM \"LAPTOPS\" WHERE \"TYPE\" = 'A'")] |
Copilot uses AI. Check for mistakes.
EngineCodes.SqlServer => new SqlServerCompiler | ||
{ | ||
UseLegacyPagination = useLegacyPagination ?? true | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The default value for SqlServer's UseLegacyPagination
is true
while Oracle's is false
. This inconsistency could lead to confusion. Consider documenting why different engines have different defaults or making the defaults consistent.
Copilot uses AI. Check for mistakes.
@faddiv sorry for the late reply, |
Added SQL Server service container and updated installation steps for sqlcmd tools.
Hi @ahmad-moussawi. I will close this and reorganize this into two separate pr. |
Hi Ahmad,
We've been using SqlKata in our project, and I’ve started exploring its internals.
I thought the compiler part could be improved significantly both for speed and memory usage.
However, to rewrite it safely, I first wanted to improve the tests and add some benchmarks.
This PR shows what I did in this regard. Please review this PR, and let me know if you are interested in any part of my work. (I also have a branch in which I implemented a new compiler, just enough to run the benchmarks.)
How to run the benchmark
In IDE:
Command line:
From the solution folder (on Windows):
dotnet run -c Release --project .\QueryBuilder.Benchmarks\QueryBuilder.Benchmarks.csproj
The reports are generated into the
.\BenchmarkDotNet.Artifacts\
folder at the solution level.Meanwhile, it is recommended to close everything else, and do as little as possible so other processes don't affect the results.
Summary of Changes:
Theory
andInlineData
attributes. This way it can be seen if anything fails separately, and better visible if any test is missing.TestCompilersContainer
completely. I was not sure in which direction you wanted to move these tests, but I saw somewhere that you wished to deprecate them.Looking forward to your feedback!