提交 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) ...@@ -3314,6 +3314,14 @@ internal static IList<LiteralToken> GetLiteralTokens(string sql)
switch (typeCode) switch (typeCode)
{ {
case TypeCode.Boolean: 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.Byte:
case TypeCode.SByte: case TypeCode.SByte:
case TypeCode.UInt16: case TypeCode.UInt16:
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0",
"summary": "A high performance Micro-ORM", "summary": "A high performance Micro-ORM",
"description": "A high performance Micro-ORM supporting Sql Server, MySQL, Sqlite, SqlCE, Firebird etc..", "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" ], "compile": [ "../Dapper NET40/*.cs", "../Dapper NET45/*.cs" ],
"title": "Dapper dot net", "title": "Dapper dot net",
"tags": [ "orm", "sql", "micro-orm" ], "tags": [ "orm", "sql", "micro-orm" ],
......
...@@ -3224,6 +3224,14 @@ public void LiteralReplacementDynamicEnumAndString() ...@@ -3224,6 +3224,14 @@ public void LiteralReplacementDynamicEnumAndString()
z.Equals(AnotherEnum.A); 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() public void LiteralReplacementWithIn()
{ {
var data = connection.Query<MyRow>("select @x where 1 in @ids and 1 ={=a}", 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.
先完成此消息的编辑!
想要评论请 注册