henkmollema / Dommel

CRUD operations with Dapper made simple.
MIT License
634 stars 100 forks source link

Improve SQL Expressions compiler #254

Closed lucaxchaves closed 3 years ago

lucaxchaves commented 3 years ago

I fixed issue #247 and also improved the SQL expression compiler.

Change List:

In addition, I also added some tests to increase code coverage.

codecov[bot] commented 3 years ago

Codecov Report

Merging #254 (35b3572) into master (21bde67) will increase coverage by 2.30%. The diff coverage is 88.46%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #254      +/-   ##
==========================================
+ Coverage   79.20%   81.51%   +2.30%     
==========================================
  Files          32       32              
  Lines        1188     1244      +56     
  Branches      135      147      +12     
==========================================
+ Hits          941     1014      +73     
+ Misses        213      197      -16     
+ Partials       34       33       -1     
Impacted Files Coverage Δ
src/Dommel/SqlExpression.cs 87.89% <88.11%> (+12.01%) :arrow_up:
src/Dommel.Json/JsonSqlExpression.cs 100.00% <100.00%> (ø)
src/Dommel/Insert.cs 100.00% <0.00%> (ø)
src/Dommel/Resolvers.cs 91.48% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 21bde67...35b3572. Read the comment docs.

henkmollema commented 3 years ago

Hi @lucaxchaves, I had to revert this commit as it contains a critical issue with generating select filters (e.g. #256 and #260). See the test cases added in 224f1365d12149734bbd2cb742b2ba249cd09e3c as well:

private class FooBar
{
    public string? ProductName { get; set; }
}

[Theory]
[ClassData(typeof(DatabaseTestData))]
public void Select_Equals_MemberAccess(DatabaseDriver database)
{
    var filter = new FooBar { ProductName = "Chef Anton's Cajun Seasoning" };
    using var con = database.GetConnection();
    var products = con.Select<Product>(p => p.Name == filter.ProductName);
    Assert.Single(products);
}

Above test case resulted in SQL like: where [Name] = Chef Anton's Cajun Seasoning. Where filter.ProductName should obviously be translated to a parameter.

I've released v2.3.2 with the commit(s) reverted.