Files
Marc Gravell aecffecae1 attempt NRT makeover (#1928)
* attempt NRT makeover

- annotate NRTs on GridReader API
- add protected access to some of the GridReader internals
- switch GridReader callbacks to be more type-independent

docs

lib updates; deal with yellow warnings and test failures (SQL server certs and cancellation surfacing differently)

fix break

simplify proposed GridReader changes to protected OnBeforeGrid and OnAfterGrid[Async]

Builds: Bump library versions (#1935)

Tests: Upgrade dependencies for Dependabot (#1936)

I'll do a pass at all of these later, but getting CVE versions out of the pipe.

Resolving 4 alerts here: https://github.com/DapperLib/Dapper/security/dependabot

merge and lib updates

allow Identity to be constructed on-the-fly inside GridReader

fix build warnings

include readme

rev minor

- enable [SkipLocalsInit] everywhere
- use NET5_0_OR_GREATER
 for remoting check

# Conflicts:
#	Dapper/CommandDefinition.cs
#	Dapper/DefaultTypeMap.cs
#	Dapper/SqlMapper.Async.cs
#	Dapper/SqlMapper.IDataReader.cs
#	Dapper/SqlMapper.Link.cs
#	Dapper/SqlMapper.cs
#	Directory.Build.props

* shipped, not unshipped

* fixup SqlBuilder; use is null / is not null

* use central package management (#1949)

* Nullable test tweaks

* Nuget: let's just remove it!

* 2 test fixes from review

* fix FindExplicitConstructor

* add GetPropertySetterOrThrow

* fix NRT on FindConstructor

* DapperRow: value is object?

* use NotNullWhen

* make constructor problem more obvious

* test fixes

---------

Co-authored-by: Nick Craver <nrcraver@gmail.com>
2023-09-12 15:58:49 +01:00

87 lines
2.7 KiB
C#

#if !NET462 // platform not supported exception
using System;
using System.Collections.Generic;
using System.IO;
using Snowflake.Data.Client;
using Xunit;
using Xunit.Abstractions;
namespace Dapper.Tests
{
public class SnowflakeTests
{
static readonly string? s_ConnectionString;
static SnowflakeTests()
{
SqlMapper.Settings.UseIncrementalPseudoPositionalParameterNames = true;
try
{ // this *probably* won't exist (TODO: can we get a test account?)
s_ConnectionString = File.ReadAllText(@"c:\Code\SnowflakeConnectionString.txt").Trim();
} catch { }
}
public SnowflakeTests(ITestOutputHelper output)
=> Output = output;
private ITestOutputHelper Output { get; }
private static SnowflakeDbConnection GetConnection()
{
if (string.IsNullOrWhiteSpace(s_ConnectionString))
Skip.Inconclusive("no snowflake connection-string");
return new SnowflakeDbConnection
{
ConnectionString = s_ConnectionString
};
}
[Fact]
public void Connect()
{
using var connection = GetConnection();
connection.Open();
}
[Fact]
public void BasicQuery()
{
using var connection = GetConnection();
var nations = connection.Query<Nation>(@"SELECT * FROM NATION").AsList();
Assert.NotEmpty(nations);
Output.WriteLine($"nations: {nations.Count}");
foreach (var nation in nations)
{
Output.WriteLine($"{nation.N_NATIONKEY}: {nation.N_NAME} (region: {nation.N_REGIONKEY}), {nation.N_COMMENT}");
}
}
[Fact]
public void ParameterizedQuery()
{
using var connection = GetConnection();
const int region = 1;
var nations = connection.Query<Nation>(@"SELECT * FROM NATION WHERE N_REGIONKEY=?region?", new { region }).AsList();
Assert.NotEmpty(nations);
Output.WriteLine($"nations: {nations.Count}");
foreach (var nation in nations)
{
Output.WriteLine($"{nation.N_NATIONKEY}: {nation.N_NAME} (region: {nation.N_REGIONKEY}), {nation.N_COMMENT}");
}
}
public class Nation
{
public int N_NATIONKEY { get; set; }
public string? N_NAME{ get; set; }
public int N_REGIONKEY { get; set; }
public string? N_COMMENT { get; set; }
}
}
}
#endif