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
6bca1952
Commit
6bca1952
authored
Sep 08, 2016
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support for international parameter names (regex categories); fix #601
parent
c8991137
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
Tests.Parameters.cs
Dapper.Tests/Tests.Parameters.cs
+17
-0
SqlMapper.cs
Dapper/SqlMapper.cs
+4
-4
No files found.
Dapper.Tests/Tests.Parameters.cs
View file @
6bca1952
...
@@ -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
}
}
}
}
}
Dapper/SqlMapper.cs
View file @
6bca1952
...
@@ -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
);
...
...
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