提交 808c2708 编写于 作者: M Marc Gravell

Fix boolean literal replacement in IL-based IMPL; 1.41-beta5 release

上级 e9313a71
......@@ -3314,6 +3314,14 @@ internal static IList<LiteralToken> GetLiteralTokens(string sql)
switch (typeCode)
{
case TypeCode.Boolean:
Label ifTrue = il.DefineLabel(), allDone = il.DefineLabel();
il.Emit(OpCodes.Brtrue_S, ifTrue);
il.Emit(OpCodes.Ldstr, "0");
il.Emit(OpCodes.Br_S, allDone);
il.MarkLabel(ifTrue);
il.Emit(OpCodes.Ldstr, "1");
il.MarkLabel(allDone);
break;
case TypeCode.Byte:
case TypeCode.SByte:
case TypeCode.UInt16:
......
......@@ -5,7 +5,7 @@
"licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0",
"summary": "A high performance Micro-ORM",
"description": "A high performance Micro-ORM supporting Sql Server, MySQL, Sqlite, SqlCE, Firebird etc..",
"version": "1.41-beta4",
"version": "1.41-beta5",
"compile": [ "../Dapper NET40/*.cs", "../Dapper NET45/*.cs" ],
"title": "Dapper dot net",
"tags": [ "orm", "sql", "micro-orm" ],
......
......@@ -3223,7 +3223,15 @@ public void LiteralReplacementDynamicEnumAndString()
y.Equals(123.45M);
z.Equals(AnotherEnum.A);
}
public void LiteralReplacementBoolean()
{
var row = connection.Query<int?>("select 42 where 1 = {=val}", new { val = true }).SingleOrDefault();
row.IsNotNull();
row.IsEqualTo(42);
row = connection.Query<int?>("select 42 where 1 = {=val}", new { val = false }).SingleOrDefault();
row.IsNull();
}
public void LiteralReplacementWithIn()
{
var data = connection.Query<MyRow>("select @x where 1 in @ids and 1 ={=a}",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册