You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would disagree that it was really a bug - with the previous code, if you call both Where and OrWhere multiple times, the final result was like this: (WhereCond1 AND WhereCond2 AND ...) AND (OrWhereCond1 OR OrWhereCond2 OR OrWhereCond3 OR ...)
From my perspective, that makes sense.
With this new update we have a breaking change.
It doesn't really matter if I can achieve the same effect using the regular .Where().
The problem here is that so far we've had consistent behaviour (maybe a bit strange, but it worked).
The proposed change is a BREAKING change, so literally it will break ALL existing code that relies on the current behaviour. Dapper is a very popular library and we cannot just break things.
If you need a different behaviour, it is a lot more better to add a new function (or a parameter to the existing one), than to change what we have atm.
I guess no one bothered to check the original test case. It is still not "fixed":
var sql = new SqlBuilder();
var tpl = sql.AddTemplate("select * from foo /**where**/");
sql.Where("MyField = @Param");
sql.OrWhere("MyField2 = @Param2");
select * from foo WHERE ( MyField = @Param OR MyField2 = @Param2 )
However both the previous and fixed SqlBuilder produces the following:
select * from foo WHERE MyField = @Param AND ( MyField2 = @Param2 )
This is because only the first call to one of Where() or OrWhere() is the one that defines the joiner variable. That is, the variable that dictates what string to place between clauses. If Where() is called first the joiner will be "AND" but if OrWhere() is called first the joiner will be "OR".
Consider this: with the "fix" we get the following behavior (imagine these are in separate functions that don't know about each other):
Activity
Merge pull request #577 from liamsymonds/573-sqlbuilder-orwhere
smax48 commentedon Sep 14, 2016
I would disagree that it was really a bug - with the previous code, if you call both Where and OrWhere multiple times, the final result was like this:
(WhereCond1 AND WhereCond2 AND ...) AND (OrWhereCond1 OR OrWhereCond2 OR OrWhereCond3 OR ...)From my perspective, that makes sense.
With this new update we have a breaking change.
smax48 commentedon Oct 26, 2016
It doesn't really matter if I can achieve the same effect using the regular .Where().
The problem here is that so far we've had consistent behaviour (maybe a bit strange, but it worked).
The proposed change is a BREAKING change, so literally it will break ALL existing code that relies on the current behaviour. Dapper is a very popular library and we cannot just break things.
If you need a different behaviour, it is a lot more better to add a new function (or a parameter to the existing one), than to change what we have atm.
CrescentFresh commentedon Nov 21, 2016
I guess no one bothered to check the original test case. It is still not "fixed":
@rafakwolf expected:
However both the previous and fixed SqlBuilder produces the following:
This is because only the first call to one of
Where()orOrWhere()is the one that defines thejoinervariable. That is, the variable that dictates what string to place between clauses. IfWhere()is called first the joiner will be "AND" but ifOrWhere()is called first the joiner will be "OR".Consider this: with the "fix" we get the following behavior (imagine these are in separate functions that don't know about each other):
result:
But switch the order of the calls:
result:
And that is what I would call a bug.
As a side comment, with the previous code it was at least consistent in that it always produced the first result irrespective of order.