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
977bbb0a
Commit
977bbb0a
authored
May 12, 2014
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"@foo unknown" detection and handling (query optimizer hints)
parent
9071f652
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
77 additions
and
22 deletions
+77
-22
AssemblyInfo.cs
Dapper NET40/Properties/AssemblyInfo.cs
+2
-2
SqlMapper.cs
Dapper NET40/SqlMapper.cs
+39
-7
AssemblyInfo.cs
Dapper.Contrib.Tests/Properties/AssemblyInfo.cs
+2
-2
AssemblyInfo.cs
Dapper.Contrib/Properties/AssemblyInfo.cs
+2
-2
AssemblyInfo.cs
Dapper.SqlBuilder/Properties/AssemblyInfo.cs
+2
-2
AssemblyInfo.cs
DapperTests NET35/Properties/AssemblyInfo.cs
+2
-2
AssemblyInfo.cs
DapperTests NET45/Properties/AssemblyInfo.cs
+2
-2
AssemblyInfo.cs
Tests/Properties/AssemblyInfo.cs
+2
-2
Tests.cs
Tests/Tests.cs
+22
-0
dapper.nuspec
dapper.nuspec
+2
-1
No files found.
Dapper NET40/Properties/AssemblyInfo.cs
View file @
977bbb0a
...
...
@@ -32,5 +32,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.2
2
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
2
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
3
.0.0"
)]
Dapper NET40/SqlMapper.cs
View file @
977bbb0a
...
...
@@ -2081,21 +2081,53 @@ public static void PackListParameters(IDbCommand command, string namePrefix, obj
}
}
var
regexIncludingUnkown
=
@"([?@:]"
+
Regex
.
Escape
(
namePrefix
)
+
@")(\s*(?i)unknown(?-i))?"
;
if
(
count
==
0
)
{
command
.
CommandText
=
Regex
.
Replace
(
command
.
CommandText
,
@"[?@:]"
+
Regex
.
Escape
(
namePrefix
),
"(SELECT NULL WHERE 1 = 0)"
);
command
.
CommandText
=
Regex
.
Replace
(
command
.
CommandText
,
regexIncludingUnkown
,
match
=>
{
var
variableName
=
match
.
Groups
[
1
].
Value
;
if
(
match
.
Groups
[
2
].
Success
)
{
// looks like an optimize hint; leave it alone!
return
match
.
Value
;
}
else
{
return
"(SELECT "
+
variableName
+
" WHERE 1 = 0)"
;
};
});
var
dummyParam
=
command
.
CreateParameter
();
dummyParam
.
ParameterName
=
namePrefix
;
dummyParam
.
Value
=
DBNull
.
Value
;
command
.
Parameters
.
Add
(
dummyParam
);
}
else
{
command
.
CommandText
=
Regex
.
Replace
(
command
.
CommandText
,
@"[?@:]"
+
Regex
.
Escape
(
namePrefix
)
,
match
=>
command
.
CommandText
=
Regex
.
Replace
(
command
.
CommandText
,
regexIncludingUnkown
,
match
=>
{
var
grp
=
match
.
Value
;
var
sb
=
new
StringBuilder
(
"("
).
Append
(
grp
).
Append
(
1
);
for
(
int
i
=
2
;
i
<=
count
;
i
++)
var
variableName
=
match
.
Groups
[
1
].
Value
;
if
(
match
.
Groups
[
2
].
Success
)
{
sb
.
Append
(
','
).
Append
(
grp
).
Append
(
i
);
// looks like an optimize hint; expand it
var
suffix
=
match
.
Groups
[
2
].
Value
;
var
sb
=
new
StringBuilder
(
variableName
).
Append
(
1
).
Append
(
suffix
);
for
(
int
i
=
2
;
i
<=
count
;
i
++)
{
sb
.
Append
(
','
).
Append
(
variableName
).
Append
(
i
).
Append
(
suffix
);
}
return
sb
.
ToString
();
}
else
{
var
sb
=
new
StringBuilder
(
"("
).
Append
(
variableName
).
Append
(
1
);
for
(
int
i
=
2
;
i
<=
count
;
i
++)
{
sb
.
Append
(
','
).
Append
(
variableName
).
Append
(
i
);
}
return
sb
.
Append
(
')'
).
ToString
();
}
return
sb
.
Append
(
')'
).
ToString
();
});
}
}
...
...
Dapper.Contrib.Tests/Properties/AssemblyInfo.cs
View file @
977bbb0a
...
...
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.2
2
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
2
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
3
.0.0"
)]
Dapper.Contrib/Properties/AssemblyInfo.cs
View file @
977bbb0a
...
...
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.2
2
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
2
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
3
.0.0"
)]
Dapper.SqlBuilder/Properties/AssemblyInfo.cs
View file @
977bbb0a
...
...
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.2
2
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
2
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
3
.0.0"
)]
DapperTests NET35/Properties/AssemblyInfo.cs
View file @
977bbb0a
...
...
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.2
2
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
2
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
3
.0.0"
)]
DapperTests NET45/Properties/AssemblyInfo.cs
View file @
977bbb0a
...
...
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.2
2
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
2
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
3
.0.0"
)]
Tests/Properties/AssemblyInfo.cs
View file @
977bbb0a
...
...
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"1.2
2
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
2
.0.0"
)]
[
assembly
:
AssemblyVersion
(
"1.2
3
.0.0"
)]
[
assembly
:
AssemblyFileVersion
(
"1.2
3
.0.0"
)]
Tests/Tests.cs
View file @
977bbb0a
...
...
@@ -2731,6 +2731,28 @@ public void LiteralIn()
count
.
IsEqualTo
(
2
);
}
public
void
ParameterizedInWithOptimizeHint
()
{
const
string
sql
=
@"
select count(1)
from(
select 1 as x
union all select 2
union all select 5) y
where y.x in @vals
option (optimize for (@vals unKnoWn))"
;
int
count
=
connection
.
Query
<
int
>(
sql
,
new
{
vals
=
new
[]
{
1
,
2
,
3
,
4
}
}).
Single
();
count
.
IsEqualTo
(
2
);
count
=
connection
.
Query
<
int
>(
sql
,
new
{
vals
=
new
[]
{
1
}
}).
Single
();
count
.
IsEqualTo
(
1
);
count
=
connection
.
Query
<
int
>(
sql
,
new
{
vals
=
new
int
[
0
]
}).
Single
();
count
.
IsEqualTo
(
0
);
}
public
void
TestProcedureWithTimeParameter
()
{
...
...
dapper.nuspec
View file @
977bbb0a
...
...
@@ -2,7 +2,7 @@
<package
xmlns=
"http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"
>
<metadata
schemaVersion=
"2"
>
<id>
Dapper
</id>
<version>
1.2
2
</version>
<version>
1.2
3
</version>
<title>
Dapper dot net
</title>
<authors>
Sam Saffron,Marc Gravell
</authors>
<owners>
Sam Saffron,Marc Gravell
</owners>
...
...
@@ -19,6 +19,7 @@
<frameworkAssembly
assemblyName=
"Microsoft.CSharp"
targetFramework=
".NETFramework4.0-Client, .NETFramework4.0"
/>
</frameworkAssemblies>
<releaseNotes>
* 1.23 - Improved support for optimize hints (@foo unknown) with list expansions
* 1.22 - Literal support now extends to enumerable types (for "in" etc usage); move to command-flags model for "buffered" etc
* 1.21 - Limit literals to numeric types; for enums, use value not name
* 1.20 - Improved async support in .NET 4.5 (lots of contributions from users here, including JasonPunyon, kwaclaw, tugberkugurlu, and mgravell);
...
...
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