henkmollema / Dommel

CRUD operations with Dapper made simple.
MIT License
611 stars 99 forks source link

Parentheses in SQL WHERE clause not working #293

Closed FisherTsai closed 8 months ago

FisherTsai commented 1 year ago

I found an issue when using Select function. Here is a simple example:

var products = connection.Select<Product>(p => p.Id > 0 && (p.Id == 1 || p.Id < 0))

The SQL WHERE clause created by Dommel does not have parentheses for the "or" condition. This makes the incorrect logic. In the above example, Product with Id 1 can't be fetched when using Dommel v3.0.0.

henkmollema commented 8 months ago

This is rather a missing feature than a bug, also a duplicate of https://github.com/henkmollema/Dommel/issues/247. I'll be looking into your attempt to fix it in https://github.com/FisherTsai/Dommel/commit/3c053d124408c84443f7176491fc8853c98f6a2c as well.