Commit 2a3bf22f authored by Marc Gravell's avatar Marc Gravell

Merge pull request #99 from tms/cultural-paramter-filtering

Make parameter filtering truly culture-insensitive
parents f0dac59e 4f1e5f91
...@@ -2055,7 +2055,7 @@ public static void PackListParameters(IDbCommand command, string namePrefix, obj ...@@ -2055,7 +2055,7 @@ public static void PackListParameters(IDbCommand command, string namePrefix, obj
private static IEnumerable<PropertyInfo> FilterParameters(IEnumerable<PropertyInfo> parameters, string sql) 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));
} }
...@@ -2146,15 +2146,6 @@ private static IEnumerable<PropertyInfo> FilterParameters(IEnumerable<PropertyIn ...@@ -2146,15 +2146,6 @@ private static IEnumerable<PropertyInfo> FilterParameters(IEnumerable<PropertyIn
foreach (var prop in props) 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)) if (typeof(ICustomQueryParameter).IsAssignableFrom(prop.PropertyType))
{ {
il.Emit(OpCodes.Ldloc_0); // stack is now [parameters] [typed-param] il.Emit(OpCodes.Ldloc_0); // stack is now [parameters] [typed-param]
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
using System.ComponentModel; using System.ComponentModel;
using Microsoft.CSharp.RuntimeBinder; using Microsoft.CSharp.RuntimeBinder;
using System.Data.Common; using System.Data.Common;
using System.Globalization;
using System.Threading;
#if POSTGRESQL #if POSTGRESQL
using Npgsql; using Npgsql;
#endif #endif
...@@ -2651,6 +2653,16 @@ public void TestDoubleDecimalConversions_SO18228523_Nulls() ...@@ -2651,6 +2653,16 @@ public void TestDoubleDecimalConversions_SO18228523_Nulls()
row.D.IsNull(); 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 class HasDoubleDecimal
{ {
public double A { get; set; } public double A { get; set; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment