提交 4f1e5f91 编写于 作者: T tms

Make parameter filtering truly culture-insensitive

上级 885a8d46
......@@ -1833,7 +1833,7 @@ public static void PackListParameters(IDbCommand command, string namePrefix, obj
private static IEnumerable<PropertyInfo> FilterParameters(IEnumerable<PropertyInfo> parameters, string sql)
{
return parameters.Where(p => Regex.IsMatch(sql, @"[?@:]" + p.Name + "([^a-zA-Z0-9_]+|$)", RegexOptions.IgnoreCase | RegexOptions.Multiline));
return parameters.Where(p => Regex.IsMatch(sql, @"[?@:]" + p.Name + "([^a-zA-Z0-9_]+|$)", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant));
}
......@@ -1924,15 +1924,6 @@ private static IEnumerable<PropertyInfo> FilterParameters(IEnumerable<PropertyIn
foreach (var prop in props)
{
if (filterParams)
{
if (identity.sql.IndexOf("@" + prop.Name, StringComparison.InvariantCultureIgnoreCase) < 0
&& identity.sql.IndexOf(":" + prop.Name, StringComparison.InvariantCultureIgnoreCase) < 0
&& identity.sql.IndexOf("?" + prop.Name, StringComparison.InvariantCultureIgnoreCase) < 0)
{ // can't see the parameter in the text (even in a comment, etc) - burn it with fire
continue;
}
}
if (typeof(ICustomQueryParameter).IsAssignableFrom(prop.PropertyType))
{
il.Emit(OpCodes.Ldloc_0); // stack is now [parameters] [typed-param]
......
......@@ -13,6 +13,8 @@
using System.ComponentModel;
using Microsoft.CSharp.RuntimeBinder;
using System.Data.Common;
using System.Globalization;
using System.Threading;
#if POSTGRESQL
using Npgsql;
#endif
......@@ -2637,6 +2639,16 @@ public void TestDoubleDecimalConversions_SO18228523_Nulls()
row.D.IsNull();
}
public void TestParameterInclusionNotSensitiveToCurrentCulture()
{
CultureInfo current = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR");
connection.Query<int>("select @pid", new { PId = 1 }).Single();
Thread.CurrentThread.CurrentCulture = current;
}
class HasDoubleDecimal
{
public double A { get; set; }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册