Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlFieldPathResolverTests.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlFieldPathResolverTests.cs
----
using redb.Core;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Models;
namespace redb.Tests.Integration.Tests.MsSql;
///
/// dbo.pvt_resolve_field_path on SQL Server Free. T-SQL keeps a variable's old value when
/// SELECT @v = ... finds no row, so a nested child the scheme does not have resolved to its parent:
/// Contacts[].NoSuchField came back as the Contacts array itself, and whatever read it - a filter, a sort,
/// a grouping - silently used the wrong structure.
///
[Collection("MsSql")]
public class MsSqlFieldPathResolverTests
{
private readonly IRedbService _redb;
public MsSqlFieldPathResolverTests(MsSqlFixture fixture) => _redb = fixture.Redb;
private async Task ResolveAsync(string path)
{
var scheme = await _redb.SyncSchemeAsync();
return await _redb.Context.ExecuteScalarAsync(
"SELECT dbo.pvt_resolve_field_path(" + scheme.Id + ", $1)", new object[] { path });
}
[Fact]
public async Task ANestedChildTheSchemeDoesNotHave_IsNotResolved()
{
(await ResolveAsync("Contacts[].NoSuchField")).Should().BeNull();
}
[Fact]
public async Task ANestedChildTheSchemeHas_IsResolved()
{
var parent = await ResolveAsync("Contacts[]");
var child = await ResolveAsync("Contacts[].Type");
child.Should().NotBeNull().And.Contain("\"db_type\":\"String\"");
child.Should().NotBe(parent);
}
}