Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Dapper
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
Dapper
Commits
4f1e5f91
Commit
4f1e5f91
authored
Oct 24, 2013
by
tms
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make parameter filtering truly culture-insensitive
parent
885a8d46
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
SqlMapper.cs
Dapper NET40/SqlMapper.cs
+1
-10
Tests.cs
Tests/Tests.cs
+12
-0
No files found.
Dapper NET40/SqlMapper.cs
View file @
4f1e5f91
...
@@ -1833,7 +1833,7 @@ public static void PackListParameters(IDbCommand command, string namePrefix, obj
...
@@ -1833,7 +1833,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
));
}
}
...
@@ -1924,15 +1924,6 @@ private static IEnumerable<PropertyInfo> FilterParameters(IEnumerable<PropertyIn
...
@@ -1924,15 +1924,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]
...
...
Tests/Tests.cs
View file @
4f1e5f91
...
@@ -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
...
@@ -2637,6 +2639,16 @@ public void TestDoubleDecimalConversions_SO18228523_Nulls()
...
@@ -2637,6 +2639,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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment