Commit 6bca1952 authored by Marc Gravell's avatar Marc Gravell

support for international parameter names (regex categories); fix #601

parent c8991137
...@@ -1043,5 +1043,22 @@ static void Incr(ref int i) ...@@ -1043,5 +1043,22 @@ static void Incr(ref int i)
else if (i <= 1000) i += 50; else if (i <= 1000) i += 50;
else i += 100; else i += 100;
} }
[Fact]
public void Issue601_InternationalParameterNamesWork()
{
// regular parameter
var result = connection.QuerySingle<int>("select @æøå٦", new { æøå٦ = 42 });
result.IsEqualTo(42);
#if OLEDB
// pseudo-positional
using (var connection = ConnectViaOledb())
{
int value = connection.QuerySingle<int>("select ?æøå٦?", new { æøå٦ = 42 });
}
#endif
}
} }
} }
...@@ -2097,13 +2097,13 @@ public static object SanitizeParameterValue(object value) ...@@ -2097,13 +2097,13 @@ public static object SanitizeParameterValue(object value)
} }
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-z0-9_]+|$)", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant)); return parameters.Where(p => Regex.IsMatch(sql, @"[?@:]" + p.Name + @"([^\p{L}\p{N}_]+|$)", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant));
} }
// look for ? / @ / : *by itself* // look for ? / @ / : *by itself*
static readonly Regex smellsLikeOleDb = new Regex(@"(?<![a-z0-9@_])[?@:](?![a-z0-9@_])", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant | RegexOptions.Compiled), static readonly Regex smellsLikeOleDb = new Regex(@"(?<![\p{L}\p{N}@_])[?@:](?![\p{L}\p{N}@_])", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant | RegexOptions.Compiled),
literalTokens = new Regex(@"(?<![a-z0-9_])\{=([a-z0-9_]+)\}", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant | RegexOptions.Compiled), literalTokens = new Regex(@"(?<![\p{L}\p{N}_])\{=([\p{L}\p{N}_]+)\}", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant | RegexOptions.Compiled),
pseudoPositional = new Regex(@"\?([a-z_][a-z0-9_]*)\?", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled); pseudoPositional = new Regex(@"\?([\p{L}_][\p{L}\p{N}_]*)\?", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled);
......
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