mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-17 05:12:13 +08:00
snowflake tests #1687
This commit is contained in:
@@ -93,6 +93,12 @@ namespace Dapper
|
||||
/// operation if there are this many elements or more. Note that this feature requires SQL Server 2016 / compatibility level 130 (or above).
|
||||
/// </summary>
|
||||
public static int InListStringSplitCount { get; set; } = -1;
|
||||
|
||||
/// <summary>
|
||||
/// If set, pseudo-positional parameters (i.e. ?foo?) are passed using auto-generated incremental names, i.e. "1", "2", "3"
|
||||
/// instead of the original name; for most scenarios, this is ignored since the name is redundant, but "snowflake" requires this.
|
||||
/// </summary>
|
||||
public static bool UseIncrementalPseudoPositionalParameterNames { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1778,6 +1778,8 @@ namespace Dapper
|
||||
}
|
||||
HashSet<string> consumed = new HashSet<string>(StringComparer.Ordinal);
|
||||
bool firstMatch = true;
|
||||
int index = 0; // use this to spoof names; in most pseudo-positional cases, the name is ignored, however:
|
||||
// for "snowflake", the name needs to be incremental i.e. "1", "2", "3"
|
||||
cmd.CommandText = pseudoPositional.Replace(cmd.CommandText, match =>
|
||||
{
|
||||
string key = match.Groups[1].Value;
|
||||
@@ -1793,6 +1795,10 @@ namespace Dapper
|
||||
cmd.Parameters.Clear(); // only clear if we are pretty positive that we've found this pattern successfully
|
||||
}
|
||||
// if found, return the anonymous token "?"
|
||||
if (Settings.UseIncrementalPseudoPositionalParameterNames)
|
||||
{
|
||||
param.ParameterName = (++index).ToString();
|
||||
}
|
||||
cmd.Parameters.Add(param);
|
||||
parameters.Remove(key);
|
||||
consumed.Add(key);
|
||||
|
||||
@@ -20,10 +20,9 @@
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
|
||||
<PackageReference Include="MySqlConnector" Version="1.1.0" />
|
||||
<PackageReference Include="Npgsql" Version="5.0.0" />
|
||||
<PackageReference Include="Snowflake.Data" Version="2.0.3" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net472'">
|
||||
|
||||
Reference in New Issue
Block a user