Bundle: redb / redb.Tests.Integration (redb.Tests.Integration.2.txt), 828 files Snapshot: 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 Index: https://redbase.app/src/dev-2026-12-06/redb/_index.txt ==== Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlMaterializationFidelityTests.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/MsSqlMaterializationFidelityTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; public class MsSqlMaterializationFidelityTests : MaterializationFidelityTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlModuleSmokeTests.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/MsSqlModuleSmokeTests.cs ---- using System.Text.RegularExpressions; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Configuration; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.MsSql; /// /// Runs the SQL module's own smoke runner, redb.MSSql/sql/v2-pvt/99_smoke_auto.sql, against the fixture /// database (review SQ-4). It was run by hand only, so nothing kept it passing. It builds SQL for a table of filter /// cases over the test model corpus, asserts shapes, and raises at the end when any case failed; the PRINT lines /// name the cases and are attached to the failure. /// [Collection("MsSql")] public class MsSqlModuleSmokeTests { // Ensures the fixture has initialized the database (schemes, module) before the script runs. public MsSqlModuleSmokeTests(MsSqlFixture fixture) => _ = fixture.Redb; [Fact] public async Task TheModuleSmokeRunner_Passes() { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; var script = await File.ReadAllTextAsync(Path.Combine(AppContext.BaseDirectory, "Smoke", "mssql_99_smoke_auto.sql")); var printed = new List(); // One connection for every batch: the runner keeps its cases in a #temp table. await using var connection = new SqlConnection(cs); connection.InfoMessage += (_, e) => printed.Add(e.Message); await connection.OpenAsync(); try { foreach (var batch in Regex.Split(script, @"^\s*GO\s*$", RegexOptions.Multiline | RegexOptions.IgnoreCase)) { if (string.IsNullOrWhiteSpace(batch)) continue; await using var command = new SqlCommand(batch, connection) { CommandTimeout = 600 }; await command.ExecuteNonQueryAsync(); } } catch (SqlException ex) { throw new Xunit.Sdk.XunitException( ex.Message + Environment.NewLine + string.Join(Environment.NewLine, printed.Where(IsFailure))); } printed.Where(IsFailure).Should().BeEmpty(); } // "FAIL [scheme / case] ...", "INSPECT [...] FAILED: ...", "SHAPE-FAIL ..." - not a summary such as "fail: 0". private static bool IsFailure(string line) => line.StartsWith("FAIL [", StringComparison.Ordinal) || line.Contains(" FAILED", StringComparison.Ordinal) || line.Contains("SHAPE-FAIL", StringComparison.Ordinal); } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlNestedDictionaryFilterTests.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/MsSqlNestedDictionaryFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlNestedDictionaryFilterTests : NestedDictionaryFilterTestsBase { public MsSqlNestedDictionaryFilterTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlNullComparisonTests.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/MsSqlNullComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlNullComparisonTests : NullComparisonTestsBase { public MsSqlNullComparisonTests(MsSqlFixture fixture) : base(fixture.Redb) { } protected override bool NegatedListItemTakesObjectsWithoutItem => true; } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlNullableCollectionsTests.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/MsSqlNullableCollectionsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlNullableCollectionsTests : NullableCollectionsTestsBase { public MsSqlNullableCollectionsTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlOrderAbsentValueTests.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/MsSqlOrderAbsentValueTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlOrderAbsentValueTests : OrderAbsentValueTestsBase { public MsSqlOrderAbsentValueTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlOrderPositionTests.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/MsSqlOrderPositionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlOrderPositionTests : FreeOrderPositionTestsBase { public MsSqlOrderPositionTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlOrderingTests.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/MsSqlOrderingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlOrderingTests : OrderingTestsBase { public MsSqlOrderingTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlOrphanTransactionTests.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/MsSqlOrphanTransactionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlOrphanTransactionTests : OrphanTransactionTestsBase { public MsSqlOrphanTransactionTests(MsSqlFixture fixture) : base(fixture.ServiceProvider) { } protected override string FailingBatchThatOpensATransaction => "BEGIN TRANSACTION; RAISERROR(N'redb orphan-transaction probe', 16, 1);"; } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlParallelImportFinishTests.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/MsSqlParallelImportFinishTests.cs ---- using Microsoft.Data.SqlClient; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; /// on SQL Server, scratch databases dropped afterwards. public class MsSqlParallelImportFinishTests : ParallelImportFinishTestsBase, IAsyncLifetime { private string _server = null!; private readonly List _databases = []; private readonly List _files = []; protected override string ProviderName => "mssql"; public Task InitializeAsync() { _server = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; return Task.CompletedTask; } public async Task DisposeAsync() { SqlConnection.ClearAllPools(); foreach (var database in _databases) await ExecuteAsync(Master(), $"IF DB_ID('{database}') IS NOT NULL BEGIN ALTER DATABASE [{database}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{database}] END"); foreach (var file in _files) File.Delete(file); } protected override async Task NewDatabaseAsync(string suffix) { var name = $"redb_export_fin_{Guid.NewGuid().ToString("N")[..12]}_{suffix}"; _databases.Add(name); await ExecuteAsync(Master(), $"CREATE DATABASE [{name}]"); return new SqlConnectionStringBuilder(_server) { InitialCatalog = name }.ConnectionString; } protected override ServiceProvider Build(string cs) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => options.UseMsSql(cs).Configure(c => c.CacheDomain = $"fin-{Guid.NewGuid():N}")); return services.BuildServiceProvider(); } protected override string NewFile() { var file = Path.Combine(Path.GetTempPath(), $"redb-export-fin-{Guid.NewGuid():N}.redb"); _files.Add(file); return file; } protected override async Task ScalarAsync(string cs, string sql) { await using var connection = new SqlConnection(cs); await connection.OpenAsync(); await using var command = new SqlCommand(sql, connection); return Convert.ToString(await command.ExecuteScalarAsync()); } protected override Task DropSequenceAsync(string cs) => ExecuteAsync(cs, "DROP SEQUENCE [dbo].[global_identity]"); protected override async Task> ShapeAsync(string cs) { var lines = new List(); await using var connection = new SqlConnection(cs); await connection.OpenAsync(); foreach (var sql in new[] { """ SELECT 'index ' + t.name + '.' + i.name + ' disabled=' + CAST(i.is_disabled AS varchar(1)) FROM sys.indexes i JOIN sys.tables t ON t.object_id = i.object_id WHERE i.name IS NOT NULL ORDER BY 1 """, "SELECT 'fk ' + name + ' disabled=' + CAST(is_disabled AS varchar(1)) + ' untrusted=' + CAST(is_not_trusted AS varchar(1)) FROM sys.foreign_keys ORDER BY 1", "SELECT 'trigger ' + name + ' disabled=' + CAST(is_disabled AS varchar(1)) FROM sys.triggers ORDER BY 1", }) { await using var command = new SqlCommand(sql, connection); await using var reader = await command.ExecuteReaderAsync(); while (await reader.ReadAsync()) lines.Add(reader.GetString(0)); } return lines; } private string Master() => new SqlConnectionStringBuilder(_server) { InitialCatalog = "master" }.ConnectionString; private static async Task ExecuteAsync(string cs, string sql) { await using var connection = new SqlConnection(cs); await connection.OpenAsync(); await using var command = new SqlCommand(sql, connection); await command.ExecuteNonQueryAsync(); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlPasswordHasherDefaultTests.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/MsSqlPasswordHasherDefaultTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlPasswordHasherDefaultTests : PasswordHasherDefaultTestsBase { public MsSqlPasswordHasherDefaultTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlPolymorphicTreeTests.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/MsSqlPolymorphicTreeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlPolymorphicTreeTests : PolymorphicTreeTestsBase { public MsSqlPolymorphicTreeTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlProCancellationTests.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/MsSqlProCancellationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSqlPro")] public class MsSqlProCancellationTests : CancellationTestsBase { public MsSqlProCancellationTests(MsSqlProFixture fixture) : base(fixture.Redb) { } protected override string? SleepSql => "WAITFOR DELAY '00:00:30'"; } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlProQueryTests.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/MsSqlProQueryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlProQueryTests : ProQueryTestsBase { public MsSqlProQueryTests(MsSqlFixture fixture) : base(fixture.Redb, isPro: false) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlProjectionTests.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/MsSqlProjectionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlProjectionTests : ProjectionTestsBase { public MsSqlProjectionTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropertyRenameTests.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/MsSqlPropertyRenameTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlPropertyRenameTests : PropertyRenameTestsBase { public MsSqlPropertyRenameTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropsCacheHeaderTests.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/MsSqlPropsCacheHeaderTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; public class MsSqlPropsCacheHeaderTests : PropsCacheHeaderTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropsCacheSkipValidationTests.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/MsSqlPropsCacheSkipValidationTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; public class MsSqlPropsCacheSkipValidationTests : PropsCacheSkipValidationTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropsCacheTransactionKeepTests.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/MsSqlPropsCacheTransactionKeepTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; public class MsSqlPropsCacheTransactionKeepTests : PropsCacheTransactionKeepTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlPropsCacheTransactionTests.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/MsSqlPropsCacheTransactionTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; public class MsSqlPropsCacheTransactionTests : PropsCacheTransactionTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlQueryOrderTests.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/MsSqlQueryOrderTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlQueryOrderTests : QueryOrderTestsBase { public MsSqlQueryOrderTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlQueryPlannerBlockTests.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/MsSqlQueryPlannerBlockTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlQueryPlannerBlockTests : FreeQueryPlannerBlockTestsBase { public MsSqlQueryPlannerBlockTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlQueryRowsAsJsonTests.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/MsSqlQueryRowsAsJsonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlQueryRowsAsJsonTests : QueryRowsAsJsonTestsBase { public MsSqlQueryRowsAsJsonTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlReaderConnectionTests.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/MsSqlReaderConnectionTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; public class MsSqlReaderConnectionTests : ReaderConnectionTestsBase { protected override string SlowScalarSql => "WAITFOR DELAY '00:00:02'; SELECT CAST(1 AS bigint)"; protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlReferenceListSaveTests.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/MsSqlReferenceListSaveTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; public class MsSqlReferenceListSaveTests : ReferenceListSaveTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlReferenceStubTests.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/MsSqlReferenceStubTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlReferenceStubTests : ReferenceStubTestsBase { public MsSqlReferenceStubTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlRegexQueryTests.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/MsSqlRegexQueryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlRegexQueryTests : RegexQueryTestsBase { public MsSqlRegexQueryTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSaveGraphHashTests.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/MsSqlSaveGraphHashTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlSaveGraphHashTests : SaveGraphHashTestsBase { public MsSqlSaveGraphHashTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSaveInterceptorTests.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/MsSqlSaveInterceptorTests.cs ---- using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlSaveInterceptorTests : SaveInterceptorTestsBase { protected override string ConnectionStringName => "MSSql"; protected override void UseProvider(RedbOptionsBuilder options, string connectionString) => options.UseMsSql(connectionString); } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSaveLockScopeTests.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/MsSqlSaveLockScopeTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; public class MsSqlSaveLockScopeTests : SaveLockScopeTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemaInitTests.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/MsSqlSchemaInitTests.cs ---- using Microsoft.Data.SqlClient; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Export.Services; using redb.MSSql.Sql; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; /// on SQL Server, scratch databases dropped afterwards. public class MsSqlSchemaInitTests : SchemaInitTestsBase, IAsyncLifetime { private string _server = null!; private readonly List _databases = []; protected override string ProviderName => "mssql"; protected override string RequiredVersion => new MsSqlDialect().Query_PvtRequiredVersion()!; private const string UserObjectsSql = "SELECT COUNT(*) FROM sys.objects WHERE is_ms_shipped = 0"; // The SQL Server script runs batch by batch, each committed on its own: a failure in the middle leaves the batches // before it. A table of the script's own name stops it after _types is created. [Fact] public async Task AnInit_ThatFailsHalfWay_NamesTheHalfCreatedDatabase_AndOnlyDropAndCreate() { var cs = await NewDatabaseAsync("half"); await ExecuteAsync(cs, "CREATE TABLE dbo._links (x int)"); var init = async () => await SchemaInitService.InitializeAsync(ProviderName, cs); (await init.Should().ThrowAsync()).Which.Message .Should().Contain("holds part of the redb schema").And.Contain("drop and create the database") .And.NotContain("schema --upgrade"); (await ScalarAsync(cs, "SELECT CASE WHEN OBJECT_ID(N'dbo._types', N'U') IS NULL THEN 0 ELSE 1 END")) .Should().Be("1", "precondition: the batches before the failure stayed"); } [Fact] public async Task AnInit_OverAHalfCreatedDatabase_LeadsWithDropAndCreate_AndTouchesNothing() { var cs = await NewDatabaseAsync("half-again"); await ExecuteAsync(cs, "CREATE TABLE dbo._links (x int)"); await FluentActions.Awaiting(() => SchemaInitService.InitializeAsync(ProviderName, cs)) .Should().ThrowAsync("precondition: the first init stopped half-way"); var before = await ScalarAsync(cs, UserObjectsSql); var again = async () => await SchemaInitService.InitializeAsync(ProviderName, cs); var message = (await again.Should().ThrowAsync()).Which.Message; message.Should().Contain("holds part of the redb schema").And.Contain("has changed nothing"); message.IndexOf("drop and create the database", StringComparison.Ordinal).Should().BeGreaterThan(-1) .And.BeLessThan(IndexOfOrEnd(message, "start a redb"), "drop and create comes first"); message.Should().NotContain("schema --upgrade"); (await ScalarAsync(cs, UserObjectsSql)).Should().Be(before); } [Fact] public async Task AnInit_OverASchemaWithoutItsModuleVersion_IsTakenForIncomplete() { // _schemes is there, the function the script deploys last is not: the probe used to answer "upgrade it". var cs = await NewDatabaseAsync("no-module"); await SchemaInitService.InitializeAsync(ProviderName, cs); await ExecuteAsync(cs, "DROP FUNCTION dbo.pvt_module_version"); var again = async () => await SchemaInitService.InitializeAsync(ProviderName, cs); (await again.Should().ThrowAsync()).Which.Message .Should().Contain("holds part of the redb schema").And.Contain("drop and create the database") .And.NotContain("schema --upgrade"); } private static int IndexOfOrEnd(string text, string value) { var index = text.IndexOf(value, StringComparison.Ordinal); return index < 0 ? text.Length : index; } public Task InitializeAsync() { _server = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; return Task.CompletedTask; } public async Task DisposeAsync() { SqlConnection.ClearAllPools(); foreach (var database in _databases) await ExecuteAsync(Master(), $"IF DB_ID('{database}') IS NOT NULL BEGIN ALTER DATABASE [{database}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{database}] END"); } protected override async Task NewDatabaseAsync(string suffix) { var name = $"redb_init_{Guid.NewGuid().ToString("N")[..12]}_{suffix}"; _databases.Add(name); await ExecuteAsync(Master(), $"CREATE DATABASE [{name}]"); return new SqlConnectionStringBuilder(_server) { InitialCatalog = name }.ConnectionString; } protected override ServiceProvider Build(string cs) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => options.UseMsSql(cs).Configure(c => c.CacheDomain = $"init-{Guid.NewGuid():N}")); return services.BuildServiceProvider(); } protected override async Task ScalarAsync(string cs, string sql) { await using var connection = new SqlConnection(cs); await connection.OpenAsync(); await using var command = new SqlCommand(sql, connection); return Convert.ToString(await command.ExecuteScalarAsync()); } protected override async Task> CatalogAsync(string cs) { var lines = new List(); await using var connection = new SqlConnection(cs); await connection.OpenAsync(); foreach (var sql in new[] { "SELECT 'sequence ' + name FROM sys.sequences ORDER BY 1", "SELECT 'fk ' + name + ' disabled=' + CAST(is_disabled AS varchar(1)) FROM sys.foreign_keys ORDER BY 1", "SELECT 'trigger ' + name + ' disabled=' + CAST(is_disabled AS varchar(1)) FROM sys.triggers ORDER BY 1", "SELECT 'module ' + dbo.pvt_module_version()", }) { await using var command = new SqlCommand(sql, connection); await using var reader = await command.ExecuteReaderAsync(); while (await reader.ReadAsync()) lines.Add(reader.GetString(0)); } return lines; } private string Master() => new SqlConnectionStringBuilder(_server) { InitialCatalog = "master" }.ConnectionString; private static async Task ExecuteAsync(string cs, string sql) { await using var connection = new SqlConnection(cs); await connection.OpenAsync(); await using var command = new SqlCommand(sql, connection); await command.ExecuteNonQueryAsync(); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemaMissingTests.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/MsSqlSchemaMissingTests.cs ---- using Microsoft.Data.SqlClient; using redb.Core.Extensions; using redb.MSSql.Data; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; public class MsSqlSchemaMissingTests : SchemaMissingTestsBase { private readonly string _name = $"redb_probe_empty_{Guid.NewGuid():N}"[..40]; protected override async Task CreateEmptyDatabaseAsync() { await using var admin = new SqlRedbConnection(ConnString("MSSql")); await admin.ExecuteAsync($"CREATE DATABASE [{_name}]"); return new SqlConnectionStringBuilder(ConnString("MSSql")) { InitialCatalog = _name }.ConnectionString; } protected override async Task DropDatabaseAsync(string connectionString) { SqlConnection.ClearPool(new SqlConnection(connectionString)); await using var admin = new SqlRedbConnection(ConnString("MSSql")); await admin.ExecuteAsync( $"IF DB_ID(N'{_name}') IS NOT NULL BEGIN " + $"ALTER DATABASE [{_name}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{_name}]; END"); } protected override void UseProvider(RedbOptionsBuilder options, string connectionString) => options.UseMsSql(connectionString); } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemaUpgradeTests.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/MsSqlSchemaUpgradeTests.cs ---- using Microsoft.Data.SqlClient; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core; using redb.Core.Data; using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; /// /// Owns database redb_upgrade_<run> and login redb_noddl_<run> on the test server. See the /// PostgreSQL twin for why it is not in a collection. /// public class MsSqlSchemaUpgradeTests : SchemaUpgradeTestsBase { public MsSqlSchemaUpgradeTests(SchemaUpgradeCleanup cleanup) : base(cleanup) { } // Virtual so the Pro subclass owns its own database and login: both classes damage the // schema on purpose and must not share it. protected virtual string DatabaseName => $"redb_upgrade_{RunSuffix}"; protected virtual string FreshDatabaseName => $"redb_upgrade_fresh_{RunSuffix}"; protected virtual string RestrictedLogin => $"redb_noddl_{RunSuffix}"; private const string RestrictedPassword = "NoDdl!12345"; private static readonly string AdminBase = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; protected override string OwnerConnectionString => new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = DatabaseName }.ConnectionString; protected override string FreshDatabaseConnectionString => new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = FreshDatabaseName }.ConnectionString; protected override async Task RecreateFreshDatabaseAsync() { await ExecAdminAsync("master", $"IF DB_ID(N'{FreshDatabaseName}') IS NOT NULL BEGIN " + $"ALTER DATABASE [{FreshDatabaseName}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; " + $"DROP DATABASE [{FreshDatabaseName}]; END"); await ExecAdminAsync("master", $"CREATE DATABASE [{FreshDatabaseName}]"); } protected override string RestrictedConnectionString => new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = DatabaseName, UserID = RestrictedLogin, Password = RestrictedPassword }.ConnectionString; protected override void UseProvider(RedbOptionsBuilder options, string connectionString) => options.UseMsSql(connectionString); private static async Task ExecAdminAsync(string database, string sql) { var cs = new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = database, Pooling = false }.ConnectionString; await using var conn = new SqlConnection(cs); await conn.OpenAsync(); await using var cmd = conn.CreateCommand(); cmd.CommandText = sql; await cmd.ExecuteNonQueryAsync(); } private static async Task ScalarAdminAsync(string database, string sql) { var cs = new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = database, Pooling = false }.ConnectionString; await using var conn = new SqlConnection(cs); await conn.OpenAsync(); await using var cmd = conn.CreateCommand(); cmd.CommandText = sql; var v = await cmd.ExecuteScalarAsync(); return v is null or DBNull ? default : (T)v; } protected override async Task PrepareDatabaseAndLoginAsync() { if (await ScalarAdminAsync("master", $"SELECT 1 FROM sys.databases WHERE name = '{DatabaseName}'") is null) await ExecAdminAsync("master", $"CREATE DATABASE [{DatabaseName}]"); if (await ScalarAdminAsync("master", $"SELECT 1 FROM sys.server_principals WHERE name = '{RestrictedLogin}'") is null) await ExecAdminAsync("master", $"CREATE LOGIN [{RestrictedLogin}] WITH PASSWORD = '{RestrictedPassword}', CHECK_POLICY = OFF"); if (await ScalarAdminAsync(DatabaseName, $"SELECT 1 FROM sys.database_principals WHERE name = '{RestrictedLogin}'") is null) await ExecAdminAsync(DatabaseName, $"CREATE USER [{RestrictedLogin}] FOR LOGIN [{RestrictedLogin}]"); } protected override async Task DropOwnedServerObjectsAsync() { SqlConnection.ClearAllPools(); foreach (var database in new[] { DatabaseName, FreshDatabaseName, ContainedDatabaseName }) await ExecAdminAsync("master", $"IF DB_ID(N'{database}') IS NOT NULL BEGIN " + $"ALTER DATABASE [{database}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; " + $"DROP DATABASE [{database}]; END"); await ExecAdminAsync("master", $"IF EXISTS (SELECT 1 FROM sys.server_principals WHERE name = N'{RestrictedLogin}') DROP LOGIN [{RestrictedLogin}]"); } protected override async Task GrantRestrictedAsync() { // db_datareader + db_datawriter + EXECUTE: reads, writes, calls functions. No CREATE, no // ALTER, no DROP — the shape a DBA leaves an application in after installation. await ExecAdminAsync(DatabaseName, $""" ALTER ROLE db_datareader ADD MEMBER [{RestrictedLogin}]; ALTER ROLE db_datawriter ADD MEMBER [{RestrictedLogin}]; GRANT EXECUTE TO [{RestrictedLogin}]; """); } protected override Task SetDeployedModuleVersionAsync(string version) => ExecAdminAsync(DatabaseName, $""" ALTER FUNCTION dbo.pvt_module_version() RETURNS nvarchar(50) WITH SCHEMABINDING AS BEGIN RETURN N'{version}'; END """); protected override async Task ReadDeployedModuleVersionAsync() => (await ScalarAdminAsync(DatabaseName, "SELECT dbo.pvt_module_version()"))!; protected override Task SetDeployedModuleCompatAsync(string? compat) => ExecAdminAsync(DatabaseName, compat is null ? "DROP FUNCTION IF EXISTS dbo.pvt_module_compat" : $""" CREATE OR ALTER FUNCTION dbo.pvt_module_compat() RETURNS nvarchar(50) WITH SCHEMABINDING AS BEGIN RETURN N'{compat}'; END """); /// The refusing guard sets NOEXEC ON on its session (it stops SSMS and sqlcmd): no pooled session keeps it. protected override Task AfterRefusedScriptAsync() { SqlConnection.ClearAllPools(); return Task.CompletedTask; } protected override async Task DropV4UpgradeDdlAsync() { await ExecAdminAsync(DatabaseName, """ IF EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'dbo._values') AND name = N'UIX__values__structure_unique') DROP INDEX [UIX__values__structure_unique] ON [dbo].[_values]; IF EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'dbo._objects') AND name = N'UIX__objects__scheme_unique') DROP INDEX [UIX__objects__scheme_unique] ON [dbo].[_objects]; IF COL_LENGTH('dbo._values', '_unique') IS NOT NULL ALTER TABLE [dbo].[_values] DROP COLUMN [_unique]; IF COL_LENGTH('dbo._structures', '_unique') IS NOT NULL ALTER TABLE [dbo].[_structures] DROP COLUMN [_unique]; IF COL_LENGTH('dbo._structures', '_unique_version') IS NOT NULL ALTER TABLE [dbo].[_structures] DROP COLUMN [_unique_version]; IF COL_LENGTH('dbo._structures', '_lazy') IS NOT NULL ALTER TABLE [dbo].[_structures] DROP COLUMN [_lazy]; IF COL_LENGTH('dbo._scheme_metadata_cache', '_unique') IS NOT NULL ALTER TABLE [dbo].[_scheme_metadata_cache] DROP COLUMN [_unique]; IF COL_LENGTH('dbo._scheme_metadata_cache', '_unique_version') IS NOT NULL ALTER TABLE [dbo].[_scheme_metadata_cache] DROP COLUMN [_unique_version]; IF COL_LENGTH('dbo._scheme_metadata_cache', '_lazy') IS NOT NULL ALTER TABLE [dbo].[_scheme_metadata_cache] DROP COLUMN [_lazy]; IF COL_LENGTH('dbo._objects', '_value_unique') IS NOT NULL ALTER TABLE [dbo].[_objects] DROP COLUMN [_value_unique]; IF EXISTS (SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'dbo._objects') AND name = N'IX__objects__value_string') DROP INDEX [IX__objects__value_string] ON [dbo].[_objects]; ALTER TABLE [dbo].[_objects] ALTER COLUMN [_value_string] NVARCHAR(MAX) NULL; """); } protected override async Task V4UpgradeDdlExistsAsync() { var present = await ScalarAdminAsync(DatabaseName, """ SELECT (SELECT COUNT(*) FROM sys.columns c JOIN sys.tables t ON t.object_id = c.object_id WHERE (t.name = '_values' AND c.name = '_unique') OR (t.name = '_structures' AND c.name IN ('_unique', '_unique_version', '_lazy')) OR (t.name = '_scheme_metadata_cache' AND c.name IN ('_unique', '_unique_version', '_lazy')) OR (t.name = '_objects' AND c.name = '_value_unique')) + (SELECT COUNT(*) FROM sys.indexes WHERE name IN ('UIX__values__structure_unique', 'UIX__objects__scheme_unique', 'IX__objects__value_string')) + (SELECT COUNT(*) FROM sys.columns WHERE object_id = OBJECT_ID('dbo._objects') AND name = '_value_string' AND max_length = 900) -- owner decision 2026-09-02: the unread full-text index must be GONE (counts as 0) + (SELECT COUNT(*) FROM sys.fulltext_indexes WHERE object_id = OBJECT_ID('dbo._values')) """); return Convert.ToInt64(present) == 12; } protected override async Task ApplyScriptAsOwnerAsync(IRedbContext ownerContext, string script) { // The same split the provider's start-up does: GO is a client-side batch separator. var batches = System.Text.RegularExpressions.Regex.Split(script, @"^\s*GO\s*$", System.Text.RegularExpressions.RegexOptions.Multiline | System.Text.RegularExpressions.RegexOptions.IgnoreCase); foreach (var batch in batches) { var trimmed = batch.Trim(); if (trimmed.Length > 0) await ownerContext.ExecuteAsync(trimmed); } } protected override async Task ReadSchemaFingerprintAsync() => (await ScalarAdminAsync(DatabaseName, """ SELECT CONCAT( (SELECT COUNT(*) FROM sys.foreign_keys), '|', (SELECT CONVERT(nvarchar(40), current_value) FROM sys.sequences WHERE name = N'global_identity'), '|', (SELECT COUNT(*) FROM sys.triggers), '|', (SELECT COUNT(*) FROM sys.objects WHERE type IN ('P', 'FN', 'IF', 'TF')), '|', (SELECT COUNT(*) FROM dbo._objects), '|', (SELECT COUNT(*) FROM dbo._values), '|', (SELECT COUNT(*) FROM dbo._schemes), '|', (SELECT COUNT(*) FROM dbo._users)) """))!; /// /// sqlcmd and SSMS: every batch on one session, an error does not stop the next batch. Only the NOEXEC the guard /// sets keeps the batches after it from running. /// protected override async Task> RunScriptByHandAsync(string script) { var errors = new List(); var cs = new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = DatabaseName, Pooling = false }.ConnectionString; await using var conn = new SqlConnection(cs); await conn.OpenAsync(); foreach (var batch in System.Text.RegularExpressions.Regex.Split(script, @"^\s*GO\s*$", System.Text.RegularExpressions.RegexOptions.Multiline | System.Text.RegularExpressions.RegexOptions.IgnoreCase)) { var trimmed = batch.Trim(); if (trimmed.Length == 0) continue; await using var cmd = conn.CreateCommand(); cmd.CommandText = trimmed; cmd.CommandTimeout = 300; try { await cmd.ExecuteNonQueryAsync(); } catch (SqlException ex) { errors.Add(ex.Message); } } return errors; } [Fact] public async Task FreshDatabase_Saves_KeepTheForeignKeysTrusted() { // The bulk copy of new objects and values checks the foreign keys (CheckConstraints). Without the hint SQL // Server skipped them and marked every foreign key of the table untrusted after the first save. await RecreateFreshDatabaseAsync(); await using var sp = Build(FreshDatabaseConnectionString, autoApply: true, cacheDomain: $"trusted-fk-{Guid.NewGuid():N}"); var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); var root = new redb.Core.Models.Entities.TreeRedbObject { name = "fk-root", Props = new redb.Tests.Integration.Models.LazyNodeProps { Label = "root" } }; root.id = await redb.SaveAsync(root); await redb.CreateChildAsync(new redb.Core.Models.Entities.TreeRedbObject { name = "fk-child", Props = new redb.Tests.Integration.Models.LazyNodeProps { Label = "child", Next = new redb.Core.Models.Entities.RedbObject { id = root.id } } }, root); var keys = Convert.ToInt32(await ScalarAdminAsync(FreshDatabaseName, "SELECT COUNT(*) FROM sys.foreign_keys WHERE OBJECT_NAME(parent_object_id) IN ('_objects', '_values')")); var untrusted = Convert.ToInt32(await ScalarAdminAsync(FreshDatabaseName, "SELECT COUNT(*) FROM sys.foreign_keys WHERE OBJECT_NAME(parent_object_id) IN ('_objects', '_values') AND is_not_trusted = 1")); keys.Should().BeGreaterThan(0); untrusted.Should().Be(0, "a save checks the keys, so the server keeps trusting them"); } [Fact] public async Task ModuleUpgrade_DisablesTheNodePermissionTrigger_AsOnPostgres() { // A database of a version before 0.2.41: the trigger enabled, the module behind. The start applies the module, // which disables the trigger as the PostgreSQL schema has it: the bulk copy fires triggers from 0.2.41 on. await ExecAdminAsync(DatabaseName, "ALTER TABLE [dbo].[_objects] ENABLE TRIGGER [tr_auto_create_node_permissions]"); await SetDeployedModuleVersionAsync("0.2.40"); await using (var sp = Build(OwnerConnectionString, autoApply: true, cacheDomain: $"trigger-upgrade-{Guid.NewGuid():N}")) await sp.GetRequiredService().InitializeAsync(ensureCreated: true); (await ReadDeployedModuleVersionAsync()).Should().NotBe("0.2.40"); var disabled = Convert.ToInt32(await ScalarAdminAsync(DatabaseName, "SELECT OBJECTPROPERTY(OBJECT_ID(N'dbo.tr_auto_create_node_permissions'), 'ExecIsTriggerDisabled')")); disabled.Should().Be(1); } protected virtual string ContainedDatabaseName => $"redb_upgrade_contained_{RunSuffix}"; private const string ContainedUser = "redb_contained"; private const string ContainedPassword = "Contained!12345"; [Fact] public async Task ContainedUser_DeployedDatabase_Starts_AndSchemaWorkNamesTheWayOut() { // The DBA scenario: the schema is deployed by a privileged login, the application connects as a user of the // database alone, with no access to master where the schema lock lives. A database in step needs no lock, so // the start goes through; schema work stops with an error that names both ways out. // A server setting, not the test's to change: checked, and a server without it fails the test loudly. var containedAuth = await ScalarAdminAsync("master", "SELECT CAST(value_in_use AS int) FROM sys.configurations WHERE name = 'contained database authentication'"); Convert.ToInt32(containedAuth).Should().Be(1, "this test needs contained database authentication on the test server; enable it once with " + "EXEC sp_configure 'contained database authentication', 1; RECONFIGURE;"); await ExecAdminAsync("master", $"IF DB_ID(N'{ContainedDatabaseName}') IS NOT NULL BEGIN " + $"ALTER DATABASE [{ContainedDatabaseName}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; " + $"DROP DATABASE [{ContainedDatabaseName}]; END"); await ExecAdminAsync("master", $"CREATE DATABASE [{ContainedDatabaseName}] CONTAINMENT = PARTIAL"); var ownerCs = new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = ContainedDatabaseName }.ConnectionString; await using (var sp = Build(ownerCs, autoApply: true, cacheDomain: $"contained-owner-{Guid.NewGuid():N}")) await sp.GetRequiredService().InitializeAsync(ensureCreated: true); await ExecAdminAsync(ContainedDatabaseName, $""" CREATE USER [{ContainedUser}] WITH PASSWORD = '{ContainedPassword}'; ALTER ROLE db_datareader ADD MEMBER [{ContainedUser}]; ALTER ROLE db_datawriter ADD MEMBER [{ContainedUser}]; GRANT EXECUTE TO [{ContainedUser}]; """); var userCs = new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = ContainedDatabaseName, UserID = ContainedUser, Password = ContainedPassword }.ConnectionString; var openMaster = async () => { await using var master = new SqlConnection(new SqlConnectionStringBuilder(userCs) { InitialCatalog = "master" }.ConnectionString); await master.OpenAsync(); }; await openMaster.Should().ThrowAsync("the user exists in its database only"); await using (var sp = Build(userCs, autoApply: true, cacheDomain: $"contained-user-{Guid.NewGuid():N}")) await sp.GetRequiredService().InitializeAsync(ensureCreated: true); await ExecAdminAsync(ContainedDatabaseName, """ ALTER FUNCTION dbo.pvt_module_version() RETURNS nvarchar(50) WITH SCHEMABINDING AS BEGIN RETURN N'0.0.0-test'; END """); await using (var sp = Build(userCs, autoApply: true, cacheDomain: $"contained-user-{Guid.NewGuid():N}")) { var start = () => sp.GetRequiredService().InitializeAsync(ensureCreated: true); (await start.Should().ThrowAsync()) .Which.Message.Should().Contain("access to master").And.Contain("GetUpgradeScript"); } } [Fact] public async Task Upgrade_RefusesToNarrowValueString_WhileLongValuesExist() { // Owner decision 2026-09-02: _value_string is an identifier column (450); long text belongs // in _note. A database already holding longer values must not be truncated silently - the // upgrade stops, names the offenders query, and changes nothing. await RecreateFreshDatabaseAsync(); await using (var sp = Build(FreshDatabaseConnectionString, autoApply: true)) await sp.GetRequiredService().InitializeAsync(ensureCreated: true); // The pre-decision shape: the MAX column with one over-long value, module behind. await ExecAdminAsync(FreshDatabaseName, "DROP INDEX [IX__objects__value_string] ON [dbo].[_objects]"); await ExecAdminAsync(FreshDatabaseName, "ALTER TABLE [dbo].[_objects] ALTER COLUMN [_value_string] NVARCHAR(MAX) NULL"); await ExecAdminAsync(FreshDatabaseName, """ INSERT INTO [dbo].[_objects] (_id, _id_scheme, _id_owner, _id_who_change, _name, _value_string) SELECT 900000001, (SELECT TOP 1 _id FROM [dbo].[_schemes] ORDER BY _id), (SELECT TOP 1 _id FROM [dbo].[_users] ORDER BY _id), (SELECT TOP 1 _id FROM [dbo].[_users] ORDER BY _id), N'long-value-string', REPLICATE(N'x', 500) """); await ExecAdminAsync(FreshDatabaseName, """ ALTER FUNCTION dbo.pvt_module_version() RETURNS nvarchar(50) WITH SCHEMABINDING AS BEGIN RETURN N'0.0.0-test'; END """); await using (var sp = Build(FreshDatabaseConnectionString, autoApply: true)) { var act = async () => await sp.GetRequiredService().InitializeAsync(); (await act.Should().ThrowAsync("silent truncation is not an option")) .Which.ToString().Should().Contain("_value_string", "the refusal names the column and the way out"); } // The way out the message names: move the text to _note, start again. await ExecAdminAsync(FreshDatabaseName, "UPDATE [dbo].[_objects] SET _note = _value_string, _value_string = NULL WHERE _id = 900000001"); await using (var sp = Build(FreshDatabaseConnectionString, autoApply: true)) await sp.GetRequiredService().InitializeAsync(); (await ScalarAdminAsync(FreshDatabaseName, "SELECT CAST(COL_LENGTH('dbo._objects', '_value_string') AS INT)")) .Should().Be(900, "the column is NVARCHAR(450) once the data allows it"); (await ScalarAdminAsync(FreshDatabaseName, "SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(N'dbo._objects') AND name = N'IX__objects__value_string'")) .Should().NotBeNull("and the index the other providers always had exists now"); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemeLoadValidationTests.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/MsSqlSchemeLoadValidationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlSchemeLoadValidationTests : SchemeLoadValidationTestsBase { public MsSqlSchemeLoadValidationTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemeNamingTests.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/MsSqlSchemeNamingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlSchemeNamingTests : SchemeNamingTestsBase { public MsSqlSchemeNamingTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSchemeRenameTests.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/MsSqlSchemeRenameTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlSchemeRenameTests : SchemeRenameTestsBase { public MsSqlSchemeRenameTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSmallSaveTimingTests.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/MsSqlSmallSaveTimingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; using Xunit.Abstractions; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlSmallSaveTimingTests : SmallSaveTimingTestsBase { public MsSqlSmallSaveTimingTests(MsSqlFixture fixture, ITestOutputHelper output) : base(fixture.ServiceProvider, output) { } protected override string? PlanCacheReportSql => MsSqlPlanCache.InsertReport; } /// The cached plans of the insert statements of the current database (read only, needs VIEW SERVER STATE). internal static class MsSqlPlanCache { public const string InsertReport = """ SELECT s.Statement, COUNT(*) AS Plans, SUM(CAST(s.usecounts AS bigint)) AS Executions, LEFT(MIN(s.text), 400) AS Sample FROM ( SELECT CASE WHEN t.text LIKE '%INSERT INTO _values (_id, _id_structure%' THEN 'INSERT _values' WHEN t.text LIKE '%INSERT INTO _objects (_id, _id_parent%' THEN 'INSERT _objects' WHEN t.text LIKE '%insert bulk%' THEN 'insert bulk' END AS Statement, cp.usecounts, t.text FROM sys.dm_exec_cached_plans cp CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) t CROSS APPLY sys.dm_exec_plan_attributes(cp.plan_handle) pa WHERE pa.attribute = 'dbid' AND CAST(pa.value AS int) = DB_ID() AND t.text NOT LIKE '%dm_exec_cached_plans%' ) s WHERE s.Statement IS NOT NULL GROUP BY s.Statement """; } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSoftDeleteProcedureTests.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/MsSqlSoftDeleteProcedureTests.cs ---- using Microsoft.Data.SqlClient; using Microsoft.Extensions.Configuration; using redb.Core.Models.Entities; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.MsSql; /// /// sp_mark_for_deletion runs under SET XACT_ABORT ON (trash review, 2026-09-14). Without it a client /// cancel or a command timeout arriving inside the procedure's transaction bypasses CATCH and leaves the /// transaction open on the session - after the connection returns to the pool as well - so every later /// statement of that session runs inside it and is rolled back with it. The pin blocks the procedure on /// a row lock held by another session, lets the command time out right there, and checks the session. /// [Collection("MsSql")] public class MsSqlSoftDeleteProcedureTests { private readonly MsSqlFixture _fixture; public MsSqlSoftDeleteProcedureTests(MsSqlFixture fixture) => _fixture = fixture; private static string ConnString() => new SqlConnectionStringBuilder( new ConfigurationBuilder() .SetBasePath(AppContext.BaseDirectory) .AddJsonFile("appsettings.json") .Build() .GetConnectionString("MSSql")!) { Pooling = false }.ConnectionString; [Fact] public async Task MarkForDeletion_TimedOutInsideItsTransaction_LeavesNoTransactionOnTheSession() { await _fixture.Redb.SyncSchemeAsync(); var id = await _fixture.Redb.SaveAsync(new RedbObject { name = "trash-xact-abort-probe", Props = new TrashTargetProps { Title = "probe" } }); var userId = _fixture.Redb.SecurityContext.GetEffectiveUser().Id; await using var holder = new SqlConnection(ConnString()); await holder.OpenAsync(); await using var held = (SqlTransaction)await holder.BeginTransactionAsync(); await using (var hold = new SqlCommand("UPDATE [dbo].[_objects] SET [_note] = N'held' WHERE [_id] = @id", holder, held)) { hold.Parameters.AddWithValue("@id", id); await hold.ExecuteNonQueryAsync(); } await using var session = new SqlConnection(ConnString()); await session.OpenAsync(); await using (var mark = new SqlCommand( "DECLARE @trash BIGINT, @marked BIGINT; EXEC [dbo].[sp_mark_for_deletion] @ids, @user, NULL, @trash OUTPUT, @marked OUTPUT;", session) { CommandTimeout = 2 }) { mark.Parameters.AddWithValue("@ids", id.ToString()); mark.Parameters.AddWithValue("@user", userId); var act = async () => await mark.ExecuteNonQueryAsync(); await act.Should().ThrowAsync("the procedure waits on the held row until the command times out"); } await using (var probe = new SqlCommand("SELECT @@TRANCOUNT", session)) Convert.ToInt32(await probe.ExecuteScalarAsync()).Should().Be(0, "a timeout inside the procedure must roll its transaction back, not leave it on the session"); await held.RollbackAsync(); (await _fixture.Redb.Context.ExecuteScalarAsync($"SELECT _id_scheme FROM _objects WHERE _id = {id}")) .Should().NotBe(-10, "the timed-out mark changed nothing"); await _fixture.Redb.DeleteAsync(id); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlStringMatchContractTests.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/MsSqlStringMatchContractTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlStringMatchContractTests : MsSqlStringMatchContractTestsBase { public MsSqlStringMatchContractTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSubSecondUpdateTests.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/MsSqlSubSecondUpdateTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; public class MsSqlSubSecondUpdateTests : SubSecondUpdateTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTagsFieldTests.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/MsSqlTagsFieldTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlTagsFieldTests : TagsFieldTestsBase { public MsSqlTagsFieldTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTemporalRoundTripTests.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/MsSqlTemporalRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlTemporalRoundTripTests : TemporalRoundTripTestsBase { public MsSqlTemporalRoundTripTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTimeTicksTests.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/MsSqlTimeTicksTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlTimeTicksTests : TimeTicksTestsBase { public MsSqlTimeTicksTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTransactionIsolationTests.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/MsSqlTransactionIsolationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlTransactionIsolationTests : TransactionIsolationTestsBase { public MsSqlTransactionIsolationTests(MsSqlFixture fixture) : base(fixture.Redb) { } protected override string? ReadLevelSql => """ SELECT CASE transaction_isolation_level WHEN 1 THEN 'read uncommitted' WHEN 2 THEN 'read committed' WHEN 3 THEN 'repeatable read' WHEN 4 THEN 'serializable' WHEN 5 THEN 'snapshot' END FROM sys.dm_exec_sessions WHERE session_id = @@SPID """; } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTrashBackgroundServiceTests.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/MsSqlTrashBackgroundServiceTests.cs ---- using Microsoft.Data.SqlClient; using redb.Core.Extensions; using redb.MSSql.Data; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; public class MsSqlTrashBackgroundServiceTests : TrashBackgroundServiceTestsBase { private readonly string _name = $"redb_probe_trashbg_{Guid.NewGuid():N}"[..40]; protected override async Task CreateEmptyDatabaseAsync() { await using var admin = new SqlRedbConnection(ConnString("MSSql")); await admin.ExecuteAsync($"CREATE DATABASE [{_name}]"); return new SqlConnectionStringBuilder(ConnString("MSSql")) { InitialCatalog = _name }.ConnectionString; } protected override async Task DropDatabaseAsync(string connectionString) { SqlConnection.ClearPool(new SqlConnection(connectionString)); await using var admin = new SqlRedbConnection(ConnString("MSSql")); await admin.ExecuteAsync( $"IF DB_ID(N'{_name}') IS NOT NULL BEGIN " + $"ALTER DATABASE [{_name}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{_name}]; END"); } protected override void UseProvider(RedbOptionsBuilder options, string connectionString) => options.UseMsSql(connectionString); } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTrashPurgeTests.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/MsSqlTrashPurgeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlTrashPurgeTests : TrashPurgeTestsBase { public MsSqlTrashPurgeTests(MsSqlFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTrashedReferenceTargetTests.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/MsSqlTrashedReferenceTargetTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; public class MsSqlTrashedReferenceTargetTests : TrashedReferenceTargetTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeDistinctTests.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/MsSqlTreeDistinctTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlTreeDistinctTests : TreeDistinctTestsBase { public MsSqlTreeDistinctTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeLevelAnalyticsTests.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/MsSqlTreeLevelAnalyticsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlTreeLevelAnalyticsTests : TreeLevelAnalyticsTestsBase { public MsSqlTreeLevelAnalyticsTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeQueryShapesTests.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/MsSqlTreeQueryShapesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlTreeQueryShapesTests : TreeQueryShapesTestsBase { public MsSqlTreeQueryShapesTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeSourceFormTests.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/MsSqlTreeSourceFormTests.cs ---- using redb.Core; using redb.Core.Models.Entities; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Helpers; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.MsSql; /// /// Free SQL Server module: a tree query with a Props filter calls the walk (pvt_tree_descendants) once and reads the /// values of each object through OUTER APPLY. The pivot joined to the objects ran the walk on both sides, and a filter /// over a 100 thousand node subtree took 3.3 s instead of 1.8 s (E204). /// [Collection("MsSql")] public class MsSqlTreeSourceFormTests { private readonly IRedbService _redb; public MsSqlTreeSourceFormTests(MsSqlFixture fixture) => _redb = fixture.Redb; [Fact] public async Task TreeQueryWithAPropsFilter_WalksTheTreeOnce() { await _redb.SyncSchemeAsync(); var root = new TreeRedbObject { name = "form-" + Guid.NewGuid().ToString("N")[..8], Props = TestDataFactory.CreateEmployee(1).Props }; root.id = await _redb.SaveAsync(root); var sql = await _redb.TreeQuery(root.id) .Where(e => e.Salary >= 60000m && e.Salary < 90000m) .ToSqlStringAsync(); sql.Should().Contain("OUTER APPLY ("); System.Text.RegularExpressions.Regex.Matches(sql, @"pvt_tree_descendants\(").Count.Should().Be(1, sql); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeSqlPreviewTests.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/MsSqlTreeSqlPreviewTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlTreeSqlPreviewTests : TreeSqlPreviewTestsBase { public MsSqlTreeSqlPreviewTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTreeTests.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/MsSqlTreeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlTreeTests : TreeTestsBase { public MsSqlTreeTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlTypeMigrationSyncTests.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/MsSqlTypeMigrationSyncTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlTypeMigrationSyncTests : TypeMigrationSyncTestsBase { public MsSqlTypeMigrationSyncTests(MsSqlFixture fixture) : base(fixture.Redb) { } protected override string TextTypeName => "NVARCHAR(50)"; protected override string BoolTrue => "1"; protected override string BoolFalse => "0"; } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlUniqueKeyTests.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/MsSqlUniqueKeyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlUniqueKeyTests : UniqueKeyTestsBase { public MsSqlUniqueKeyTests(MsSqlFixture fixture) : base(fixture.Redb) { } protected override string BoolTrue => "1"; } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlUnregisteredTreeTargetTests.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/MsSqlUnregisteredTreeTargetTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlUnregisteredTreeTargetTests : UnregisteredTreeTargetTestsBase { public MsSqlUnregisteredTreeTargetTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlUntypedLinkedObjectTests.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/MsSqlUntypedLinkedObjectTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.MSSql.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; public class MsSqlUntypedLinkedObjectTests : UntypedLinkedObjectTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlUserConfigurationServiceTests.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/MsSqlUserConfigurationServiceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlUserConfigurationServiceTests : UserConfigurationServiceTestsBase { public MsSqlUserConfigurationServiceTests(MsSqlFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlValueOnlyObjectSaveTests.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/MsSqlValueOnlyObjectSaveTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlValueOnlyObjectSaveTests : ValueOnlyObjectSaveTestsBase { public MsSqlValueOnlyObjectSaveTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlValueUniqueTests.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/MsSqlValueUniqueTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlValueUniqueTests : ValueUniqueTestsBase { public MsSqlValueUniqueTests(MsSqlFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlValuesFkIndexesTests.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/MsSqlValuesFkIndexesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlValuesFkIndexesTests : ValuesFkIndexesTestsBase { public MsSqlValuesFkIndexesTests(MsSqlFixture fixture) : base(fixture.Redb) { } protected override async Task IndexExistsAsync(string indexName) => await Redb.Context.ExecuteScalarAsync( "SELECT COUNT(*) FROM sys.indexes WHERE name = '{0}'".Replace("{0}", indexName)) > 0; } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlWhereTests.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/MsSqlWhereTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlWhereTests : WhereTestsBase { public MsSqlWhereTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlWindowTests.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/MsSqlWindowTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlWindowTests : WindowTestsBase { public MsSqlWindowTests(MsSqlFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAbsentFieldConsistencyTests.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/MsSqlPro/MsSqlProAbsentFieldConsistencyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProAbsentFieldConsistencyTests : AbsentFieldConsistencyTestsBase { public MsSqlProAbsentFieldConsistencyTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAbsentValuesTests.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/MsSqlPro/MsSqlProAbsentValuesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProAbsentValuesTests : AbsentValuesTestsBase { public MsSqlProAbsentValuesTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAggregatePathTests.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/MsSqlPro/MsSqlProAggregatePathTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProAggregatePathTests : AggregatePathTestsBase { public MsSqlProAggregatePathTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAggregatePreviewTests.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/MsSqlPro/MsSqlProAggregatePreviewTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProAggregatePreviewTests : ProAggregatePreviewTestsBase { public MsSqlProAggregatePreviewTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAggregationOverArrayTests.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/MsSqlPro/MsSqlProAggregationOverArrayTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProAggregationOverArrayTests : AggregationOverArrayTestsBase { public MsSqlProAggregationOverArrayTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAggregationTests.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/MsSqlPro/MsSqlProAggregationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProAggregationTests : AggregationTestsBase { public MsSqlProAggregationTests(MsSqlProFixture fixture) : base(fixture.Redb, isPro: true) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAmbientTransactionTests.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/MsSqlPro/MsSqlProAmbientTransactionTests.cs ---- using redb.Core.Data; using redb.MSSql.Data; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProAmbientTransactionTests : AmbientTransactionTestsBase { public MsSqlProAmbientTransactionTests(MsSqlProFixture fixture) : base(fixture.ServiceProvider) { } protected override string CreateProbeTableSql => "IF OBJECT_ID(N'dbo.ambient_tx_rows', N'U') IS NULL CREATE TABLE dbo.ambient_tx_rows (tag nvarchar(100) NOT NULL);"; protected override string SlowStatementSql => "WAITFOR DELAY '00:00:02'; SELECT 1"; protected override IRedbConnection CreateStandaloneConnection(IServiceProvider services, bool differentSessionSettings) => new SqlRedbConnection(ConnString("MSSql"), lazyReferences: differentSessionSettings); } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProAnalyticsTelemetryTests.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/MsSqlPro/MsSqlProAnalyticsTelemetryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProAnalyticsTelemetryTests : AnalyticsTelemetryTestsBase { public MsSqlProAnalyticsTelemetryTests(MsSqlProFixture fixture) : base(fixture.Redb) { } protected override int CommandsPerCall => 1; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayAnyTests.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/MsSqlPro/MsSqlProArrayAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProArrayAnyTests : ArrayAnyTestsBase { public MsSqlProArrayAnyTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayContainsFoldTests.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/MsSqlPro/MsSqlProArrayContainsFoldTests.cs ---- using System.Text.RegularExpressions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.MsSqlPro; /// /// An OR of several Contains over one array reads the elements once, with the values in a list: one EXISTS with IN, not /// one EXISTS per value (E169: 260 -> 140 ms). The answers are held equal to the other form by /// PvtPrefilterEquivalenceTestsBase; this pins the shape of the statement with the planner on. /// [Collection("MsSqlPro")] public class MsSqlProArrayContainsFoldTests { private readonly redb.Core.IRedbService _redb; public MsSqlProArrayContainsFoldTests(MsSqlProFixture fixture) => _redb = fixture.Redb; [Fact] public async Task OrOfContainsOverOneArray_IsOneExistsWithTheValuesInAList() { var restore = _redb.Configuration.EnablePvtPrefilter; try { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var sql = await _redb.Query() .Where(e => e.Skills != null && (e.Skills.Contains("C#") || e.Skills.Contains("Python") || e.Skills.Contains("SQL"))) .Take(100) .ToSqlStringAsync(); Regex.Matches(sql, @"_array_index IS NOT NULL AND a\._\w+ = ").Count.Should().Be(0, "no EXISTS per value:\n{0}", sql); Regex.Matches(sql, @"_array_index IS NOT NULL AND a\._\w+ IN \(").Count.Should().Be(1, "one read of the elements:\n{0}", sql); } finally { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayGroupByDeepTests.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/MsSqlPro/MsSqlProArrayGroupByDeepTests.cs ---- using redb.Core; using redb.Core.Models.Entities; using redb.Core.Query.Aggregation; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Helpers; using redb.Tests.Integration.Models; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProArrayGroupByDeepTests : ArrayGroupByDeepTestsBase { private readonly IRedbService _redb; public MsSqlProArrayGroupByDeepTests(MsSqlProFixture fixture) : base(fixture.Redb) => _redb = fixture.Redb; // Without a condition every element is read anyway: the flat grouping always takes hash joins, since with two fields // of an element the second one otherwise became a many-to-many merge join (E142). [Fact] public async Task UnconditionedGrouping_CarriesTheHashJoinHint() { var sql = await _redb.Query() .GroupByArray(e => e.Contacts!.SelectMany(c => c.Metadata!), m => m.Label) .ToSqlStringAsync(g => new { Label = g.Key, Entries = Agg.Count(g), OfA = Agg.Count(g, m => m.Value == "a") }); sql.Should().Contain("OPTION (HASH JOIN, MAXDOP 1)").And.NotContain("IF (SELECT COUNT(*)"); } // With a condition the hint pays only over many objects and loses on a few, where nested loops read only the // matching elements. The streams source (planner on) puts the ids into a temporary table, and the batch picks the // statement by their count; the pivot source (planner off) has no count and runs without the hint. [Fact] public async Task ConditionedGrouping_TakesTheHintOnlyOverManyIds() { var sql = await _redb.Query() .Where(e => e.HomeAddress!.Building!.Floor > 10) .GroupByArray(e => e.Contacts!.SelectMany(c => c.Metadata!), m => m.Label) .ToSqlStringAsync(g => new { Label = g.Key, Entries = Agg.Count(g), OfA = Agg.Count(g, m => m.Value == "a") }); if (ProTestOptions.PvtPrefilter) { sql.Should().Contain("IF (SELECT COUNT(*) FROM (SELECT TOP (10000) _id FROM #redb_ids") .And.Contain(") >= 10000") .And.Contain("OPTION (HASH JOIN, MAXDOP 1);") .And.Contain("\nELSE\n"); sql.Split("FOR JSON PATH").Length.Should().Be(3, "both branches carry the grouping"); } else sql.Should().NotContain("HASH JOIN").And.NotContain("IF (SELECT COUNT(*)"); } // The branch with the hint runs over 10 000 ids, more than the test database holds, so this test lowers the threshold // for one call and the same few objects go through IF ... OPTION (HASH JOIN, MAXDOP 1). The collection runs its tests // one after another, and the threshold is put back in finally. Planner off: the pivot source has no count and no hint. [Fact] public async Task ConditionedGrouping_TheBranchWithTheHint_MatchesTheObjects() { var threshold = typeof(redb.MSSql.Pro.Query.ProQueryProvider).GetProperty( "ArrayGroupHashJoinThreshold", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)!; var before = (int)threshold.GetValue(null)!; threshold.SetValue(null, 1); try { await ConditionedGrouping_OverAFewObjects_MatchesTheObjects(); } finally { threshold.SetValue(null, before); } } // A condition over a few objects: the ids go into the temporary table (planner on) and the batch runs the grouping // without the hint. The answer is the same LINQ over the objects. [Fact] public async Task ConditionedGrouping_OverAFewObjects_MatchesTheObjects() { await _redb.SyncSchemeAsync(); var marker = "gh" + Guid.NewGuid().ToString("N")[..10]; var seeded = new List>(); for (var i = 0; i < 6; i++) { var e = TestDataFactory.CreateEmployee(i, firstName: $"{marker}-{i:D2}"); e.Props.Contacts![0].Metadata = [new TestContactDetail { Label = "work", Value = i % 2 == 0 ? "a" : "b" }]; e.Props.Contacts[1].Metadata = [new TestContactDetail { Label = "night", Value = "a" }]; e.Props.HomeAddress!.Building!.Floor = 5 + i * 3; await _redb.SaveAsync(e); seeded.Add(e); } var rows = await _redb.Query() .Where(e => e.FirstName.StartsWith(marker) && e.HomeAddress!.Building!.Floor > 10) .GroupByArray(e => e.Contacts!.SelectMany(c => c.Metadata!), m => m.Label) .SelectAsync(g => new { Label = g.Key, Entries = Agg.Count(g), OfA = Agg.Count(g, m => m.Value == "a") }); var expected = seeded.Where(e => e.Props.HomeAddress!.Building!.Floor > 10) .SelectMany(e => e.Props.Contacts!).SelectMany(c => c.Metadata ?? []) .GroupBy(m => m.Label) .Select(g => new { Label = g.Key, Entries = g.Count(), OfA = g.Count(m => m.Value == "a") }) .ToList(); expected.Should().NotBeEmpty("precondition: some of the objects match"); rows.Should().BeEquivalentTo(expected); } // The tree grouping does not: its node set may be a recursive CTE, and a hash-join hint leaves SQL Server without a // plan for it (error 8622). A change here is a change of the tree path, not of this test. [Fact] public async Task TreeGroupingStatement_CarriesNoJoinHint() { await _redb.SyncSchemeAsync(); var root = new TreeRedbObject { name = "hint-root-" + Guid.NewGuid().ToString("N")[..8], Props = TestDataFactory.CreateEmployee(0).Props }; root.id = await _redb.SaveAsync(root); var sql = await _redb.TreeQuery(root.id) .GroupByArray(e => e.Contacts!, c => c.Type) .ToSqlStringAsync(g => new { Type = g.Key, Count = Agg.Count(g), Verified = Agg.Count(g, c => c.IsVerified == true) }); sql.Should().NotContain("HASH JOIN"); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayGroupMetadataCacheTests.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/MsSqlPro/MsSqlProArrayGroupMetadataCacheTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProArrayGroupMetadataCacheTests : ArrayGroupMetadataCacheTestsBase { public MsSqlProArrayGroupMetadataCacheTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayOfClassesAnyTests.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/MsSqlPro/MsSqlProArrayOfClassesAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProArrayOfClassesAnyTests : ArrayOfClassesAnyTestsBase { public MsSqlProArrayOfClassesAnyTests(MsSqlProFixture fixture) : base(fixture.Redb) { } protected override bool ReadsAnyOverClasses => true; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayParentIndexTests.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/MsSqlPro/MsSqlProArrayParentIndexTests.cs ---- using Microsoft.Data.SqlClient; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.MsSqlPro; /// /// IX__values__array_parent_id is the leading column of IX__values__array_parent_index, which serves the same lookups, /// the check of FK__values__array_parent and the cascade trigger. A new database does not create it; the module drops it /// on an existing database only where an unfiltered index led by _array_parent_id remains. The test owns its database /// and makes the module apply again by removing its version function, as a database with an older module meets it. /// public class MsSqlProArrayParentIndexTests : IClassFixture { private const string Narrow = "IX__values__array_parent_id"; private const string Wide = "IX__values__array_parent_index"; private static readonly string AdminBase = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; private readonly SchemaUpgradeCleanup _cleanup; public MsSqlProArrayParentIndexTests(SchemaUpgradeCleanup cleanup) { _cleanup = cleanup; cleanup.Register(async () => { SqlConnection.ClearAllPools(); await AdminAsync("master", $"IF DB_ID(N'{DatabaseName}') IS NOT NULL BEGIN ALTER DATABASE [{DatabaseName}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{DatabaseName}]; END"); }); } private string DatabaseName => $"redb_arrparent_pro_{_cleanup.Suffix}"; [Fact] public async Task NarrowIndex_IsLeftOutOfANewDatabase_AndDroppedOnlyWhereTheWideOneExists() { var database = DatabaseName; await AdminAsync("master", $"IF DB_ID(N'{database}') IS NOT NULL BEGIN ALTER DATABASE [{database}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{database}]; END"); await AdminAsync("master", $"CREATE DATABASE [{database}]"); await StartAsync(database, ensureCreated: true); (await IndexExistsAsync(database, Narrow)).Should().BeFalse("a new database does not keep it"); (await IndexExistsAsync(database, Wide)).Should().BeTrue(); // An existing database of an older module: both indexes. The module drops the narrow one. await AdminAsync(database, $"CREATE INDEX [{Narrow}] ON [dbo].[_values]([_array_parent_id])"); await AdminAsync(database, "DROP FUNCTION dbo.pvt_module_version"); await StartAsync(database, ensureCreated: false); (await IndexExistsAsync(database, Narrow)).Should().BeFalse("the wider index serves its lookups, the key check and the trigger"); (await IndexExistsAsync(database, Wide)).Should().BeTrue(); // A database created by an old version without the wide index: the narrow one is the only index led by the parent. await AdminAsync(database, $"CREATE INDEX [{Narrow}] ON [dbo].[_values]([_array_parent_id])"); await AdminAsync(database, $"DROP INDEX [{Wide}] ON [dbo].[_values]"); await AdminAsync(database, "DROP FUNCTION dbo.pvt_module_version"); await StartAsync(database, ensureCreated: false); (await IndexExistsAsync(database, Narrow)).Should().BeTrue("without a wider index the key check and the trigger keep this one"); } private static async Task StartAsync(string database, bool ensureCreated) { var cs = new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = database }.ConnectionString; var license = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build()["Redb:License"]; var services = new ServiceCollection(); services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => { options.UseMsSql(cs).Configure(c => c.EnablePropsCache = false); if (!string.IsNullOrWhiteSpace(license)) options.WithLicense(license); }); await using var provider = services.BuildServiceProvider(); await provider.GetRequiredService().InitializeAsync(ensureCreated); SqlConnection.ClearAllPools(); } private static async Task IndexExistsAsync(string database, string name) { await using var conn = new SqlConnection(new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = database, Pooling = false }.ConnectionString); await conn.OpenAsync(); await using var cmd = conn.CreateCommand(); cmd.CommandText = "SELECT COUNT(*) FROM sys.indexes WHERE object_id = OBJECT_ID(N'dbo._values') AND name = @name"; cmd.Parameters.AddWithValue("@name", name); return (int)(await cmd.ExecuteScalarAsync())! > 0; } private static async Task AdminAsync(string database, string sql) { await using var conn = new SqlConnection(new SqlConnectionStringBuilder(AdminBase) { InitialCatalog = database, Pooling = false }.ConnectionString); await conn.OpenAsync(); await using var cmd = conn.CreateCommand(); cmd.CommandText = sql; cmd.CommandTimeout = 600; await cmd.ExecuteNonQueryAsync(); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayTests.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/MsSqlPro/MsSqlProArrayTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProArrayTests : ArrayTestsBase { public MsSqlProArrayTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProBareRedbObjectFieldTests.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/MsSqlPro/MsSqlProBareRedbObjectFieldTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProBareRedbObjectFieldTests : BareRedbObjectFieldTestsBase { public MsSqlProBareRedbObjectFieldTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProBaseFieldNameCollisionTests.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/MsSqlPro/MsSqlProBaseFieldNameCollisionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProBaseFieldNameCollisionTests : BaseFieldNameCollisionTestsBase { public MsSqlProBaseFieldNameCollisionTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProBulkInsertTimeoutTests.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/MsSqlPro/MsSqlProBulkInsertTimeoutTests.cs ---- using System.Diagnostics; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core; using redb.Core.Models.Configuration; using redb.Core.Models.Contracts; using redb.Core.Models.Entities; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.MsSqlPro; /// /// The SqlBulkCopy of AddNewObjectsAsync waits for a lock that another session holds on _values. Without /// BulkInsertTimeout it gives up after the driver's 30 seconds whatever the connection string says; with the option it /// waits as long as configured. The wait costs the server nothing: one table lock, no load. 300 objects of SimpleProps /// put both tables past the statement path (250 rows), so the objects and the values go through SqlBulkCopy. /// [Collection("MsSqlPro")] public class MsSqlProBulkInsertTimeoutTests { private const int Objects = 300; private static readonly TimeSpan LockHeld = TimeSpan.FromSeconds(35); private readonly string _connectionString; public MsSqlProBulkInsertTimeoutTests(MsSqlProFixture fixture) { _ = fixture; // the fixture created the database and synced the schemes _connectionString = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; } [Fact] public async Task BulkLoad_WaitsPastThirtySeconds_WithTheOption_AndIsCutAtThirty_WithoutIt() { // Without the option: the driver's 30 seconds cut the load while the lock is held. await using (var plain = await ServiceAsync(null)) await using (var blocker = await HoldValuesLockAsync()) { var watch = Stopwatch.StartNew(); var act = () => plain.Redb.AddNewObjectsAsync(NewObjects("bulk-timeout-plain")); var thrown = await act.Should().ThrowAsync(); watch.Stop(); HasSqlTimeout(thrown.Which).Should().BeTrue($"the load is cut by the client timeout, got: {thrown.Which}"); watch.Elapsed.Should().BeGreaterThan(TimeSpan.FromSeconds(25)).And.BeLessThan(TimeSpan.FromSeconds(90), "the driver's default of 30 seconds applies"); } // With the option: the load outwaits a lock held longer than 30 seconds and saves every object. await using (var configured = await ServiceAsync(TimeSpan.FromSeconds(120))) { await using var blocker = await HoldValuesLockAsync(); var release = Task.Run(async () => { await Task.Delay(LockHeld); await blocker.DisposeAsync(); }); var watch = Stopwatch.StartNew(); var ids = await configured.Redb.AddNewObjectsAsync(NewObjects("bulk-timeout-set")); watch.Stop(); await release; ids.Should().HaveCount(Objects); watch.Elapsed.Should().BeGreaterThan(TimeSpan.FromSeconds(30), "the load waited for the lock past the old cut"); (await configured.Redb.Query().Where(p => p.Title == "bulk-timeout-set").CountAsync()) .Should().Be(Objects); (await configured.Redb.Query().Where(p => p.Title == "bulk-timeout-plain").CountAsync()) .Should().Be(0, "the cut load rolled back"); await configured.Redb.DeleteAsync(ids); } } private static List> NewObjects(string title) => Enumerable.Range(0, Objects).Select(i => (IRedbObject)new RedbObject { name = $"{title}-{i}", Props = new SimpleProps { Title = title, Count = i, Price = i, CreatedAt = DateTime.UtcNow, IsActive = true, Code = Guid.NewGuid(), Description = "d", OptionalNumber = i } }).ToList(); private static bool HasSqlTimeout(Exception? e) { for (; e != null; e = e.InnerException) if (e is SqlException { Number: -2 }) return true; return false; } /// A session that holds an exclusive table lock on _values until it is disposed. private async Task HoldValuesLockAsync() { // Not pooled: a pooled connection would go back to the pool with the transaction still open. var connection = new SqlConnection(new SqlConnectionStringBuilder(_connectionString) { Pooling = false }.ConnectionString); await connection.OpenAsync(); await using var command = new SqlCommand( "BEGIN TRANSACTION; SELECT TOP (1) _id FROM _values WITH (TABLOCKX, HOLDLOCK);", connection); await command.ExecuteNonQueryAsync(); return new ValuesLock(connection); } private sealed class ValuesLock(SqlConnection connection) : IAsyncDisposable { private int _released; public async ValueTask DisposeAsync() { if (Interlocked.Exchange(ref _released, 1) == 1) return; try { await using var rollback = new SqlCommand("IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION;", connection); await rollback.ExecuteNonQueryAsync(); } finally { await connection.DisposeAsync(); } } } private async Task ServiceAsync(TimeSpan? bulkInsertTimeout) { var services = new ServiceCollection(); services.AddRedbPro(o => o.UseMsSql(_connectionString).Configure(c => { c.PropsSaveStrategy = PropsSaveStrategy.ChangeTracking; c.EnablePropsCache = false; c.BulkInsertTimeout = bulkInsertTimeout; })); var provider = services.BuildServiceProvider(); var redb = provider.GetRequiredService(); await redb.InitializeAsync(); await redb.SyncSchemeAsync(); return new Service(provider, redb); } private sealed record Service(ServiceProvider Provider, IRedbService Redb) : IAsyncDisposable { public ValueTask DisposeAsync() => Provider.DisposeAsync(); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProBytesRoundTripTests.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/MsSqlPro/MsSqlProBytesRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProBytesRoundTripTests : BytesRoundTripTestsBase { public MsSqlProBytesRoundTripTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCacheBehaviorTests.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/MsSqlPro/MsSqlProCacheBehaviorTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProCacheBehaviorTests : CacheBehaviorTestsBase { public MsSqlProCacheBehaviorTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProColdSchemeLinkedObjectTests.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/MsSqlPro/MsSqlProColdSchemeLinkedObjectTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProColdSchemeLinkedObjectTests : ColdSchemeLinkedObjectTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProColdSchemeTreeFilterTests.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/MsSqlPro/MsSqlProColdSchemeTreeFilterTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProColdSchemeTreeFilterTests : ColdSchemeTreeFilterTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCollectionFilterAnalyticsTests.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/MsSqlPro/MsSqlProCollectionFilterAnalyticsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProCollectionFilterAnalyticsTests : CollectionFilterAnalyticsTestsBase { public MsSqlProCollectionFilterAnalyticsTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCollectionGroupKeyTests.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/MsSqlPro/MsSqlProCollectionGroupKeyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProCollectionGroupKeyTests : CollectionGroupKeyTestsBase { public MsSqlProCollectionGroupKeyTests(MsSqlProFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCollectionKindChangeTests.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/MsSqlPro/MsSqlProCollectionKindChangeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProCollectionKindChangeTests : CollectionKindChangeTestsBase { public MsSqlProCollectionKindChangeTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProComputedComparisonTests.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/MsSqlPro/MsSqlProComputedComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProComputedComparisonTests : ComputedComparisonTestsBase { public MsSqlProComputedComparisonTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConcurrencyStressTests.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/MsSqlPro/MsSqlProConcurrencyStressTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProConcurrencyStressTests : ConcurrencyStressTestsBase { public MsSqlProConcurrencyStressTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConcurrentDeleteCountTests.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/MsSqlPro/MsSqlProConcurrentDeleteCountTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProConcurrentDeleteCountTests : ConcurrentDeleteCountTestsBase { public MsSqlProConcurrentDeleteCountTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } protected override async Task HoldRowAsync(long objectId) => await RowHolders.SqlServerAsync(objectId); } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConcurrentDeleteListTests.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/MsSqlPro/MsSqlProConcurrentDeleteListTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Pro.Extensions; using redb.Core.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProConcurrentDeleteListTests : ConcurrentDeleteListTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConcurrentWritersTests.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/MsSqlPro/MsSqlProConcurrentWritersTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProConcurrentWritersTests : ConcurrentWritersTestsBase { public MsSqlProConcurrentWritersTests(MsSqlProFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConnectionLeaseTests.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/MsSqlPro/MsSqlProConnectionLeaseTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProConnectionLeaseTests : ConnectionLeaseTestsBase { public MsSqlProConnectionLeaseTests(MsSqlProFixture fixture) : base(fixture.ServiceProvider) { } protected override string CreateProbeTableSql => "IF OBJECT_ID(N'dbo.connection_lease_rows', N'U') IS NULL CREATE TABLE dbo.connection_lease_rows (tag nvarchar(100) NOT NULL);"; protected override bool AmbientLeaseCarriesTransaction => false; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProConstantPredicateTests.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/MsSqlPro/MsSqlProConstantPredicateTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProConstantPredicateTests : ConstantPredicateTestsBase { public MsSqlProConstantPredicateTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProContainsWalkTests.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/MsSqlPro/MsSqlProContainsWalkTests.cs ---- using System.Linq.Expressions; using redb.Core; using redb.Core.Models.Entities; using redb.Core.Query; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.MsSqlPro; /// /// A page in object order under a Contains on an array of text: SQL Server Pro walks the first rows of the array in /// object order (at least 1 000, fifty per row of the page) and answers from the walk when it filled the page, from the /// streams otherwise. The answers must not change: every query runs with the planner off and on and is compared with the /// answer computed from the loaded objects, with the page filled by the walk (two values on many objects, Skip, a value /// twice in one array, a scalar condition beside it, the id ascending), and left to the streams (a rare value; values /// only on the last objects, past the walk's rows). The first object that matches is in the trash, its rows still there. /// [Collection("MsSqlPro")] public class MsSqlProContainsWalkTests { private const int Objects = 300; private static readonly SemaphoreSlim SeedLock = new(1, 1); private readonly IRedbService _redb; public MsSqlProContainsWalkTests(MsSqlProFixture fixture) => _redb = fixture.Redb; // About five rows of the array per object (its header and the elements), 1 500 for 300 objects: the walk of a page // of 5 reads the first 1 000, about 200 objects, so the last objects are past it. private static string[] SkillsOf(int i) { var skills = new List { "x", "y", "z" }; if (i % 2 == 0) skills.Add("a"); if (i % 10 == 0) skills.Add("a"); if (i % 3 == 0) skills.Add("b"); if (i == 250) skills.Add("rare"); if (i >= 280) skills.Add("late"); return skills.ToArray(); } private async Task>> SeedAsync() { await SeedLock.WaitAsync(); try { var all = await _redb.Query().ToListAsync(); if (all.Count == Objects - 1) return all; if (all.Count > 0) await _redb.DeleteAsync(all.Select(o => o.Id).ToList()); var objects = Enumerable.Range(0, Objects).Select(i => new RedbObject { name = $"contains-walk-{i:000}", Props = new ContainsWalkProps { Age = i % 50, Department = i % 4 == 0 ? "eng" : "ops", Skills = SkillsOf(i) } }).ToList(); await _redb.SaveAsync(objects); // The first object holds a and b: in the trash with its rows, it must not come back. await _redb.SoftDeleteAsync([objects[0].Id]); all = await _redb.Query().ToListAsync(); all.Should().HaveCount(Objects - 1); return all; } finally { SeedLock.Release(); } } private async Task EachFormAsync(Func check) { var restore = _redb.Configuration.EnablePvtPrefilter; try { foreach (var on in new[] { false, true }) { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = on); await check(on ? "planner on" : "planner off"); } } finally { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } private static List Expected(IEnumerable> all, Func keep, int skip, int take) => all.Where(o => keep(o.Props)).Select(o => o.Id).OrderBy(id => id).Skip(skip).Take(take).ToList(); public static IEnumerable Pages() { static object[] Case(string name, Expression> filter, int skip, int take) => [name, filter, skip, take]; yield return Case("two wide values", p => p.Skills!.Contains("a") && p.Skills!.Contains("b"), 0, 5); yield return Case("two wide values, Skip", p => p.Skills!.Contains("a") && p.Skills!.Contains("b"), 7, 5); yield return Case("a value twice in one array", p => p.Skills!.Contains("a"), 0, 5); yield return Case("a scalar condition beside it", p => p.Skills!.Contains("b") && p.Age > 30, 0, 5); yield return Case("a text scalar beside it", p => p.Skills!.Contains("a") && p.Department == "eng", 0, 5); yield return Case("a rare value", p => p.Skills!.Contains("rare") && p.Skills!.Contains("a"), 0, 5); yield return Case("values past the walk", p => p.Skills!.Contains("late") && p.Skills!.Contains("a"), 0, 5); yield return Case("no match", p => p.Skills!.Contains("rare") && p.Skills!.Contains("late"), 0, 5); } [Theory] [MemberData(nameof(Pages))] public async Task PageInObjectOrder_SameAnswer(string name, Expression> filter, int skip, int take) { var all = await SeedAsync(); var keep = filter.Compile(); var expected = Expected(all, keep, skip, take); await EachFormAsync(async form => { var plain = await _redb.Query().Where(filter).Skip(skip).Take(take).ToListAsync(); plain.Select(o => o.Id).Should().Equal(expected, $"{name}, no ordering, {form}"); var byId = await _redb.Query().Where(filter).OrderByRedb(o => o.Id).Skip(skip).Take(take).ToListAsync(); byId.Select(o => o.Id).Should().Equal(expected, $"{name}, by id, {form}"); var byIdDesc = await _redb.Query().Where(filter).OrderByDescendingRedb(o => o.Id).Skip(skip).Take(take).ToListAsync(); byIdDesc.Select(o => o.Id).Should().Equal( all.Where(o => keep(o.Props)).Select(o => o.Id).OrderByDescending(id => id).Skip(skip).Take(take).ToList(), $"{name}, by id descending, {form}"); }); } /// /// The walk is written for a page in object order only: not for a page sorted by a Props field or by the id descending, /// nor for a count. Read off the statement with the planner on (the streams form needs it). /// [Fact] public async Task Walk_OnlyForAPageInObjectOrder() { await SeedAsync(); var restore = _redb.Configuration.EnablePvtPrefilter; try { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); IRedbQueryable Query() => _redb.Query().Where(p => p.Skills!.Contains("a") && p.Skills!.Contains("b")); (await Query().Take(5).ToSqlStringAsync()).Should().Contain("@pvt_walk", "a page in object order"); (await Query().OrderByRedb(o => o.Id).Take(5).ToSqlStringAsync()).Should().Contain("@pvt_walk", "a page by id"); (await Query().OrderByDescendingRedb(o => o.Id).Take(5).ToSqlStringAsync()).Should().NotContain("@pvt_walk", "by id descending"); (await Query().OrderBy(p => p.Age).Take(5).ToSqlStringAsync()).Should().NotContain("@pvt_walk", "by a Props field"); (await Query().ToSqlStringAsync()).Should().NotContain("@pvt_walk", "no page"); } finally { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCrudTests.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/MsSqlPro/MsSqlProCrudTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProCrudTests : CrudTestsBase { public MsSqlProCrudTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCtPerfBenchmarkTests.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/MsSqlPro/MsSqlProCtPerfBenchmarkTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProCtPerfBenchmarkTests : CtPerfBenchmarkTestsBase { public MsSqlProCtPerfBenchmarkTests(MsSqlProFixture fixture) : base(fixture.Redb) { } protected override string ProviderName => "MsSqlPro"; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProCtSaveInvariantsTests.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/MsSqlPro/MsSqlProCtSaveInvariantsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProCtSaveInvariantsTests : CtSaveInvariantsTestsBase { public MsSqlProCtSaveInvariantsTests(MsSqlProFixture fixture) : base(fixture.Redb) { } /// Фикстура гоняет ChangeTracking - строки нетронутых значений обязаны сохранять _id. protected override bool ExpectStableValueRowIds => true; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDbInfoTests.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/MsSqlPro/MsSqlProDbInfoTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProDbInfoTests : DbInfoTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } protected override string VersionMarker => "Microsoft SQL Server"; // sys.database_files.size is in 8 KB pages. protected override string SizeInBytesSql => "SELECT SUM(CAST(size AS BIGINT)) * 8192 FROM sys.database_files"; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDecimalRoundTripTests.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/MsSqlPro/MsSqlProDecimalRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProDecimalRoundTripTests : DecimalRoundTripTestsBase { public MsSqlProDecimalRoundTripTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDeepTreeTests.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/MsSqlPro/MsSqlProDeepTreeTests.cs ---- using redb.Core; using redb.Core.Models.Entities; using redb.Core.Query; using redb.Core.Query.Aggregation; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.MsSqlPro; /// /// An unrooted tree query that needs levels (WhereLevel, a query maxDepth) walks every node up to the real root of its /// tree with a recursive CTE. SQL Server stops a recursion at 100 levels unless the statement says otherwise, and every /// statement form that read that walk failed on a deeper tree ("The maximum recursion 100 has been exhausted"). A chain /// of 120 levels on a scheme of its own, read by each form: the list, the count, Any, the query's maxDepth, Sum, a batch /// aggregate, GroupBy, a window, GroupByArray, and the listing path of WhereHasAncestor. /// [Collection("MsSqlPro")] public class MsSqlProDeepTreeTests { private const int Depth = 120; private readonly IRedbService _redb; public MsSqlProDeepTreeTests(MsSqlProFixture fixture) => _redb = fixture.Redb; private async Task SeedChainAsync() { await _redb.SyncSchemeAsync(); var tag = "deep-" + Guid.NewGuid().ToString("N")[..8]; TreeRedbObject Node(int i) => new() { name = $"{tag}-{i}", Props = new DeepChainProps { Tag = tag, Index = i, Bucket = i % 2 == 0 ? "even" : "odd", Marks = [new() { Kind = "k" }] } }; var previous = Node(0); previous.id = await _redb.SaveAsync(previous); for (var i = 1; i < Depth; i++) { var node = Node(i); node.id = await _redb.CreateChildAsync(node, previous); previous = node; } return tag; } [Fact] public async Task EveryForm_ReadsATreeDeeperThan100Levels() { var tag = await SeedChainAsync(); // Levels count from the real root (level 0): the deepest ten nodes are levels 110..119. IRedbQueryable Deep() => _redb.TreeQuery().Where(n => n.Tag == tag).WhereLevel(l => l >= 110); var deepIndexes = Enumerable.Range(110, 10).ToList(); (await Deep().ToListAsync()).Select(o => o.Props.Index).Should().BeEquivalentTo(deepIndexes, "the list"); (await Deep().CountAsync()).Should().Be(10, "the count"); (await _redb.TreeQuery().Where(n => n.Tag == tag).WhereLevel(l => l >= Depth - 1).AnyAsync()) .Should().BeTrue("Any"); (await _redb.TreeQuery().Where(n => n.Tag == tag).WithMaxDepth(115).CountAsync()) .Should().Be(116, "the query's maxDepth, levels 0..115"); (await Deep().SumAsync(n => n.Index)).Should().Be(deepIndexes.Sum(), "Sum"); var batch = await Deep().AggregateAsync(x => new { Count = Agg.Count(), Max = Agg.Max(x.Props.Index) }); batch.Count.Should().Be(10, "a batch aggregate"); batch.Max.Should().Be(Depth - 1); var groups = await Deep().GroupBy(n => n.Bucket).SelectAsync(g => new { g.Key, C = Agg.Count(g) }); groups.ToDictionary(g => g.Key, g => g.C).Should().BeEquivalentTo(new Dictionary { ["even"] = 5, ["odd"] = 5 }, "GroupBy"); var window = await Deep().WithWindow(w => w.OrderBy(n => n.Index)).SelectAsync(x => new { x.Id, Row = Win.RowNumber() }); window.Should().HaveCount(10, "a window"); var marks = await Deep().GroupByArray(n => n.Marks!, m => m.Kind).SelectAsync(g => new { g.Key, C = Agg.Count(g) }); marks.Single().C.Should().Be(10, "GroupByArray"); var listed = await _redb.TreeQuery().Where(n => n.Tag == tag) .WhereHasAncestor(n => n.Tag == tag && n.Index == 100).WhereLevel(l => l >= 110).ToListAsync(); // The ancestor at level 100: the listing reaches the default 50 levels below it, so 110..119 are in. listed.Select(o => o.Props.Index).Should().BeEquivalentTo(deepIndexes, "the listing path of WhereHasAncestor"); } /// /// A tree query under one root or one parent walks down with a recursive CTE when the planner is off; with a depth /// limit above 100 that recursion went past SQL Server's default of 100 levels on the chain. The list, the count and /// the subtree that WhereHasAncestor looks for its ancestors in, each under the node at the top of the chain. /// [Fact] public async Task UnderOneRootOrParent_PlannerOff_ReadsMoreThan100LevelsDown() { var tag = await SeedChainAsync(); var top = (await _redb.TreeQuery().Where(n => n.Tag == tag && n.Index == 0).ToListAsync()).Single().Id; var below = Enumerable.Range(1, Depth - 1).ToList(); var restore = _redb.Configuration.EnablePvtPrefilter; try { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); (await _redb.TreeQuery(top, 150).Where(n => n.Tag == tag).ToListAsync()) .Select(o => o.Props.Index).Should().BeEquivalentTo(below, "under the root"); (await _redb.TreeQuery(top, 150).Where(n => n.Tag == tag).CountAsync()) .Should().Be(Depth - 1, "the count under the root"); (await _redb.TreeQuery(new[] { top }, 150).Where(n => n.Tag == tag).ToListAsync()) .Select(o => o.Props.Index).Should().BeEquivalentTo(below, "under one parent"); var under = await _redb.TreeQuery(top, 150).Where(n => n.Tag == tag) .WhereHasAncestor(n => n.Tag == tag && n.Index == 105).ToListAsync(); under.Select(o => o.Props.Index).Should().BeEquivalentTo(Enumerable.Range(106, Depth - 106), "WhereHasAncestor looks for the ancestor in the subtree of the root"); } finally { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// WhereHasAncestor under a root lists the descendants of the matching ancestors first, with a recursion as deep as its /// maxDepth: 150 below the node at level 5 of the chain reaches the bottom, 114 levels down, past SQL Server's default /// of 100. /// [Fact] public async Task UnderARoot_WhereHasAncestor_ListsMoreThan100LevelsDown() { var tag = await SeedChainAsync(); var top = (await _redb.TreeQuery().Where(n => n.Tag == tag && n.Index == 0).ToListAsync()).Single().Id; var under = await _redb.TreeQuery(top, 150).Where(n => n.Tag == tag) .WhereHasAncestor(n => n.Tag == tag && n.Index == 5, 150).ToListAsync(); under.Select(o => o.Props.Index).Should().BeEquivalentTo(Enumerable.Range(6, Depth - 6)); } /// /// WhereHasDescendant with no root, no parents and no other tree filter climbs in the batch of the statement that /// reads the nodes (a loop over a table variable, one level per pass). A match at the bottom of the chain with maxDepth /// 150 climbs 119 levels to the top; without maxDepth the default 50. List and count, planner off and on. /// [Fact] public async Task InBatch_WhereHasDescendant_ClimbsMoreThan100Levels() { var tag = await SeedChainAsync(); IRedbQueryable Above(int? maxDepth) => _redb.TreeQuery().Where(n => n.Tag == tag) .WhereHasDescendant(n => n.Tag == tag && n.Index == Depth - 1, maxDepth); var restore = _redb.Configuration.EnablePvtPrefilter; try { foreach (var on in new[] { false, true }) { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = on); var form = on ? "planner on" : "planner off"; (await Above(150).ToListAsync()).Select(o => o.Props.Index) .Should().BeEquivalentTo(Enumerable.Range(0, Depth - 1), $"every node above the bottom, {form}"); (await Above(150).CountAsync()).Should().Be(Depth - 1, $"the count, {form}"); (await Above(null).ToListAsync()).Select(o => o.Props.Index) .Should().BeEquivalentTo(Enumerable.Range(Depth - 51, 50), $"the default 50 levels, {form}"); } } finally { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDeleteBatchCountTests.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/MsSqlPro/MsSqlProDeleteBatchCountTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProDeleteBatchCountTests : DeleteBatchCountTestsBase { public MsSqlProDeleteBatchCountTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDeleteSubtreeCountTests.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/MsSqlPro/MsSqlProDeleteSubtreeCountTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Pro.Extensions; using redb.Core.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProDeleteSubtreeCountTests : DeleteSubtreeCountTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDictionaryEntryKeyFilterTests.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/MsSqlPro/MsSqlProDictionaryEntryKeyFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProDictionaryEntryKeyFilterTests : DictionaryEntryKeyFilterTestsBase { public MsSqlProDictionaryEntryKeyFilterTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDictionaryEntryLeadsTests.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/MsSqlPro/MsSqlProDictionaryEntryLeadsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProDictionaryEntryLeadsTests : DictionaryEntryLeadsTestsBase { public MsSqlProDictionaryEntryLeadsTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDictionaryOrderTests.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/MsSqlPro/MsSqlProDictionaryOrderTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProDictionaryOrderTests : DictionaryOrderTestsBase { public MsSqlProDictionaryOrderTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDictionaryTests.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/MsSqlPro/MsSqlProDictionaryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProDictionaryTests : DictionaryTestsBase { public MsSqlProDictionaryTests(MsSqlProFixture fixture) : base(fixture.Redb) { } protected override int? DictionaryKeyBound => 430; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProDisposedScopeGuardTests.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/MsSqlPro/MsSqlProDisposedScopeGuardTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProDisposedScopeGuardTests : DisposedScopeGuardTestsBase { public MsSqlProDisposedScopeGuardTests(MsSqlProFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProElementFoldOrderTests.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/MsSqlPro/MsSqlProElementFoldOrderTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProElementFoldOrderTests : ElementFoldOrderTestsBase { public MsSqlProElementFoldOrderTests(MsSqlProFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProElementIndexFilterTests.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/MsSqlPro/MsSqlProElementIndexFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProElementIndexFilterTests : ElementIndexFilterTestsBase { public MsSqlProElementIndexFilterTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProEnumComparisonTests.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/MsSqlPro/MsSqlProEnumComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProEnumComparisonTests : EnumComparisonTestsBase { public MsSqlProEnumComparisonTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProEnumDictionaryKeyTests.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/MsSqlPro/MsSqlProEnumDictionaryKeyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProEnumDictionaryKeyTests : EnumDictionaryKeyTestsBase { public MsSqlProEnumDictionaryKeyTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProFieldNamedLikeAFunctionTests.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/MsSqlPro/MsSqlProFieldNamedLikeAFunctionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProFieldNamedLikeAFunctionTests : FieldNamedLikeAFunctionTestsBase { public MsSqlProFieldNamedLikeAFunctionTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProFilterFieldPathTests.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/MsSqlPro/MsSqlProFilterFieldPathTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProFilterFieldPathTests : FilterFieldPathTestsBase { public MsSqlProFilterFieldPathTests(MsSqlProFixture fixture) : base(fixture.Redb) { } protected override bool ReadsElementsByIndex => true; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProGroupByHavingTests.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/MsSqlPro/MsSqlProGroupByHavingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProGroupByHavingTests : GroupByHavingTestsBase { public MsSqlProGroupByHavingTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProGroupBySelectShapesTests.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/MsSqlPro/MsSqlProGroupBySelectShapesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProGroupBySelectShapesTests : GroupBySelectShapesTestsBase { public MsSqlProGroupBySelectShapesTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProGroupByTests.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/MsSqlPro/MsSqlProGroupByTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProGroupByTests : GroupByTestsBase { public MsSqlProGroupByTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProHasAncestorFormTests.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/MsSqlPro/MsSqlProHasAncestorFormTests.cs ---- using redb.Core; using redb.Core.Models.Contracts; using redb.Core.Models.Entities; using redb.Core.Query; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Helpers; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.MsSqlPro; /// /// WhereHasAncestor on SQL Server Pro: without a root, parents, query depth or other tree filter, the query walks down from /// the matching ancestors as its parents, in the statement that reads the page: without maxDepth at any depth, with a /// maxDepth at most that many levels (the query's own depth limit). Every other case lists the descendants first and sends /// their ids back. Each case returns the right objects; the walk takes one data statement less than the listing. With a /// maxDepth the walk must count from the nearest matching ancestor and return a node under two nested ones once. /// [Collection("MsSqlPro")] public class MsSqlProHasAncestorFormTests { private readonly IRedbService _redb; public MsSqlProHasAncestorFormTests(MsSqlProFixture fixture) => _redb = fixture.Redb; // root (marked) -> a -> b -> c, and root -> d. Only the root matches the ancestor condition. private async Task<(string Tag, long Root, long A, long B, long C, long D)> SeedAsync() { var tag = "ha-" + Guid.NewGuid().ToString("N")[..8]; var root = TestDataFactory.CreateTreeNode($"{tag}-root", tag); root.Props.Description = "anchor"; root.id = await _redb.SaveAsync(root); var a = TestDataFactory.CreateTreeNode($"{tag}-a", tag); a.Props.Description = "mid"; a.id = await _redb.CreateChildAsync(a, root); var b = TestDataFactory.CreateTreeNode($"{tag}-b", tag); b.id = await _redb.CreateChildAsync(b, a); var c = TestDataFactory.CreateTreeNode($"{tag}-c", tag); c.id = await _redb.CreateChildAsync(c, b); var d = TestDataFactory.CreateTreeNode($"{tag}-d", tag); d.id = await _redb.CreateChildAsync(d, root); return (tag, root.id, a.id, b.id, c.id, d.id); } private static async Task<(List Ids, int Statements)> RunAsync(IRedbQueryable query) { List ids = []; var statements = await CommandCounter.CountAsync(async () => ids = (await query.ToListAsync()).Select(o => o.id).ToList()); return (ids, statements); } [Fact] public async Task EachCase_ReturnsItsAnswer_InTheFormItsShapeCalls() { var (tag, root, a, b, c, d) = await SeedAsync(); IRedbQueryable Tree() => _redb.TreeQuery().Where(n => n.Code == tag); // No maxDepth: every descendant of the root, walked from it. var any = await RunAsync(Tree().WhereHasAncestor(n => n.Code == tag && n.Description == "anchor")); any.Ids.Should().BeEquivalentTo([a, b, c, d]); // maxDepth 1: the children, walked from the root. var children = await RunAsync(Tree().WhereHasAncestor(n => n.Code == tag && n.Description == "anchor", 1)); children.Ids.Should().BeEquivalentTo([a, d]); // maxDepth 2: two levels, walked from the root with the query's depth limit. var two = await RunAsync(Tree().WhereHasAncestor(n => n.Code == tag && n.Description == "anchor", 2)); two.Ids.Should().BeEquivalentTo([a, b, d]); // A root of the query: listed first. The ancestor is looked for inside the query's tree, so it is a, not the root. var rooted = await RunAsync(_redb.TreeQuery(root).Where(n => n.Code == tag) .WhereHasAncestor(n => n.Code == tag && n.Description == "mid")); rooted.Ids.Should().BeEquivalentTo([b, c]); // Another tree filter beside it (a second WhereHasAncestor): the first one is listed, the second resolved after it. var both = await RunAsync(Tree().WhereHasAncestor(n => n.Code == tag && n.Description == "anchor") .WhereHasAncestor(n => n.Code == tag && n.Description == "mid")); both.Ids.Should().BeEquivalentTo([b, c], "under the anchor and under a"); // The walk reads the page in the statement that walks down; the listing adds the statement of the descendants. var counts = $"statements: no maxDepth {any.Statements}, maxDepth 1 {children.Statements}, maxDepth 2 {two.Statements}, " + $"rooted {rooted.Statements}, two filters {both.Statements}"; two.Statements.Should().Be(any.Statements, "maxDepth 2 walks down from the ancestors too; {0}", counts); rooted.Statements.Should().BeGreaterThan(any.Statements, "a rooted query keeps the listing; {0}", counts); both.Statements.Should().BeGreaterThan(any.Statements, "another tree filter keeps the listing; {0}", counts); } /// /// Two matching ancestors, one under the other: root (marked) -> a (marked) -> x -> y, and root -> d. With maxDepth 2, /// x is one level below a and two below the root and comes once; y is two levels below a, three below the root, and is /// in: the depth counts from the nearest matching ancestor. /// [Fact] public async Task MaxDepth_NestedAncestors_NodeOnce_DepthFromTheNearest() { var tag = "han-" + Guid.NewGuid().ToString("N")[..8]; var root = TestDataFactory.CreateTreeNode($"{tag}-root", tag); root.Props.Description = "anchor"; root.id = await _redb.SaveAsync(root); var a = TestDataFactory.CreateTreeNode($"{tag}-a", tag); a.Props.Description = "anchor"; a.id = await _redb.CreateChildAsync(a, root); var x = TestDataFactory.CreateTreeNode($"{tag}-x", tag); x.id = await _redb.CreateChildAsync(x, a); var y = TestDataFactory.CreateTreeNode($"{tag}-y", tag); y.id = await _redb.CreateChildAsync(y, x); var z = TestDataFactory.CreateTreeNode($"{tag}-z", tag); z.id = await _redb.CreateChildAsync(z, y); var d = TestDataFactory.CreateTreeNode($"{tag}-d", tag); d.id = await _redb.CreateChildAsync(d, root); IRedbQueryable Under(int maxDepth) => _redb.TreeQuery().Where(n => n.Code == tag) .WhereHasAncestor(n => n.Code == tag && n.Description == "anchor", maxDepth); var two = (await Under(2).ToListAsync()).Select(o => o.id).ToList(); two.Should().OnlyHaveUniqueItems("x is under both anchors"); two.Should().BeEquivalentTo([a.id, x.id, y.id, d.id], "z is three levels below a"); var three = (await Under(3).ToListAsync()).Select(o => o.id).ToList(); three.Should().OnlyHaveUniqueItems(); three.Should().BeEquivalentTo([a.id, x.id, y.id, z.id, d.id]); (await Under(2).CountAsync()).Should().Be(4, "the count reads the same walk"); } /// /// More matching ancestors than the provider sends one parameter each (ProSqlBuilder.InListParameterLimit, 500): the /// parents travel as one list. 520 marked roots, each with a child and a grandchild, one great-grandchild under the /// first; maxDepth 2 returns the children and the grandchildren. /// [Fact] public async Task MaxDepth_ParentsAboveTheParameterLimit() { const int anchors = 520; var tag = "hap-" + Guid.NewGuid().ToString("N")[..8]; IRedbObject Node(string name, long? parent, string? description = null) => new RedbObject { name = name, parent_id = parent, Props = new TreeNodeProps { Name = name, Code = tag, Description = description ?? string.Empty, IsActive = true } }; var rootIds = await _redb.SaveAsync(Enumerable.Range(0, anchors).Select(i => Node($"{tag}-r{i}", null, "anchor")).ToList()); var childIds = await _redb.SaveAsync(rootIds.Select((r, i) => Node($"{tag}-c{i}", r)).ToList()); var grandchildIds = await _redb.SaveAsync(childIds.Select((c, i) => Node($"{tag}-g{i}", c)).ToList()); await _redb.SaveAsync(new List { Node($"{tag}-deep", grandchildIds[0]) }); var ids = (await _redb.TreeQuery().Where(n => n.Code == tag) .WhereHasAncestor(n => n.Code == tag && n.Description == "anchor", 2).ToListAsync()) .Select(o => o.id).ToList(); ids.Should().OnlyHaveUniqueItems(); ids.Should().BeEquivalentTo(childIds.Concat(grandchildIds)); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProHasDescendantFormTests.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/MsSqlPro/MsSqlProHasDescendantFormTests.cs ---- using redb.Core; using redb.Core.Query; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Helpers; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.MsSqlPro; /// /// WhereHasDescendant on SQL Server Pro: with no root, no parents and no other tree filter, the climb from the matching /// descendants runs in the batch of the statement that reads the nodes, into a temporary table that statement reads; /// otherwise its ids come back first and are sent as a condition on the object id. Each case returns the objects that /// have a matching descendant (within maxDepth), in both planner modes, through the list, the count, Any and an /// aggregate; the batch takes one statement less than the ids sent back. /// [Collection("MsSqlPro")] public class MsSqlProHasDescendantFormTests { private readonly IRedbService _redb; public MsSqlProHasDescendantFormTests(MsSqlProFixture fixture) => _redb = fixture.Redb; // r -> a -> b (marked), r -> c; x -> y (marked); z (marked, no parent, no child). private async Task<(string Tag, long R, long A, long B, long C, long X, long Y, long Z)> SeedAsync() { var tag = "hd-" + Guid.NewGuid().ToString("N")[..8]; async Task Node(string name, long? parent, bool marked, decimal budget) { var n = TestDataFactory.CreateTreeNode($"{tag}-{name}", tag, budget); n.Props.Description = marked ? "marked" : "plain"; if (parent == null) return await _redb.SaveAsync(n); var parentNode = await _redb.LoadAsync(parent.Value); return await _redb.CreateChildAsync(n, parentNode!); } var r = await Node("r", null, false, 1); var a = await Node("a", r, false, 10); var b = await Node("b", a, true, 100); var c = await Node("c", r, false, 1000); var x = await Node("x", null, false, 10000); var y = await Node("y", x, true, 100000); var z = await Node("z", null, true, 1000000); return (tag, r, a, b, c, x, y, z); } private async Task EachFormAsync(Func check) { var restore = _redb.Configuration.EnablePvtPrefilter; try { foreach (var on in new[] { false, true }) { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = on); await check(on ? "planner on" : "planner off"); } } finally { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } [Fact] public async Task EachCase_ReturnsTheObjectsAboveAMatch() { var (tag, r, a, _, _, x, _, _) = await SeedAsync(); IRedbQueryable Above(string description, int? maxDepth = null) => _redb.TreeQuery() .Where(n => n.Code == tag).WhereHasDescendant(n => n.Code == tag && n.Description == description, maxDepth); await EachFormAsync(async form => { (await Above("marked").ToListAsync()).Select(o => o.id).Should().BeEquivalentTo([r, a, x], form); (await Above("marked", 1).ToListAsync()).Select(o => o.id).Should().BeEquivalentTo([a, x], $"maxDepth 1, {form}"); (await Above("marked").CountAsync()).Should().Be(3, $"count, {form}"); (await Above("marked").AnyAsync()).Should().BeTrue($"any, {form}"); (await Above("marked").SumAsync(n => n.Budget)).Should().Be(10011m, $"sum, {form}"); (await Above("none").ToListAsync()).Should().BeEmpty($"no match, {form}"); (await Above("none").CountAsync()).Should().Be(0, $"no match, count, {form}"); (await Above("none").AnyAsync()).Should().BeFalse($"no match, any, {form}"); // Under a root: the climb looks among the root's descendants and its ids come back first. (await _redb.TreeQuery(r).Where(n => n.Code == tag) .WhereHasDescendant(n => n.Code == tag && n.Description == "marked").ToListAsync()) .Select(o => o.id).Should().BeEquivalentTo([a], $"under a root, {form}"); }); } [Fact] public async Task InBatch_TakesOneStatementLess_AndShowsTheClimbInItsPreview() { var (tag, r, a, _, _, x, _, _) = await SeedAsync(); var plain = _redb.TreeQuery().Where(n => n.Code == tag) .WhereHasDescendant(n => n.Code == tag && n.Description == "marked"); // A second tree filter keeps the ids sent back. var listed = _redb.TreeQuery().Where(n => n.Code == tag) .WhereHasDescendant(n => n.Code == tag && n.Description == "marked") .WhereHasDescendant(n => n.Code == tag && n.Description == "marked"); List plainIds = [], listedIds = []; var inBatch = await CommandCounter.CountAsync(async () => plainIds = (await plain.ToListAsync()).Select(o => o.id).ToList()); var sentBack = await CommandCounter.CountAsync(async () => listedIds = (await listed.ToListAsync()).Select(o => o.id).ToList()); plainIds.Should().BeEquivalentTo([r, a, x]); listedIds.Should().BeEquivalentTo([r, a, x]); inBatch.Should().BeLessThan(sentBack, "the climb runs in the batch of the statement; sent back it is a statement of its own and a second for the next filter"); var preview = await plain.ToSqlStringAsync(); preview.Should().Contain("#redb_up", "the climb is part of the batch shown"); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProHashCanonCollisionTests.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/MsSqlPro/MsSqlProHashCanonCollisionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProHashCanonCollisionTests : HashCanonCollisionTestsBase { public MsSqlProHashCanonCollisionTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProIgnoredPropertyWalkTests.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/MsSqlPro/MsSqlProIgnoredPropertyWalkTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProIgnoredPropertyWalkTests : IgnoredPropertyWalkTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProIndexCatalogTests.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/MsSqlPro/MsSqlProIndexCatalogTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Models; using redb.Core.Models.Configuration; using redb.MSSql.Pro.Sql; using redb.MSSql.Sql; using redb.Tests.Integration.Tests.MsSql; namespace redb.Tests.Integration.Tests.MsSqlPro; /// /// MsSqlProIndexCatalog.Pro, the index of the streams query form, against a fresh SQL Server Pro database of this build /// with the planner on (see ). /// public class MsSqlProIndexCatalogTests : MsSqlIndexCatalogTests { protected override void AddRedb(IServiceCollection services, string connectionString, Action configure) => redb.Core.Pro.Extensions.RedbProServiceCollectionExtensions.AddRedbPro(services, o => redb.MSSql.Pro.Extensions.MsSqlProOptionsExtensions.UseMsSql(o, connectionString).Configure(configure)); protected override IReadOnlyList Catalog => MsSqlProIndexCatalog.Pro; protected override IReadOnlyList CoveredElsewhere => MsSqlIndexCatalog.Base; protected override (string File, string Namespace, string Class, string Member, RedbIndexOrigin Origin) Target => ("redb.MSSql.Pro/Sql/MsSqlProIndexCatalog.g.cs", "redb.MSSql.Pro.Sql", "MsSqlProIndexCatalog", "Pro", RedbIndexOrigin.ProModule); } /// The streams index of SQL Server Pro is built once (see ). public class MsSqlProStreamsIndexOnceTests : Base.StreamsIndexOnceTestsBase { protected override async Task CreateDatabaseAsync(string name) { await MsSqlIndexCatalogTests.ExecAdminAsync($"CREATE DATABASE [{name}]"); return new Microsoft.Data.SqlClient.SqlConnectionStringBuilder(MsSqlIndexCatalogTests.AdminBase) { InitialCatalog = name }.ConnectionString; } protected override async Task DropDatabaseAsync(string name) { Microsoft.Data.SqlClient.SqlConnection.ClearAllPools(); await MsSqlIndexCatalogTests.ExecAdminAsync( $"IF DB_ID(N'{name}') IS NOT NULL BEGIN ALTER DATABASE [{name}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{name}]; END"); } protected override void AddRedbPro(IServiceCollection services, string connectionString, Action configure) => redb.Core.Pro.Extensions.RedbProServiceCollectionExtensions.AddRedbPro(services, o => redb.MSSql.Pro.Extensions.MsSqlProOptionsExtensions.UseMsSql(o, connectionString).Configure(configure)); protected override string StreamsIndex => "IX__values__structure_object_scalar"; protected override string DropStreamsIndexSql => "DROP INDEX [IX__values__structure_object_scalar] ON [dbo].[_values]"; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProIntegerAverageTests.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/MsSqlPro/MsSqlProIntegerAverageTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProIntegerAverageTests : IntegerAverageTestsBase { public MsSqlProIntegerAverageTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProKeyCacheRepeatTests.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/MsSqlPro/MsSqlProKeyCacheRepeatTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProKeyCacheRepeatTests : KeyCacheRepeatTestsBase { public MsSqlProKeyCacheRepeatTests(MsSqlProFixture fixture) { _ = fixture; } protected override ServiceProvider Build(string applicationName) { var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); var cs = config.GetConnectionString("MSSql")! + $";Application Name={applicationName}"; var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => { options.UseMsSql(cs).Configure(c => c.EnablePvtPrefilter = ProTestOptions.PvtPrefilter); if (config["Redb:License"] is { Length: > 0 } license) options.WithLicense(license); }); return services.BuildServiceProvider(); } protected override string SequenceTopSql => "SELECT CAST(current_value AS bigint) FROM sys.sequences WHERE name = 'global_identity'"; protected override string SequenceRestartSql(long next) => $"ALTER SEQUENCE dbo.global_identity RESTART WITH {next}"; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProKeyDrawTests.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/MsSqlPro/MsSqlProKeyDrawTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProKeyDrawTests : KeyDrawTestsBase { public MsSqlProKeyDrawTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProKeywordNamesTests.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/MsSqlPro/MsSqlProKeywordNamesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProKeywordNamesTests : KeywordNamesTestsBase { public MsSqlProKeywordNamesTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLazyHostTests.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/MsSqlPro/MsSqlProLazyHostTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProLazyHostTests : LazyHostTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } protected override string ReadFlagSql => "SELECT CAST(SESSION_CONTEXT(N'redb.lazy_refs') AS NVARCHAR(10))"; /// The Pro materializer reads the global option live; its registrations do not arm the session flag. protected override bool SessionFlagIsTheChannel => false; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLazyReferenceTests.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/MsSqlPro/MsSqlProLazyReferenceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProLazyReferenceTests : LazyReferenceTestsBase { public MsSqlProLazyReferenceTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLazyReferencesOptionTests.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/MsSqlPro/MsSqlProLazyReferencesOptionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProLazyReferencesOptionTests : LazyReferencesOptionTestsBase { public MsSqlProLazyReferencesOptionTests(MsSqlProFixture fixture) : base(fixture.Redb) { } // Л2 boundary: the Pro materializer reads the global option, not the session flag. protected override bool PerQueryOverrideWorks => false; protected override bool GlobalMutationAffects => true; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLikeEscapingTests.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/MsSqlPro/MsSqlProLikeEscapingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProLikeEscapingTests : LikeEscapingTestsBase { public MsSqlProLikeEscapingTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListItemArrayAnyTests.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/MsSqlPro/MsSqlProListItemArrayAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProListItemArrayAnyTests : ListItemArrayAnyTestsBase { public MsSqlProListItemArrayAnyTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListItemObjectWalkTests.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/MsSqlPro/MsSqlProListItemObjectWalkTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProListItemObjectWalkTests : ListItemObjectWalkTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListReadPropsOnceTests.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/MsSqlPro/MsSqlProListReadPropsOnceTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Pro.Extensions; using redb.Core.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProListReadPropsOnceTests : ListReadPropsOnceTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListRoundTripsTests.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/MsSqlPro/MsSqlProListRoundTripsTests.cs ---- using System.Data.Common; using System.Diagnostics; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProListRoundTripsTests : ListRoundTripsTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } /// /// The list goes to the server as its builder writes it (the statement ToSqlStringAsync shows), with the scheme hash /// as a second result set of the same batch: no table variable around the page. The INSERT ... SELECT of the page into /// a table variable lost the parallel and the batch-mode plans of sorted and distinct pages. /// [Fact] public async Task ListStatement_IsSentAsBuilt_WithTheHashBesideIt() { var run = Guid.NewGuid().ToString("N")[..8]; var services = new ServiceCollection(); Register(services, options => { UseProvider(options); options.Configure(c => { c.EnablePropsCache = false; c.CacheDomain = $"round-trips-text-{run}"; }); }); await using var sp = services.BuildServiceProvider(); var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); var query = redb.Query().Where(p => p.Tag == run).OrderBy(p => p.Number).Take(10); await query.ToListAsync(); var preview = await query.ToSqlStringAsync(); var built = string.Join("\n", preview.Split('\n').Where(l => !l.TrimStart().StartsWith("--", StringComparison.Ordinal))).Trim(); var sent = new List(); using var observer = new ListenerObserver(listener => listener.Name != "SqlClientDiagnosticListener" ? null : listener.Subscribe(new EventObserver(e => { if (e.Key.EndsWith("WriteCommandBefore", StringComparison.Ordinal) && e.Value?.GetType().GetProperty("Command")?.GetValue(e.Value) is DbCommand command) lock (sent) sent.Add(command.CommandText); }))); using (DiagnosticListener.AllListeners.Subscribe(observer)) await query.ToListAsync(); lock (sent) { sent.Should().NotContain(s => s.Contains("@redb_page", StringComparison.Ordinal), "the page is not wrapped"); sent.Should().Contain(s => s.Contains(built, StringComparison.Ordinal) && s.Contains("_structure_hash FROM _schemes", StringComparison.Ordinal), "the list goes as its builder writes it, with the hash in its batch"); } } private sealed class ListenerObserver(Func onNext) : IObserver, IDisposable { private readonly List _subscriptions = []; public void OnNext(DiagnosticListener value) { if (onNext(value) is { } s) lock (_subscriptions) _subscriptions.Add(s); } public void OnError(Exception error) { } public void OnCompleted() { } public void Dispose() { lock (_subscriptions) foreach (var s in _subscriptions) s.Dispose(); } } private sealed class EventObserver(Action> onNext) : IObserver> { public void OnNext(KeyValuePair value) => onNext(value); public void OnError(Exception error) { } public void OnCompleted() { } } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProListTests.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/MsSqlPro/MsSqlProListTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProListTests : ListTestsBase { protected override bool IsPro => true; public MsSqlProListTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLiteralStructureIdsTests.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/MsSqlPro/MsSqlProLiteralStructureIdsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProLiteralStructureIdsTests : LiteralStructureIdsTestsBase { public MsSqlProLiteralStructureIdsTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProLongBaseFilterTests.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/MsSqlPro/MsSqlProLongBaseFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProLongBaseFilterTests : LongBaseFilterTestsBase { public MsSqlProLongBaseFilterTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMaintenanceTests.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/MsSqlPro/MsSqlProMaintenanceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProMaintenanceTests : MaintenanceTestsBase { public MsSqlProMaintenanceTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMaterializationFidelityTests.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/MsSqlPro/MsSqlProMaterializationFidelityTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProMaterializationFidelityTests : MaterializationFidelityTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMaterializerConversionTests.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/MsSqlPro/MsSqlProMaterializerConversionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProMaterializerConversionTests : ProMaterializerConversionTestsBase { public MsSqlProMaterializerConversionTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMigrationTargetAddressingTests.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/MsSqlPro/MsSqlProMigrationTargetAddressingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProMigrationTargetAddressingTests : MigrationTargetAddressingTestsBase { public MsSqlProMigrationTargetAddressingTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMigrationTests.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/MsSqlPro/MsSqlProMigrationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProMigrationTests : MigrationTestsBase { public MsSqlProMigrationTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProMigrationTransformArithmeticTests.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/MsSqlPro/MsSqlProMigrationTransformArithmeticTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProMigrationTransformArithmeticTests : MigrationTransformArithmeticTestsBase { public MsSqlProMigrationTransformArithmeticTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProNestedDictionaryFilterTests.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/MsSqlPro/MsSqlProNestedDictionaryFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProNestedDictionaryFilterTests : NestedDictionaryFilterTestsBase { public MsSqlProNestedDictionaryFilterTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProNullComparisonTests.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/MsSqlPro/MsSqlProNullComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProNullComparisonTests : NullComparisonTestsBase { public MsSqlProNullComparisonTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProNullableCollectionsTests.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/MsSqlPro/MsSqlProNullableCollectionsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProNullableCollectionsTests : NullableCollectionsTestsBase { public MsSqlProNullableCollectionsTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProOlderModelTests.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/MsSqlPro/MsSqlProOlderModelTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProOlderModelTests : OlderModelTestsBase { public MsSqlProOlderModelTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProOrderAbsentValueTests.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/MsSqlPro/MsSqlProOrderAbsentValueTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProOrderAbsentValueTests : OrderAbsentValueTestsBase { public MsSqlProOrderAbsentValueTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProOrderingTests.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/MsSqlPro/MsSqlProOrderingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProOrderingTests : OrderingTestsBase { public MsSqlProOrderingTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPageValuesGraphTests.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/MsSqlPro/MsSqlProPageValuesGraphTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProPageValuesGraphTests : PageValuesGraphTestsBase { public MsSqlProPageValuesGraphTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProProQueryTests.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/MsSqlPro/MsSqlProProQueryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProProQueryTests : ProQueryTestsBase { public MsSqlProProQueryTests(MsSqlProFixture fixture) : base(fixture.Redb, isPro: true) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProProjectionTests.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/MsSqlPro/MsSqlProProjectionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProProjectionTests : ProjectionTestsBase { public MsSqlProProjectionTests(MsSqlProFixture fixture) : base(fixture.Redb) { } protected override bool ReadsOnlyProjectedRows => true; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropertyRenameTests.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/MsSqlPro/MsSqlProPropertyRenameTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProPropertyRenameTests : PropertyRenameTestsBase { public MsSqlProPropertyRenameTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsCacheHeaderTests.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/MsSqlPro/MsSqlProPropsCacheHeaderTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProPropsCacheHeaderTests : PropsCacheHeaderTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsCacheSkipValidationTests.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/MsSqlPro/MsSqlProPropsCacheSkipValidationTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProPropsCacheSkipValidationTests : PropsCacheSkipValidationTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsCacheTransactionKeepTests.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/MsSqlPro/MsSqlProPropsCacheTransactionKeepTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Pro.Extensions; using redb.Core.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProPropsCacheTransactionKeepTests : PropsCacheTransactionKeepTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsCacheTransactionTests.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/MsSqlPro/MsSqlProPropsCacheTransactionTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Pro.Extensions; using redb.Core.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProPropsCacheTransactionTests : PropsCacheTransactionTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPropsDepthBoundaryTests.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/MsSqlPro/MsSqlProPropsDepthBoundaryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProPropsDepthBoundaryTests : PropsDepthBoundaryTestsBase { public MsSqlProPropsDepthBoundaryTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPvtPrefilterEquivalenceTests.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/MsSqlPro/MsSqlProPvtPrefilterEquivalenceTests.cs ---- using redb.Core.Models.Contracts; using redb.Core.Models.Entities; using redb.Core.Query; using redb.Core.Query.Aggregation; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Helpers; using redb.Tests.Integration.Models; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProPvtPrefilterEquivalenceTests : PvtPrefilterEquivalenceTestsBase { public MsSqlProPvtPrefilterEquivalenceTests(MsSqlProFixture fixture) : base(fixture.Redb) { } /// See . [Fact] public Task UnfilteredExtremes_FirstEntryOfTheIndex_SameAnswers() => UnfilteredExtremes_FirstEntryOfTheIndex_SameAnswersAsync(); /// See . [Fact] public Task AllWithoutFilter_ProbeThenCounts_SameAnswers() => AllWithoutFilter_ProbeThenCounts_SameAnswersAsync(); /// /// An OR of narrow branches stays on the aggregate form, where the row prefilter reads every /// branch from the index of values; as streams it was checked above every object of the scheme /// (examples, three string branches: 1 694 ms against 95 ms). A narrow leaf in the top-level AND /// keeps the streams. Asserted on the SQL, and the answer must not change. /// [Fact] public async Task Streams_NarrowOrGoesToRowPrefilter_NarrowAndKeepsStreams() { await TestDataFactory.SeedEmployees(Redb, 40); var restore = Redb.Configuration.EnablePvtPrefilter; try { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); IRedbQueryable NarrowOr() => Redb.Query() .Where(e => e.Department == "Engineering" || e.Position == "Developer" || e.LastName == "Smith") .OrderByRedb(o => o.Id).Take(100); var narrowOr = await NarrowOr().ToSqlStringAsync(); narrowOr.Should().Contain("Streams not applied, the filter is an OR of narrow branches"); narrowOr.Should().Contain("-- PVT prefilter: Row form, 3 branch(es)"); var narrowAnd = await Redb.Query() .Where(e => e.Department == "Engineering" && (e.Age > 30 || e.Position == "Developer")) .OrderByRedb(o => o.Id).Take(100) .ToSqlStringAsync(); narrowAnd.Should().Contain("-- PVT form: Streams,", "an equality in the top-level AND is pushed into its stream"); var on = (await NarrowOr().ToListAsync()).Select(r => r.id).ToList(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = (await NarrowOr().ToListAsync()).Select(r => r.id).ToList(); on.Should().Equal(off, "the form changes the plan, not the answer"); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// A narrow leaf on an indexed column (a number here) drives the streams off the index of values, the trash subtracted: /// a count, an existence check, a page, a grouping, an aggregate. A text leaf does not: _String has no index of values on /// SQL Server. Next to a filter on the object's own fields that is wide by its shape (an id range) the leaf lifts FORCE /// ORDER and the index hint; next to one narrow by its shape (an IN list of ids) the forced order stays. An object in the /// trash holds the value of the leaf, and a page also requires a field absent. Every answer must equal the one with the /// prefilter off. /// [Fact] public async Task DrivingLeaf_IndexedLeafOnly_TrashSubtracted_SameAnswers() { var ids = await TestDataFactory.SeedEmployees(Redb, 40); var victim = ids[1]; var age = (await Redb.Query().WhereRedb(o => o.Id == victim).ToListAsync()).Single().Props.Age; await Redb.SoftDeleteAsync(new[] { victim, ids[7] }); var some = ids.Skip(10).Take(15).ToList(); const string driven = "FROM (SELECT dv._id_object AS _id"; const string trash = "NOT IN (SELECT t._id FROM _objects t WHERE t._id_scheme = -10)"; var restore = Redb.Configuration.EnablePvtPrefilter; try { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); IRedbQueryable Aged() => Redb.Query().Where(e => e.Age == age); var page = await Aged().Take(10).ToSqlStringAsync(); page.Should().Contain(driven).And.Contain(trash).And.NotContain("FORCE ORDER"); (await Aged().GroupBy(e => e.Department).ToSqlStringAsync(g => new { g.Key, C = Agg.Count(g) })) .Should().Contain(driven, "a grouping reads its objects off the leaf as well"); (await Aged().ToAggregateSqlStringAsync(x => new { S = Agg.Sum(x.Props.Salary) })) .Should().Contain(driven, "an aggregate reads its objects off the leaf as well"); (await Redb.Query().Where(e => e.Department == "Engineering").Take(10).ToSqlStringAsync()) .Should().NotContain(driven, "a text leaf has no index of values to drive from"); var range = await Aged().WhereRedb(o => o.Id > 0).Take(10).ToSqlStringAsync(); range.Should().NotContain(driven, "the objects drive under WhereRedb").And.NotContain("FORCE ORDER") .And.NotContain("WITH (INDEX(", "a range of ids is wide by its shape, the leaf lifts the forced order"); (await Aged().WhereRedb(o => some.Contains(o.Id)).Take(10).ToSqlStringAsync()) .Should().Contain("FORCE ORDER", "an IN list of ids is narrow by its shape and keeps the forced order"); (await Redb.Query().Where(e => e.Department == "Engineering").WhereRedb(o => o.Id > 0).Take(10).ToSqlStringAsync()) .Should().Contain("FORCE ORDER", "a text leaf does not lift the forced order"); static string Ids(IEnumerable rows) => string.Join(",", rows.Select(r => r.Id)); static string Groups(IEnumerable rows) => string.Join(",", rows.Select(r => r!.ToString()).OrderBy(s => s, StringComparer.Ordinal)); async Task AnswersAsync() => string.Join("; ", new[] { $"count {await Aged().CountAsync()}", $"any {await Aged().AnyAsync()}", $"page {Ids(await Aged().Take(10).ToListAsync())}", $"by salary {Ids(await Aged().OrderBy(e => e.Salary).ThenByRedb(o => o.Id).Take(5).ToListAsync())}", $"absent {Ids(await Aged().Where(e => e.EmployeeCode == null).Take(10).ToListAsync())}", $"group {Groups(await Aged().GroupBy(e => e.Department).SelectAsync(g => new { g.Key, C = Agg.Count(g) }))}", $"sum {(await Aged().AggregateAsync(x => new { S = Agg.Sum(x.Props.Salary) })).S}", $"range {await Aged().WhereRedb(o => o.Id > 0).CountAsync()}", $"in list {await Aged().WhereRedb(o => some.Contains(o.Id)).CountAsync()}", $"range group {Groups(await Aged().WhereRedb(o => o.Id > 0).GroupBy(e => e.Department).SelectAsync(g => new { g.Key, C = Agg.Count(g) }))}", }); var on = await AnswersAsync(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = await AnswersAsync(); on.Should().Be(off, "driving off the leaf and lifting the forced order change the plan, not the answer"); on.Should().NotStartWith("count 0", "the seed has live employees of the victim's age"); (await Redb.Query().WhereRedb(o => o.Id == victim).CountAsync()).Should().Be(0, "the victim is in the trash"); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// A page sorted by a Props field and then by others (ThenBy) is led by the first field as a batch: /// the walk fills a table variable, the streams fill it when the walk did not. Without ThenBy the /// streams stay, SQL Server walks the index on its own there. Compared by the sequence of all keys, /// ThenBy Id included. /// [Fact] public async Task LeadingForm_ThenBy_SameKeysAsAggregateForm() { await TestDataFactory.SeedEmployees(Redb, 40); var restore = Redb.Configuration.EnablePvtPrefilter; try { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); IRedbQueryable Page(int skip) => Redb.Query() .Where(e => e.Salary > 0m && e.Age >= 20) .OrderByDescending(e => e.Salary).ThenBy(e => e.Age).ThenBy(e => e.LastName) .Skip(skip).Take(10); IRedbQueryable ById() => Redb.Query() .Where(e => e.Age >= 20) .OrderBy(e => e.Age).ThenByRedb(o => o.Id) .Take(10); var sql = await Page(0).ToSqlStringAsync(); sql.Should().Contain("-- PVT leading form:"); sql.Should().Contain("@pvt_bound", "with ThenBy the walk reads the run it stops in to the end"); var withoutThenBy = await Redb.Query() .Where(e => e.Salary > 0m && e.Age >= 20) .OrderByDescending(e => e.Salary).Take(10) .ToSqlStringAsync(); withoutThenBy.Should().NotContain("-- PVT leading form:", "without ThenBy SQL Server walks the index itself"); foreach (var skip in new[] { 0, 5 }) { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var on = (await Page(skip).ToListAsync()).Select(r => (r.Props.Salary, r.Props.Age, r.Props.LastName)).ToList(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = (await Page(skip).ToListAsync()).Select(r => (r.Props.Salary, r.Props.Age, r.Props.LastName)).ToList(); on.Should().Equal(off, $"the leading form changes the plan, not the order (Skip {skip})"); } Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); (await ById().ToSqlStringAsync()).Should().Contain("-- PVT leading form:"); var onIds = (await ById().ToListAsync()).Select(r => r.Id).ToList(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var offIds = (await ById().ToListAsync()).Select(r => r.Id).ToList(); onIds.Should().Equal(offIds, "ThenBy Id orders the run of equal ages by id in both forms"); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// With ThenBy the walk of the leading form reads on to the end of the run of equal sort values it /// stops in. Take 10 walks 1 000 entries: 5 objects at the top value, then a run of 1 200 equal values /// whose smallest titles sit past the first thousand entries. A run longer than twice the walk (2 100 /// objects) leaves the page to the streams. Both pages are compared with the prefilter off. /// [Fact] public async Task LeadingForm_ThenBy_RunOfEqualValuesAtTheBound() { const long top = 9_000_100, run = 9_000_090, longRun = 9_000_080; var objects = new List>(); void Add(long value, int count) { // Titles fall as the objects are created, so the first titles of a run are its last entries. for (var i = 0; i < count; i++) objects.Add(new RedbObject { name = $"run-{value}-{i}", Props = new SimpleProps { Title = $"t{value}-{count - i:D5}", OptionalNumber = value } }); } Add(top, 5); Add(run, 1200); Add(longRun, 2100); await Redb.SaveAsync(objects); var restore = Redb.Configuration.EnablePvtPrefilter; try { IRedbQueryable Run() => Redb.Query() .Where(p => p.OptionalNumber >= run) .OrderByDescending(p => p.OptionalNumber).ThenBy(p => p.Title) .Take(10); IRedbQueryable LongRun() => Redb.Query() .Where(p => p.OptionalNumber >= longRun) .OrderBy(p => p.OptionalNumber).ThenBy(p => p.Title) .Take(10); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); (await Run().ToSqlStringAsync()).Should().Contain("-- PVT leading form:"); foreach (var (name, page) in new[] { ("run", (Func>)Run), ("long run", LongRun) }) { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var on = (await page().ToListAsync()).Select(r => (r.Props.OptionalNumber, r.Props.Title)).ToList(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = (await page().ToListAsync()).Select(r => (r.Props.OptionalNumber, r.Props.Title)).ToList(); on.Should().HaveCount(10); on.Should().Equal(off, $"the leading form changes the plan, not the order ({name})"); } } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProPvtPrefilterListItemTests.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/MsSqlPro/MsSqlProPvtPrefilterListItemTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProPvtPrefilterListItemTests : PvtPrefilterListItemTestsBase { public MsSqlProPvtPrefilterListItemTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProQueryOrderTests.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/MsSqlPro/MsSqlProQueryOrderTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProQueryOrderTests : QueryOrderTestsBase { public MsSqlProQueryOrderTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProQueryPlannerBlockTests.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/MsSqlPro/MsSqlProQueryPlannerBlockTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProQueryPlannerBlockTests : QueryPlannerBlockTestsBase { public MsSqlProQueryPlannerBlockTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProRareRangePagesTests.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/MsSqlPro/MsSqlProRareRangePagesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProRareRangePagesTests : RareRangePagesTestsBase { public MsSqlProRareRangePagesTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProReaderConnectionTests.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/MsSqlPro/MsSqlProReaderConnectionTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProReaderConnectionTests : ReaderConnectionTestsBase { protected override string SlowScalarSql => "WAITFOR DELAY '00:00:02'; SELECT CAST(1 AS bigint)"; protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProRedundantArrayGuardTests.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/MsSqlPro/MsSqlProRedundantArrayGuardTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProRedundantArrayGuardTests : RedundantArrayGuardTestsBase { public MsSqlProRedundantArrayGuardTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProReferenceListSaveTests.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/MsSqlPro/MsSqlProReferenceListSaveTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProReferenceListSaveTests : ReferenceListSaveTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProRegexQueryTests.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/MsSqlPro/MsSqlProRegexQueryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProRegexQueryTests : RegexQueryTestsBase { public MsSqlProRegexQueryTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProRowMapperKindsTests.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/MsSqlPro/MsSqlProRowMapperKindsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProRowMapperKindsTests : RowMapperKindsTestsBase { public MsSqlProRowMapperKindsTests(MsSqlProFixture fixture) : base(fixture.Redb) { } protected override string KindsSql => @"SELECT CAST(1 AS bigint) AS _id, CAST(7 AS bigint) AS count, CAST(NULL AS bigint) AS maybe_long, CAST(12.50 AS decimal(18,2)) AS amount, CAST(1.5 AS float) AS from_double, CAST(0.25 AS float) AS ratio, CAST(1 AS bit) AS flag, CAST('6f1d0c3e-2b4a-4c8e-9a51-3d2f7e8b9c01' AS uniqueidentifier) AS key_value, CAST('2026-01-02T03:04:05+00:00' AS datetimeoffset) AS when_at, CAST(NULL AS datetime2) AS day, 0x0102 AS bytes, 'abc' AS NAME, 'shown' AS display_name, CAST('2026-03-04T00:00:00' AS datetime2) AS first_seen, 'x' AS zzz"; protected override string EnumSql => "SELECT 2 AS kind"; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSaveGraphHashTests.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/MsSqlPro/MsSqlProSaveGraphHashTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProSaveGraphHashTests : SaveGraphHashTestsBase { public MsSqlProSaveGraphHashTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSaveInterceptorTests.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/MsSqlPro/MsSqlProSaveInterceptorTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Models.Configuration; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProSaveInterceptorTests : SaveInterceptorTestsBase { protected override string ConnectionStringName => "MSSql"; protected override PropsSaveStrategy Strategy => PropsSaveStrategy.ChangeTracking; protected override void AddRedbServices(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options, string connectionString) => options.UseMsSql(connectionString); } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSaveLockScopeTests.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/MsSqlPro/MsSqlProSaveLockScopeTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Pro.Extensions; using redb.Core.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProSaveLockScopeTests : SaveLockScopeTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSchemaUpgradeTests.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/MsSqlPro/MsSqlProSchemaUpgradeTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; /// /// MSSQL Pro never opted out of the module deployment the way the PostgreSQL and SQLite Pro /// services did, so this suite starts green - it exists to keep it that way: the upgrade contract /// belongs to every tier, and the two providers that skipped it left existing databases without the /// V4 columns. Owns its own database and login. /// public class MsSqlProSchemaUpgradeTests : redb.Tests.Integration.Tests.MsSql.MsSqlSchemaUpgradeTests { public MsSqlProSchemaUpgradeTests(SchemaUpgradeCleanup cleanup) : base(cleanup) { } protected override string DatabaseName => $"redb_upgrade_pro_{RunSuffix}"; protected override string FreshDatabaseName => $"redb_upgrade_pro_fresh_{RunSuffix}"; protected override string RestrictedLogin => $"redb_noddl_pro_{RunSuffix}"; protected override string ContainedDatabaseName => $"redb_upgrade_pro_contained_{RunSuffix}"; protected override void AddRedbServices(IServiceCollection services, Action configure) => services.AddRedbPro(configure); // Resolves to the Pro overload through this file's using of redb.MSSql.Pro.Extensions. protected override void UseProvider(RedbOptionsBuilder options, string connectionString) => options.UseMsSql(connectionString); } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSchemeLoadValidationTests.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/MsSqlPro/MsSqlProSchemeLoadValidationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProSchemeLoadValidationTests : SchemeLoadValidationTestsBase { public MsSqlProSchemeLoadValidationTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSchemeNamingTests.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/MsSqlPro/MsSqlProSchemeNamingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProSchemeNamingTests : SchemeNamingTestsBase { public MsSqlProSchemeNamingTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSchemeRenameTests.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/MsSqlPro/MsSqlProSchemeRenameTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProSchemeRenameTests : SchemeRenameTestsBase { public MsSqlProSchemeRenameTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSmallSaveTimingTests.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/MsSqlPro/MsSqlProSmallSaveTimingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; using Xunit.Abstractions; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProSmallSaveTimingTests : SmallSaveTimingTestsBase { public MsSqlProSmallSaveTimingTests(MsSqlProFixture fixture, ITestOutputHelper output) : base(fixture.ServiceProvider, output) { } protected override string? PlanCacheReportSql => MsSql.MsSqlPlanCache.InsertReport; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProStringMatchContractTests.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/MsSqlPro/MsSqlProStringMatchContractTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProStringMatchContractTests : MsSqlStringMatchContractTestsBase { public MsSqlProStringMatchContractTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSubSecondUpdateTests.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/MsSqlPro/MsSqlProSubSecondUpdateTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Models.Configuration; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProSubSecondUpdateTests : SubSecondUpdateTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override PropsSaveStrategy SaveStrategy => PropsSaveStrategy.ChangeTracking; protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProSyncLoadTests.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/MsSqlPro/MsSqlProSyncLoadTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProSyncLoadTests : ProSyncLoadTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTagsFieldTests.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/MsSqlPro/MsSqlProTagsFieldTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProTagsFieldTests : TagsFieldTestsBase { public MsSqlProTagsFieldTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTemporalRoundTripTests.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/MsSqlPro/MsSqlProTemporalRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProTemporalRoundTripTests : TemporalRoundTripTestsBase { public MsSqlProTemporalRoundTripTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTimeTicksTests.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/MsSqlPro/MsSqlProTimeTicksTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProTimeTicksTests : TimeTicksTestsBase { public MsSqlProTimeTicksTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTrashPurgeTests.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/MsSqlPro/MsSqlProTrashPurgeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProTrashPurgeTests : TrashPurgeTestsBase { public MsSqlProTrashPurgeTests(MsSqlProFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTrashedReferenceTargetTests.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/MsSqlPro/MsSqlProTrashedReferenceTargetTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.MSSql.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; public class MsSqlProTrashedReferenceTargetTests : TrashedReferenceTargetTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override bool ProPropsCache => true; protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("MSSql")!; options.UseMsSql(cs); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeAggregateTests.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/MsSqlPro/MsSqlProTreeAggregateTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProTreeAggregateTests : TreeAggregateTestsBase { public MsSqlProTreeAggregateTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeDistinctTests.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/MsSqlPro/MsSqlProTreeDistinctTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProTreeDistinctTests : TreeDistinctTestsBase { public MsSqlProTreeDistinctTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeLevelAnalyticsTests.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/MsSqlPro/MsSqlProTreeLevelAnalyticsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProTreeLevelAnalyticsTests : TreeLevelAnalyticsTestsBase { public MsSqlProTreeLevelAnalyticsTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeOrderAndPreviewTests.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/MsSqlPro/MsSqlProTreeOrderAndPreviewTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProTreeOrderAndPreviewTests : TreeOrderAndPreviewTestsBase { public MsSqlProTreeOrderAndPreviewTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeQueryShapesTests.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/MsSqlPro/MsSqlProTreeQueryShapesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProTreeQueryShapesTests : TreeQueryShapesTestsBase { public MsSqlProTreeQueryShapesTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTreeTests.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/MsSqlPro/MsSqlProTreeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProTreeTests : ProTreeTestsBase { public MsSqlProTreeTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProTypeChangeTicksAndKeysTests.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/MsSqlPro/MsSqlProTypeChangeTicksAndKeysTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProTypeChangeTicksAndKeysTests : TypeChangeTicksAndKeysTestsBase { public MsSqlProTypeChangeTicksAndKeysTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } protected override string TextType => "NVARCHAR(100)"; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProUniqueKeyTests.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/MsSqlPro/MsSqlProUniqueKeyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProUniqueKeyTests : UniqueKeyTestsBase { public MsSqlProUniqueKeyTests(MsSqlProFixture fixture) : base(fixture.Redb) { } protected override string BoolTrue => "1"; // ChangeTracking: see PostgresProUniqueKeyTests. protected override bool KeySwapMustPass => false; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProUnregisteredTreeTargetTests.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/MsSqlPro/MsSqlProUnregisteredTreeTargetTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProUnregisteredTreeTargetTests : UnregisteredTreeTargetTestsBase { public MsSqlProUnregisteredTreeTargetTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProUserConfigurationServiceTests.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/MsSqlPro/MsSqlProUserConfigurationServiceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProUserConfigurationServiceTests : UserConfigurationServiceTestsBase { public MsSqlProUserConfigurationServiceTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProValueOnlyObjectSaveTests.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/MsSqlPro/MsSqlProValueOnlyObjectSaveTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProValueOnlyObjectSaveTests : ValueOnlyObjectSaveTestsBase { public MsSqlProValueOnlyObjectSaveTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProValueUniqueTests.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/MsSqlPro/MsSqlProValueUniqueTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProValueUniqueTests : ValueUniqueTestsBase { public MsSqlProValueUniqueTests(MsSqlProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProValuesFkIndexesTests.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/MsSqlPro/MsSqlProValuesFkIndexesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProValuesFkIndexesTests : ValuesFkIndexesTestsBase { public MsSqlProValuesFkIndexesTests(MsSqlProFixture fixture) : base(fixture.Redb) { } protected override async Task IndexExistsAsync(string indexName) => await Redb.Context.ExecuteScalarAsync( "SELECT COUNT(*) FROM sys.indexes WHERE name = '{0}'".Replace("{0}", indexName)) > 0; } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProWhereTests.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/MsSqlPro/MsSqlProWhereTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProWhereTests : WhereTestsBase { public MsSqlProWhereTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProWholeSchemeGroupingHintTests.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/MsSqlPro/MsSqlProWholeSchemeGroupingHintTests.cs ---- using redb.Core; using redb.Core.Models.Entities; using redb.Core.Query.Aggregation; using redb.Core.Query.Window; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Helpers; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.MsSqlPro; /// /// A GroupBy over the whole scheme on the streams source (planner on) closes with hash joins: with two or more fields /// the optimizer otherwise joined their value rows many-to-many through worktables (E130a). Any condition, the aggregate /// pivot of the planner-off pass, a window over the groups and a tree keep the statement as it was. /// [Collection("MsSqlPro")] public class MsSqlProWholeSchemeGroupingHintTests { private const string Hint = "OPTION (HASH JOIN, MAXDOP 1)"; private readonly IRedbService _redb; public MsSqlProWholeSchemeGroupingHintTests(MsSqlProFixture fixture) => _redb = fixture.Redb; [Fact] public async Task WholeSchemeGrouping_TakesTheHashJoinHint_OnlyOnTheStreamsSource() { await _redb.SyncSchemeAsync(); var sql = await _redb.Query() .GroupBy(e => new { e.Department, e.Position }) .ToSqlStringAsync(g => new { g.Key.Department, g.Key.Position, Total = Agg.Sum(g, e => e.Salary), Count = Agg.Count(g) }); if (ProTestOptions.PvtPrefilter) sql.TrimEnd().Should().EndWith(Hint); else sql.Should().NotContain("HASH JOIN", "the aggregate pivot lost with hash joins (1.7 s -> 6.3 s)"); } [Fact] public async Task WholeSchemeGroupingWithHaving_TakesTheHint_OnlyOnTheStreamsSource() { await _redb.SyncSchemeAsync(); var sql = await _redb.Query() .GroupBy(e => e.Department) .Having(g => Agg.Count(g) > 5) .ToSqlStringAsync(g => new { Department = g.Key, Count = Agg.Count(g) }); if (ProTestOptions.PvtPrefilter) sql.TrimEnd().Should().EndWith(Hint); else sql.Should().NotContain("HASH JOIN"); } [Fact] public async Task GroupingWithAWhere_KeepsItsStatement() { await _redb.SyncSchemeAsync(); var sql = await _redb.Query() .Where(e => e.Salary > 60000m) .GroupBy(e => new { e.Department, e.Position }) .ToSqlStringAsync(g => new { g.Key.Department, g.Key.Position, Count = Agg.Count(g) }); sql.Should().NotContain("HASH JOIN"); } [Fact] public async Task GroupingWithABaseFieldCondition_KeepsItsStatement() { await _redb.SyncSchemeAsync(); var sql = await _redb.Query() .WhereRedb(o => o.Id > 0) .GroupBy(e => new { e.Department, e.Position }) .ToSqlStringAsync(g => new { g.Key.Department, g.Key.Position, Count = Agg.Count(g) }); sql.Should().NotContain("HASH JOIN"); } [Fact] public async Task WindowOverTheGroups_KeepsItsStatement() { await _redb.SyncSchemeAsync(); var sql = await _redb.Query() .GroupBy(e => e.Department) .WithWindow(w => w.OrderByDesc(g => Agg.Sum(g, e => e.Salary))) .ToSqlStringAsync(g => new { Department = g.Key, Total = Agg.Sum(g, e => e.Salary), Rank = Win.Rank() }); sql.Should().NotContain("HASH JOIN"); } [Fact] public async Task TreeGrouping_KeepsItsStatement() { await _redb.SyncSchemeAsync(); var root = new TreeRedbObject { name = "grp-hint-root-" + Guid.NewGuid().ToString("N")[..8], Props = TestDataFactory.CreateEmployee(0).Props }; root.id = await _redb.SaveAsync(root); var sql = await _redb.TreeQuery(root.id) .GroupBy(e => new { e.Department, e.Position }) .ToSqlStringAsync(g => new { g.Key.Department, g.Key.Position, Count = Agg.Count(g) }); sql.Should().NotContain("HASH JOIN"); } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProWideEqualityLeadsTests.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/MsSqlPro/MsSqlProWideEqualityLeadsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProWideEqualityLeadsTests : WideEqualityLeadsTestsBase { public MsSqlProWideEqualityLeadsTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProWindowTests.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/MsSqlPro/MsSqlProWindowTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.MsSqlPro; [Collection("MsSqlPro")] public class MsSqlProWindowTests : ProWindowTestsBase { public MsSqlProWindowTests(MsSqlProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAbsentValuesTests.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/Postgres/PostgresAbsentValuesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresAbsentValuesTests : AbsentValuesTestsBase { public PostgresAbsentValuesTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAggregatePathTests.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/Postgres/PostgresAggregatePathTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresAggregatePathTests : AggregatePathTestsBase { public PostgresAggregatePathTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAggregatePreviewTests.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/Postgres/PostgresAggregatePreviewTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresAggregatePreviewTests : FreeAggregatePreviewTestsBase { public PostgresAggregatePreviewTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAggregationOverArrayTests.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/Postgres/PostgresAggregationOverArrayTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresAggregationOverArrayTests : AggregationOverArrayTestsBase { public PostgresAggregationOverArrayTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAggregationTests.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/Postgres/PostgresAggregationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresAggregationTests : AggregationTestsBase { public PostgresAggregationTests(PostgresFixture fixture) : base(fixture.Redb, isPro: false) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAmbientTransactionTests.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/Postgres/PostgresAmbientTransactionTests.cs ---- using redb.Core.Data; using redb.Postgres.Data; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresAmbientTransactionTests : AmbientTransactionTestsBase { public PostgresAmbientTransactionTests(PostgresFixture fixture) : base(fixture.ServiceProvider) { } protected override string CreateProbeTableSql => "CREATE TABLE IF NOT EXISTS ambient_tx_rows (tag varchar(100) NOT NULL)"; protected override string SlowStatementSql => "SELECT 1 FROM pg_sleep(2)"; protected override IRedbConnection CreateStandaloneConnection(IServiceProvider services, bool differentSessionSettings) => new NpgsqlRedbConnection(NpgsqlDataSourceFactory.Create( ConnString("Postgres"), stringCollation: null, lazyReferences: differentSessionSettings)); } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAnalyticsTelemetryTests.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/Postgres/PostgresAnalyticsTelemetryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresAnalyticsTelemetryTests : AnalyticsTelemetryTestsBase { public PostgresAnalyticsTelemetryTests(PostgresFixture fixture) : base(fixture.Redb) { } protected override int CommandsPerCall => 2; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresAnyExistsTests.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/Postgres/PostgresAnyExistsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresAnyExistsTests : FreeAnyExistsTestsBase { public PostgresAnyExistsTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayAnyTests.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/Postgres/PostgresArrayAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresArrayAnyTests : ArrayAnyTestsBase { public PostgresArrayAnyTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayGroupByDeepTests.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/Postgres/PostgresArrayGroupByDeepTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresArrayGroupByDeepTests : ArrayGroupByDeepTestsBase { public PostgresArrayGroupByDeepTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayGroupModuleGuardTests.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/Postgres/PostgresArrayGroupModuleGuardTests.cs ---- using redb.Core; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Postgres; /// /// A14: the free module's array grouping refuses, with a reason, what it cannot answer instead of reading it as a /// field with no rows: an unknown '$' token, '$element' on an array of classes, a field of an array of simple values, /// a field the elements do not have, a dictionary in the array path. The core refuses these forms before they reach /// SQL, so the function is called directly - the SQL is the public surface for callers that submit the JSON themselves. /// [Collection("Postgres")] public class PostgresArrayGroupModuleGuardTests { private readonly IRedbService _redb; public PostgresArrayGroupModuleGuardTests(PostgresFixture fixture) => _redb = fixture.Redb; private async Task BuildAsync(string arrayPath, string groupByJson) { var scheme = await _redb.SyncSchemeAsync(); return await _redb.Context.ExecuteScalarAsync( "SELECT pvt_build_array_groupby_sql(" + scheme.Id + ", $1::text, NULL::jsonb, $2::jsonb, NULL::jsonb)", new object[] { arrayPath, groupByJson }); } [Theory] [InlineData("Contacts", "[{\"field\":\"$foo\",\"alias\":\"x\"}]", "*\"$foo\" is not a field of the elements of \"Contacts\"*")] [InlineData("Contacts", "[{\"field\":\"$element\",\"alias\":\"x\"}]", "*\"$element\" names the element itself*")] [InlineData("Skills", "[{\"field\":\"Name\",\"alias\":\"x\"}]", "*simple values and have no field \"Name\"*")] [InlineData("Contacts.Metadata", "[{\"field\":\"Type\",\"alias\":\"x\"}]", "*\"Type\" is not a field of the elements of \"Contacts.Metadata\"*")] [InlineData("PhoneDirectory", "[{\"field\":\"$element\",\"alias\":\"x\"}]", "*dictionary*")] [InlineData("HomeAddress", "[{\"field\":\"City\",\"alias\":\"x\"}]", "*\"HomeAddress\" is not an array*")] public async Task WhatItCannotAnswer_IsRefusedWithAReason(string arrayPath, string groupByJson, string message) { var act = async () => await BuildAsync(arrayPath, groupByJson); (await act.Should().ThrowAsync()).Which.Message.Should().Match(message); } [Fact] public async Task AnInnerArrayAndTheElementOfASimpleArray_AreBuilt() { (await BuildAsync("Contacts.Metadata", "[{\"field\":\"Label\",\"alias\":\"Label\"}]")).Should().Contain("GROUP BY"); (await BuildAsync("Skills", "[{\"field\":\"$element\",\"alias\":\"Skill\"}]")).Should().Contain("GROUP BY"); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayOfClassesAnyTests.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/Postgres/PostgresArrayOfClassesAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresArrayOfClassesAnyTests : ArrayOfClassesAnyTestsBase { public PostgresArrayOfClassesAnyTests(PostgresFixture fixture) : base(fixture.Redb) { } protected override bool ReadsAnyOverClasses => false; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresArrayTests.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/Postgres/PostgresArrayTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresArrayTests : ArrayTestsBase { public PostgresArrayTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresBareRedbObjectFieldTests.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/Postgres/PostgresBareRedbObjectFieldTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresBareRedbObjectFieldTests : BareRedbObjectFieldTestsBase { public PostgresBareRedbObjectFieldTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresBaseFieldNameCollisionTests.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/Postgres/PostgresBaseFieldNameCollisionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresBaseFieldNameCollisionTests : BaseFieldNameCollisionTestsBase { public PostgresBaseFieldNameCollisionTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresBugRegressionTests.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/Postgres/PostgresBugRegressionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresBugRegressionTests : BugRegressionTestsBase { public PostgresBugRegressionTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresBytesRoundTripTests.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/Postgres/PostgresBytesRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresBytesRoundTripTests : BytesRoundTripTestsBase { public PostgresBytesRoundTripTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresCacheBehaviorTests.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/Postgres/PostgresCacheBehaviorTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresCacheBehaviorTests : CacheBehaviorTestsBase { public PostgresCacheBehaviorTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresCancellationTests.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/Postgres/PostgresCancellationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresCancellationTests : CancellationTestsBase { public PostgresCancellationTests(PostgresFixture fixture) : base(fixture.Redb) { } protected override string? SleepSql => "SELECT pg_sleep(30)"; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresColdSchemeLinkedObjectTests.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/Postgres/PostgresColdSchemeLinkedObjectTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresColdSchemeLinkedObjectTests : ColdSchemeLinkedObjectTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresColdSchemeTreeFilterTests.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/Postgres/PostgresColdSchemeTreeFilterTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresColdSchemeTreeFilterTests : ColdSchemeTreeFilterTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresCollectionFilterAnalyticsTests.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/Postgres/PostgresCollectionFilterAnalyticsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresCollectionFilterAnalyticsTests : CollectionFilterAnalyticsTestsBase { public PostgresCollectionFilterAnalyticsTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresComputedComparisonTests.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/Postgres/PostgresComputedComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresComputedComparisonTests : ComputedComparisonTestsBase { public PostgresComputedComparisonTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresConcurrencyStressTests.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/Postgres/PostgresConcurrencyStressTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresConcurrencyStressTests : ConcurrencyStressTestsBase { public PostgresConcurrencyStressTests(PostgresFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresConcurrentDeleteCountTests.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/Postgres/PostgresConcurrentDeleteCountTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresConcurrentDeleteCountTests : ConcurrentDeleteCountTestsBase { public PostgresConcurrentDeleteCountTests(PostgresFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } protected override async Task HoldRowAsync(long objectId) => await RowHolders.PostgresAsync(objectId); } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresConcurrentDeleteListTests.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/Postgres/PostgresConcurrentDeleteListTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresConcurrentDeleteListTests : ConcurrentDeleteListTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresConcurrentWritersTests.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/Postgres/PostgresConcurrentWritersTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresConcurrentWritersTests : ConcurrentWritersTestsBase { public PostgresConcurrentWritersTests(PostgresFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresConnectionTeardownTests.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/Postgres/PostgresConnectionTeardownTests.cs ---- using System.Globalization; using redb.Core.Data; using redb.Postgres.Data; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresConnectionTeardownTests : ConnectionTeardownTestsBase { protected override IRedbConnection CreateConnection() => new NpgsqlRedbConnection(ConnString("Postgres")); protected override string SleepSql(double seconds) => $"SELECT COUNT(*) FROM pg_sleep({seconds.ToString(CultureInfo.InvariantCulture)})"; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresConstantPredicateTests.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/Postgres/PostgresConstantPredicateTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresConstantPredicateTests : ConstantPredicateTestsBase { public PostgresConstantPredicateTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresCrudTests.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/Postgres/PostgresCrudTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresCrudTests : CrudTestsBase { public PostgresCrudTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresCtSaveInvariantsTests.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/Postgres/PostgresCtSaveInvariantsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresCtSaveInvariantsTests : CtSaveInvariantsTestsBase { public PostgresCtSaveInvariantsTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresDbInfoTests.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/Postgres/PostgresDbInfoTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresDbInfoTests : DbInfoTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } protected override string VersionMarker => "PostgreSQL"; protected override string SizeInBytesSql => "SELECT pg_database_size(current_database())"; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresDecimalRoundTripTests.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/Postgres/PostgresDecimalRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresDecimalRoundTripTests : DecimalRoundTripTestsBase { public PostgresDecimalRoundTripTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresDeleteBatchCountTests.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/Postgres/PostgresDeleteBatchCountTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresDeleteBatchCountTests : DeleteBatchCountTestsBase { public PostgresDeleteBatchCountTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresDeleteSubtreeCountTests.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/Postgres/PostgresDeleteSubtreeCountTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresDeleteSubtreeCountTests : DeleteSubtreeCountTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresDictionaryOrderTests.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/Postgres/PostgresDictionaryOrderTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresDictionaryOrderTests : DictionaryOrderTestsBase { public PostgresDictionaryOrderTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresDictionaryTests.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/Postgres/PostgresDictionaryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresDictionaryTests : DictionaryTestsBase { public PostgresDictionaryTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresDisposedScopeGuardTests.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/Postgres/PostgresDisposedScopeGuardTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresDisposedScopeGuardTests : DisposedScopeGuardTestsBase { public PostgresDisposedScopeGuardTests(PostgresFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresExportForeignKeyTests.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/Postgres/PostgresExportForeignKeyTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Npgsql; using redb.Core; using redb.Core.Extensions; using redb.Core.Models.Entities; using redb.Export.Providers; using redb.Export.Services; using redb.Postgres.Extensions; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Postgres; /// /// redb.Export loads PostgreSQL with the foreign key triggers off, because the file order needs it: roles point at /// objects that come later, children may come before their parents. Switching the triggers back on checks nothing, /// so a file with a reference to a row it does not hold loaded silently, while SQL Server refused the same file. /// The import now checks every key of the redb tables at the end and refuses such a file by name. Each test runs on /// scratch databases of its own, dropped afterwards. /// public class PostgresExportForeignKeyTests : IAsyncLifetime { private const long Missing = 999_999_999; private string _server = null!; private readonly List _databases = []; private readonly List _files = []; public Task InitializeAsync() { var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); _server = config.GetConnectionString("Postgres")!; return Task.CompletedTask; } public async Task DisposeAsync() { NpgsqlConnection.ClearAllPools(); foreach (var database in _databases) await ExecuteAsync(Maintenance(), $"DROP DATABASE IF EXISTS \"{database}\" WITH (FORCE)"); foreach (var file in _files) File.Delete(file); } [Fact] public async Task ASerialImport_OfAFileWithAMissingParent_IsRefusedByKeyName_AndChangesNothing() { var (file, childId) = await ExportWithMissingParentAsync(); var target = await NewTargetWithOneObjectAsync(); var key = await ParentKeyNameAsync(target); var before = await ScalarAsync(target, "SELECT count(*) FROM _objects"); var importing = async () => await ImportAsync(target, file, parallelism: 1); var refusal = await importing.Should().ThrowAsync(); refusal.Which.Message.Should() .Contain($"{key}: 1 row(s) of _objects point at a missing row of _objects (_id)") .And.Contain($"_id = {childId}, _id_parent = {Missing}") .And.Contain("Nothing was imported; the database is unchanged."); (await ScalarAsync(target, "SELECT count(*) FROM _objects")).Should().Be(before, "the refusal rolls back the whole import, the cleaning included"); (await ScalarAsync(target, "SELECT count(*) FROM _objects WHERE _name = 'already-here'")).Should().Be(1); } [Fact] public async Task AParallelImport_OfAFileWithAMissingParent_IsRefusedByKeyName_AndSaysTheRowsAreWritten() { var (file, childId) = await ExportWithMissingParentAsync(); var target = await NewTargetWithOneObjectAsync(); var key = await ParentKeyNameAsync(target); var importing = async () => await ImportAsync(target, file, parallelism: 2); var refusal = await importing.Should().ThrowAsync(); refusal.Which.Message.Should() .Contain($"{key}: 1 row(s) of _objects point at a missing row of _objects (_id)") .And.Contain($"_id = {childId}, _id_parent = {Missing}") .And.Contain("The parallel import has already written its rows"); (await ScalarAsync(target, "SELECT count(*) FROM pg_indexes WHERE tablename IN ('_objects', '_values')")) .Should().BeGreaterThan(0, "the indexes are rebuilt before the check, so a refused parallel import leaves them in place"); } [Fact] public async Task AFileExportedWithSchemes_WhoseObjectPointsIntoASchemeLeftOut_IsRefused_NamingTheReference() { var source = await NewDatabaseAsync("src"); long parentId, childId; await using (var provider = Build(source)) { var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); await redb.SyncSchemeAsync(); parentId = await redb.SaveAsync(new RedbObject { name = "parent-left-out", Props = new CityProps { Name = "c" } }); childId = await redb.SaveAsync(new RedbObject { name = "child-exported", parent_id = parentId, Props = new SimpleProps { Title = "t" } }); } var simpleScheme = await ScalarAsync(source, "SELECT min(_id) FROM _schemes WHERE _name LIKE '%SimpleProps%'"); var file = await ExportAsync(source, [simpleScheme]); var target = await NewTargetWithOneObjectAsync(); var key = await ParentKeyNameAsync(target); var importing = async () => await ImportAsync(target, file, parallelism: 1); var refusal = await importing.Should().ThrowAsync(); refusal.Which.Message.Should() .Contain("--schemes") .And.Contain($"{key}: 1 row(s) of _objects point at a missing row of _objects (_id)") .And.Contain($"_id = {childId}, _id_parent = {parentId}"); } [Theory] [InlineData(1)] [InlineData(2)] public async Task AWholeFile_WithChildrenBeforeTheirParents_StillImports(int parallelism) { var source = await NewDatabaseAsync("src"); long childId, parentId; await using (var provider = Build(source)) { var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); // The child gets the lower id, so the export writes it before its parent, possibly in another batch. var child = new RedbObject { name = "child", Props = new SimpleProps { Title = "c" } }; childId = await redb.SaveAsync(child); parentId = await redb.SaveAsync(new RedbObject { name = "parent", Props = new SimpleProps { Title = "p" } }); } await ExecuteAsync(source, $"UPDATE _objects SET _id_parent = {parentId} WHERE _id = {childId}"); var file = await ExportAsync(source, null); var target = await NewTargetWithOneObjectAsync(); await ImportAsync(target, file, parallelism); (await ScalarAsync(target, $"SELECT _id_parent FROM _objects WHERE _id = {childId}")).Should().Be(parentId, "a reference the file holds both ends of passes the check, whatever the order of the rows"); } /// Exports a database whose one object points at a parent that is not there. private async Task<(string File, long ChildId)> ExportWithMissingParentAsync() { var source = await NewDatabaseAsync("src"); long childId; await using (var provider = Build(source)) { var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); childId = await redb.SaveAsync(new RedbObject { name = "orphan", Props = new SimpleProps { Title = "o" } }); await redb.SaveAsync(new RedbObject { name = "sibling", Props = new SimpleProps { Title = "s" } }); } // The key would refuse the update; with the triggers off it goes in, as it would from a broken file. await ExecuteAsync(source, $"SET session_replication_role = 'replica'; UPDATE _objects SET _id_parent = {Missing} WHERE _id = {childId}"); return (await ExportAsync(source, null), childId); } private async Task NewTargetWithOneObjectAsync() { var target = await NewDatabaseAsync("dst"); await using var provider = Build(target); var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); await redb.SaveAsync(new RedbObject { name = "already-here", Props = new SimpleProps { Title = "keep" } }); return target; } private static async Task ParentKeyNameAsync(string cs) { await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); await using var command = new NpgsqlCommand(""" SELECT c.conname::text FROM pg_constraint c JOIN pg_attribute a ON a.attrelid = c.conrelid AND a.attnum = ANY(c.conkey) WHERE c.contype = 'f' AND c.conrelid = '_objects'::regclass AND a.attname = '_id_parent' """, connection); return (string)(await command.ExecuteScalarAsync())!; } private async Task NewDatabaseAsync(string suffix) { var name = $"redb_export_fk_{Guid.NewGuid().ToString("N")[..12]}_{suffix}"; _databases.Add(name); await ExecuteAsync(Maintenance(), $"CREATE DATABASE \"{name}\""); return new NpgsqlConnectionStringBuilder(_server) { Database = name }.ConnectionString; } private string Maintenance() => new NpgsqlConnectionStringBuilder(_server) { Database = "postgres" }.ConnectionString; private static ServiceProvider Build(string cs) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => options .UsePostgres(cs) .Configure(c => c.CacheDomain = $"export-fk-{Guid.NewGuid():N}")); return services.BuildServiceProvider(); } private async Task ExportAsync(string cs, long[]? schemeIds) { var file = Path.Combine(Path.GetTempPath(), $"redb-export-fk-{Guid.NewGuid():N}.redb"); _files.Add(file); await using var provider = ProviderFactory.Create("postgres"); await provider.OpenAsync(cs); await new ExportService(provider, verbose: false, batchSize: 1000).ExportAsync(file, schemeIds, compress: false, dryRun: false); return file; } private static async Task ImportAsync(string cs, string file, int parallelism) { await using var provider = ProviderFactory.Create("postgres"); await provider.OpenAsync(cs); await new ImportService(provider, verbose: false, batchSize: 1000, parallelism: parallelism) .ImportAsync(file, clean: true, dryRun: false); } private static async Task ExecuteAsync(string cs, string sql) { await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); await using var command = new NpgsqlCommand(sql, connection); await command.ExecuteNonQueryAsync(); } private static async Task ScalarAsync(string cs, string sql) { await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); await using var command = new NpgsqlCommand(sql, connection); return Convert.ToInt64(await command.ExecuteScalarAsync()); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresExportRenameHistoryTests.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/Postgres/PostgresExportRenameHistoryTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Npgsql; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; /// on PostgreSQL, scratch databases dropped afterwards. public class PostgresExportRenameHistoryTests : ExportRenameHistoryTestsBase, IAsyncLifetime { private string _server = null!; private readonly List _databases = []; private readonly List _files = []; protected override string ProviderName => "postgres"; public Task InitializeAsync() { var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); _server = config.GetConnectionString("Postgres")!; return Task.CompletedTask; } public async Task DisposeAsync() { NpgsqlConnection.ClearAllPools(); foreach (var database in _databases) await ExecuteAsync(Maintenance(), $"DROP DATABASE IF EXISTS \"{database}\" WITH (FORCE)"); foreach (var file in _files) File.Delete(file); } protected override async Task NewDatabaseAsync(string suffix) { var name = $"redb_export_ren_{Guid.NewGuid().ToString("N")[..12]}_{suffix}"; _databases.Add(name); await ExecuteAsync(Maintenance(), $"CREATE DATABASE \"{name}\""); return new NpgsqlConnectionStringBuilder(_server) { Database = name }.ConnectionString; } protected override ServiceProvider Build(string cs) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => options .UsePostgres(cs) .Configure(c => c.CacheDomain = $"export-ren-{Guid.NewGuid():N}")); return services.BuildServiceProvider(); } protected override string NewFile() { var file = Path.Combine(Path.GetTempPath(), $"redb-export-ren-{Guid.NewGuid():N}.redb"); _files.Add(file); return file; } protected override async Task ScalarAsync(string cs, string sql) { await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); await using var command = new NpgsqlCommand(sql, connection); return AsText(await command.ExecuteScalarAsync()); } protected override async Task> PairsAsync(string cs, string sql) { await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); await using var command = new NpgsqlCommand(sql, connection); await using var reader = await command.ExecuteReaderAsync(); var rows = new List<(string?, string?)>(); while (await reader.ReadAsync()) rows.Add((AsText(reader.GetValue(0)), AsText(reader.GetValue(1)))); return rows; } protected override Task ExecuteSqlAsync(string cs, string sql) => ExecuteAsync(cs, sql); private string Maintenance() => new NpgsqlConnectionStringBuilder(_server) { Database = "postgres" }.ConnectionString; private static async Task ExecuteAsync(string cs, string sql) { await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); await using var command = new NpgsqlCommand(sql, connection); await command.ExecuteNonQueryAsync(); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresExportSchemaGateTests.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/Postgres/PostgresExportSchemaGateTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Npgsql; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Postgres.Sql; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; /// on PostgreSQL, scratch databases dropped afterwards. public class PostgresExportSchemaGateTests : ExportSchemaGateTestsBase, IAsyncLifetime { private string _server = null!; private readonly List _databases = []; private readonly List _files = []; protected override string ProviderName => "postgres"; protected override bool SupportsParallel => true; protected override string OutdatedRemedy => "`redb schema --upgrade --provider postgres`"; protected override string SchemaVersionSql => "SELECT pvt_module_version()"; public Task InitializeAsync() { var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); _server = config.GetConnectionString("Postgres")!; return Task.CompletedTask; } public async Task DisposeAsync() { NpgsqlConnection.ClearAllPools(); foreach (var database in _databases) await ExecuteAsync(Maintenance(), $"DROP DATABASE IF EXISTS \"{database}\" WITH (FORCE)"); foreach (var file in _files) File.Delete(file); } protected override async Task NewDatabaseAsync(string suffix) { var name = $"redb_export_gate_{Guid.NewGuid().ToString("N")[..12]}_{suffix}"; _databases.Add(name); await ExecuteAsync(Maintenance(), $"CREATE DATABASE \"{name}\""); return new NpgsqlConnectionStringBuilder(_server) { Database = name }.ConnectionString; } protected override ServiceProvider Build(string cs) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => options .UsePostgres(cs) .Configure(c => c.CacheDomain = $"export-gate-{Guid.NewGuid():N}")); return services.BuildServiceProvider(); } protected override string NewFile() { var file = Path.Combine(Path.GetTempPath(), $"redb-export-gate-{Guid.NewGuid():N}.redb"); _files.Add(file); return file; } protected override Task StageOlderAsync(string cs) => ExecuteAsync(cs, """ ALTER TABLE _schemes DROP COLUMN _renamed_from; ALTER TABLE _structures DROP COLUMN _renamed_from; CREATE OR REPLACE FUNCTION pvt_module_version() RETURNS text LANGUAGE plpgsql IMMUTABLE AS $$ BEGIN RETURN '0.0.1'; END $$; """); protected override Task StageNewerAsync(string cs, bool servesThisBuild) { var compat = servesThisBuild ? $"{new PostgreSqlDialect().Query_PvtRequiredVersion()}|4.8.0" : "99.0.0|99.0.0"; return ExecuteAsync(cs, $""" CREATE OR REPLACE FUNCTION pvt_module_version() RETURNS text LANGUAGE plpgsql IMMUTABLE AS $$ BEGIN RETURN '99.0.0'; END $$; CREATE OR REPLACE FUNCTION pvt_module_compat() RETURNS text LANGUAGE sql IMMUTABLE AS $$ SELECT '{compat}'::text $$; """); } protected override async Task ScalarAsync(string cs, string sql) { await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); await using var command = new NpgsqlCommand(sql, connection); return Convert.ToString(await command.ExecuteScalarAsync()); } protected override async Task> ProviderStateAsync(string cs) { var lines = new List(); await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); foreach (var sql in new[] { "SELECT 'index ' || tablename || '.' || indexname FROM pg_indexes WHERE schemaname = current_schema() ORDER BY 1", "SELECT 'fk ' || conrelid::regclass || '.' || conname FROM pg_constraint WHERE contype = 'f' ORDER BY 1", // The foreign keys are enforced by internal triggers: a load that switched them off leaves them disabled. "SELECT 'trigger ' || tgrelid::regclass || '.' || tgname || ' ' || tgenabled::text FROM pg_trigger WHERE tgisinternal ORDER BY 1", "SELECT 'dropped-indexes-table ' || (to_regclass('_import_dropped_indexes') IS NOT NULL)", }) { await using var command = new NpgsqlCommand(sql, connection); await using var reader = await command.ExecuteReaderAsync(); while (await reader.ReadAsync()) lines.Add(reader.GetString(0)); } return lines; } private string Maintenance() => new NpgsqlConnectionStringBuilder(_server) { Database = "postgres" }.ConnectionString; protected override Task ExecuteSqlAsync(string cs, string sql) => ExecuteAsync(cs, sql); private static async Task ExecuteAsync(string cs, string sql) { await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); await using var command = new NpgsqlCommand(sql, connection); await command.ExecuteNonQueryAsync(); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresFieldNamedLikeAFunctionTests.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/Postgres/PostgresFieldNamedLikeAFunctionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresFieldNamedLikeAFunctionTests : FieldNamedLikeAFunctionTestsBase { public PostgresFieldNamedLikeAFunctionTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresFilterFieldPathTests.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/Postgres/PostgresFilterFieldPathTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresFilterFieldPathTests : FilterFieldPathTestsBase { public PostgresFilterFieldPathTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresFreeListItemJsonTests.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/Postgres/PostgresFreeListItemJsonTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresFreeListItemJsonTests : FreeListItemJsonTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresFreePvtAuditTests.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/Postgres/PostgresFreePvtAuditTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; /// /// Free PG run of the shared PVT audit suite (). /// [Collection("Postgres")] public class PostgresFreePvtAuditTests : PvtAuditTestsBase { public PostgresFreePvtAuditTests(PostgresFixture fixture) : base(fixture.Redb, isPro: false) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresGroupByHavingTests.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/Postgres/PostgresGroupByHavingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresGroupByHavingTests : GroupByHavingTestsBase { public PostgresGroupByHavingTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresGroupBySelectShapesTests.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/Postgres/PostgresGroupBySelectShapesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresGroupBySelectShapesTests : GroupBySelectShapesTestsBase { public PostgresGroupBySelectShapesTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresGroupByTests.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/Postgres/PostgresGroupByTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresGroupByTests : GroupByTestsBase { public PostgresGroupByTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresIgnoredPropertyWalkTests.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/Postgres/PostgresIgnoredPropertyWalkTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresIgnoredPropertyWalkTests : IgnoredPropertyWalkTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresIndexCatalogTests.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/Postgres/PostgresIndexCatalogTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Npgsql; using redb.Core.Data; using redb.Core.Extensions; using redb.Core.Models; using redb.Core.Models.Configuration; using redb.Postgres.Extensions; using redb.Postgres.Sql; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; /// PostgresIndexCatalog.Base against a fresh PostgreSQL database of this build (see ). public class PostgresIndexCatalogTests : IndexCatalogTestsBase { internal static readonly string AdminBase = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; protected override async Task CreateDatabaseAsync(string name) { await ExecAdminAsync($"CREATE DATABASE \"{name}\""); return new NpgsqlConnectionStringBuilder(AdminBase) { Database = name }.ConnectionString; } protected override async Task DropDatabaseAsync(string name) { NpgsqlConnection.ClearAllPools(); await ExecAdminAsync($"DROP DATABASE IF EXISTS \"{name}\" WITH (FORCE)"); } internal static async Task ExecAdminAsync(string sql) { var cs = new NpgsqlConnectionStringBuilder(AdminBase) { Database = "postgres", Pooling = false }.ConnectionString; await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); await using var command = new NpgsqlCommand(sql, connection); await command.ExecuteNonQueryAsync(); } protected override void AddRedb(IServiceCollection services, string connectionString, Action configure) => services.AddRedb(o => o.UsePostgres(connectionString).Configure(configure)); // pg_indexes.indexdef names the table with its schema; the table is kept schema-free. protected override async Task> ReadCreateStatementsAsync(IRedbContext context) { var rows = await context.QueryAsync( "SELECT indexname AS \"Name\", replace(indexdef, ' ON ' || schemaname || '.', ' ON ') AS \"Sql\" " + "FROM pg_indexes WHERE schemaname = current_schema()"); return rows.ToDictionary(r => r.Name!, r => r.Sql!, StringComparer.OrdinalIgnoreCase); } protected override IReadOnlyList Catalog => PostgresIndexCatalog.Base; protected override (string File, string Namespace, string Class, string Member, RedbIndexOrigin Origin) Target => ("redb.Postgres/sql/PostgresIndexCatalog.g.cs", "redb.Postgres.Sql", "PostgresIndexCatalog", "Base", RedbIndexOrigin.Base); protected sealed class SqlRow { public string? Name { get; set; } public string? Sql { get; set; } } } /// The index check and its repair on PostgreSQL (CREATE INDEX CONCURRENTLY), see . public class PostgresIndexRepairTests : IndexRepairTestsBase { protected override async Task CreateDatabaseAsync(string name) { await PostgresIndexCatalogTests.ExecAdminAsync($"CREATE DATABASE \"{name}\""); return new NpgsqlConnectionStringBuilder(PostgresIndexCatalogTests.AdminBase) { Database = name }.ConnectionString; } protected override async Task DropDatabaseAsync(string name) { NpgsqlConnection.ClearAllPools(); await PostgresIndexCatalogTests.ExecAdminAsync($"DROP DATABASE IF EXISTS \"{name}\" WITH (FORCE)"); } protected override void AddRedb(IServiceCollection services, string connectionString, Action configure) => services.AddRedb(o => o.UsePostgres(connectionString).Configure(configure)); protected override string DropIndexSql(string table, string index) => $"DROP INDEX \"{index}\""; protected override string CreateOtherIndexSql(string index) => $"CREATE INDEX \"{index}\" ON _objects (_note)"; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresIntegerAverageTests.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/Postgres/PostgresIntegerAverageTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresIntegerAverageTests : IntegerAverageTestsBase { public PostgresIntegerAverageTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresLazyHostTests.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/Postgres/PostgresLazyHostTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresLazyHostTests : LazyHostTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } protected override string ReadFlagSql => "SELECT current_setting('redb.lazy_refs', true)"; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresLazyReferenceTests.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/Postgres/PostgresLazyReferenceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresLazyReferenceTests : LazyReferenceTestsBase { public PostgresLazyReferenceTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresLazyReferencesOptionTests.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/Postgres/PostgresLazyReferencesOptionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresLazyReferencesOptionTests : LazyReferencesOptionTestsBase { public PostgresLazyReferencesOptionTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresLikeEscapingTests.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/Postgres/PostgresLikeEscapingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresLikeEscapingTests : LikeEscapingTestsBase { public PostgresLikeEscapingTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresListItemArrayAnyTests.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/Postgres/PostgresListItemArrayAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresListItemArrayAnyTests : ListItemArrayAnyTestsBase { public PostgresListItemArrayAnyTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresListItemObjectLoaderLeakTests.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/Postgres/PostgresListItemObjectLoaderLeakTests.cs ---- using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresListItemObjectLoaderLeakTests : PostgresListItemObjectLoaderLeakTestsBase { protected override bool IsPro => false; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresListItemObjectWalkTests.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/Postgres/PostgresListItemObjectWalkTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresListItemObjectWalkTests : ListItemObjectWalkTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresListReadPropsOnceTests.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/Postgres/PostgresListReadPropsOnceTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresListReadPropsOnceTests : ListReadPropsOnceTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresListTests.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/Postgres/PostgresListTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresListTests : ListTestsBase { public PostgresListTests(PostgresFixture fixture) : base(fixture.Redb) { } // Postgres Free PVT supports OrderBy on ListItem.Value / .Alias // (verified 2026-05-22 by un-gating the assertions). protected override bool SupportsListItemValueAliasOrdering => true; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresLockForUpdateTests.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/Postgres/PostgresLockForUpdateTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresLockForUpdateTests : LockForUpdateTestsBase { public PostgresLockForUpdateTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresLongBaseFilterTests.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/Postgres/PostgresLongBaseFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresLongBaseFilterTests : LongBaseFilterTestsBase { public PostgresLongBaseFilterTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresMaintenanceTests.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/Postgres/PostgresMaintenanceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresMaintenanceTests : MaintenanceTestsBase { public PostgresMaintenanceTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresMaterializationFidelityTests.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/Postgres/PostgresMaterializationFidelityTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresMaterializationFidelityTests : MaterializationFidelityTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresModuleSmokeTests.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/Postgres/PostgresModuleSmokeTests.cs ---- using Microsoft.Extensions.Configuration; using Npgsql; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.Postgres; /// /// Runs the SQL module's own smoke runner, redb.Postgres/sql/v2-pvt/99_smoke_auto.sql, against the fixture /// database (review SQ-4). It was run by hand only, so nothing kept it passing. It builds SQL for a table of filter /// cases over the test model corpus, asserts shapes, and raises at the end when any case failed; the NOTICE lines /// name the cases and are attached to the failure. /// [Collection("Postgres")] public class PostgresModuleSmokeTests { // Ensures the fixture has initialized the database (schemes, module) before the script runs. public PostgresModuleSmokeTests(PostgresFixture fixture) => _ = fixture.Redb; [Fact] public async Task TheModuleSmokeRunner_Passes() { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; var script = await File.ReadAllTextAsync(Path.Combine(AppContext.BaseDirectory, "Smoke", "postgres_99_smoke_auto.sql")); var notices = new List(); await using var connection = new NpgsqlConnection(cs); connection.Notice += (_, e) => notices.Add(e.Notice.MessageText); await connection.OpenAsync(); try { await using var command = new NpgsqlCommand(script, connection) { CommandTimeout = 600 }; await command.ExecuteNonQueryAsync(); } catch (PostgresException ex) { throw new Xunit.Sdk.XunitException( ex.MessageText + Environment.NewLine + string.Join(Environment.NewLine, notices.Where(IsFailure))); } notices.Where(IsFailure).Should().BeEmpty(); } // "FAIL [scheme / case] ...", "INSPECT [...] FAILED: ...", "SHAPE-FAIL ..." - not a summary such as "fail: 0". private static bool IsFailure(string line) => line.StartsWith("FAIL [", StringComparison.Ordinal) || line.Contains(" FAILED", StringComparison.Ordinal) || line.Contains("SHAPE-FAIL", StringComparison.Ordinal); } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresNestedDictionaryFilterTests.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/Postgres/PostgresNestedDictionaryFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresNestedDictionaryFilterTests : NestedDictionaryFilterTestsBase { public PostgresNestedDictionaryFilterTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresNullComparisonTests.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/Postgres/PostgresNullComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresNullComparisonTests : NullComparisonTestsBase { public PostgresNullComparisonTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresNullableCollectionsTests.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/Postgres/PostgresNullableCollectionsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresNullableCollectionsTests : NullableCollectionsTestsBase { public PostgresNullableCollectionsTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresOrderAbsentValueTests.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/Postgres/PostgresOrderAbsentValueTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresOrderAbsentValueTests : OrderAbsentValueTestsBase { public PostgresOrderAbsentValueTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresOrderPositionTests.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/Postgres/PostgresOrderPositionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresOrderPositionTests : FreeOrderPositionTestsBase { public PostgresOrderPositionTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresOrderingTests.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/Postgres/PostgresOrderingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresOrderingTests : OrderingTestsBase { public PostgresOrderingTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresOrphanTransactionTests.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/Postgres/PostgresOrphanTransactionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresOrphanTransactionTests : OrphanTransactionTestsBase { public PostgresOrphanTransactionTests(PostgresFixture fixture) : base(fixture.ServiceProvider) { } protected override string FailingBatchThatOpensATransaction => "BEGIN; SELECT 1/0;"; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresParallelImportFinishTests.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/Postgres/PostgresParallelImportFinishTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Npgsql; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; /// on PostgreSQL, scratch databases dropped afterwards. public class PostgresParallelImportFinishTests : ParallelImportFinishTestsBase, IAsyncLifetime { private string _server = null!; private readonly List _databases = []; private readonly List _files = []; protected override string ProviderName => "postgres"; public Task InitializeAsync() { _server = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; return Task.CompletedTask; } public async Task DisposeAsync() { NpgsqlConnection.ClearAllPools(); foreach (var database in _databases) await ExecuteAsync(Maintenance(), $"DROP DATABASE IF EXISTS \"{database}\" WITH (FORCE)"); foreach (var file in _files) File.Delete(file); } protected override async Task NewDatabaseAsync(string suffix) { var name = $"redb_export_fin_{Guid.NewGuid().ToString("N")[..12]}_{suffix}"; _databases.Add(name); await ExecuteAsync(Maintenance(), $"CREATE DATABASE \"{name}\""); return new NpgsqlConnectionStringBuilder(_server) { Database = name }.ConnectionString; } protected override ServiceProvider Build(string cs) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => options.UsePostgres(cs).Configure(c => c.CacheDomain = $"fin-{Guid.NewGuid():N}")); return services.BuildServiceProvider(); } protected override string NewFile() { var file = Path.Combine(Path.GetTempPath(), $"redb-export-fin-{Guid.NewGuid():N}.redb"); _files.Add(file); return file; } protected override async Task ScalarAsync(string cs, string sql) { await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); await using var command = new NpgsqlCommand(sql, connection); return Convert.ToString(await command.ExecuteScalarAsync()); } protected override Task DropSequenceAsync(string cs) => ExecuteAsync(cs, "DROP SEQUENCE global_identity CASCADE"); protected override async Task> ShapeAsync(string cs) { var lines = new List(); await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); foreach (var sql in new[] { "SELECT 'index ' || tablename || '.' || indexname FROM pg_indexes WHERE schemaname = current_schema() ORDER BY 1", "SELECT 'trigger ' || tgrelid::regclass || '.' || tgname || ' ' || tgenabled::text FROM pg_trigger ORDER BY 1", "SELECT 'dropped-indexes-table ' || (to_regclass('_import_dropped_indexes') IS NOT NULL)", }) { await using var command = new NpgsqlCommand(sql, connection); await using var reader = await command.ExecuteReaderAsync(); while (await reader.ReadAsync()) lines.Add(reader.GetString(0)); } return lines; } private string Maintenance() => new NpgsqlConnectionStringBuilder(_server) { Database = "postgres" }.ConnectionString; private static async Task ExecuteAsync(string cs, string sql) { await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); await using var command = new NpgsqlCommand(sql, connection); await command.ExecuteNonQueryAsync(); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresPasswordHasherDefaultTests.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/Postgres/PostgresPasswordHasherDefaultTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresPasswordHasherDefaultTests : PasswordHasherDefaultTestsBase { public PostgresPasswordHasherDefaultTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresPolymorphicTreeTests.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/Postgres/PostgresPolymorphicTreeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresPolymorphicTreeTests : PolymorphicTreeTestsBase { public PostgresPolymorphicTreeTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresProCancellationTests.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/Postgres/PostgresProCancellationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("PostgresPro")] public class PostgresProCancellationTests : CancellationTestsBase { public PostgresProCancellationTests(PostgresProFixture fixture) : base(fixture.Redb) { } protected override string? SleepSql => "SELECT pg_sleep(30)"; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresProQueryTests.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/Postgres/PostgresProQueryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresProQueryTests : ProQueryTestsBase { public PostgresProQueryTests(PostgresFixture fixture) : base(fixture.Redb, isPro: false) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresProjectionTests.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/Postgres/PostgresProjectionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresProjectionTests : ProjectionTestsBase { public PostgresProjectionTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresPropertyRenameTests.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/Postgres/PostgresPropertyRenameTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresPropertyRenameTests : PropertyRenameTestsBase { public PostgresPropertyRenameTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresPropsCacheHeaderTests.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/Postgres/PostgresPropsCacheHeaderTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresPropsCacheHeaderTests : PropsCacheHeaderTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresPropsCacheSkipValidationTests.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/Postgres/PostgresPropsCacheSkipValidationTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresPropsCacheSkipValidationTests : PropsCacheSkipValidationTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresPropsCacheTransactionKeepTests.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/Postgres/PostgresPropsCacheTransactionKeepTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresPropsCacheTransactionKeepTests : PropsCacheTransactionKeepTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresPropsCacheTransactionTests.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/Postgres/PostgresPropsCacheTransactionTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresPropsCacheTransactionTests : PropsCacheTransactionTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresQueryOrderTests.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/Postgres/PostgresQueryOrderTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresQueryOrderTests : QueryOrderTestsBase { public PostgresQueryOrderTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresQueryPlannerBlockTests.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/Postgres/PostgresQueryPlannerBlockTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresQueryPlannerBlockTests : FreeQueryPlannerBlockTestsBase { public PostgresQueryPlannerBlockTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresQueryRowsAsJsonTests.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/Postgres/PostgresQueryRowsAsJsonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresQueryRowsAsJsonTests : QueryRowsAsJsonTestsBase { public PostgresQueryRowsAsJsonTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresReaderConnectionTests.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/Postgres/PostgresReaderConnectionTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresReaderConnectionTests : ReaderConnectionTestsBase { protected override string SlowScalarSql => "SELECT count(*) FROM (SELECT pg_sleep(2)) AS s"; protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresReferenceListSaveTests.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/Postgres/PostgresReferenceListSaveTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresReferenceListSaveTests : ReferenceListSaveTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresReferenceStubTests.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/Postgres/PostgresReferenceStubTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresReferenceStubTests : ReferenceStubTestsBase { public PostgresReferenceStubTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresRegexQueryTests.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/Postgres/PostgresRegexQueryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresRegexQueryTests : RegexQueryTestsBase { public PostgresRegexQueryTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresSaveByUniqueInterleaveTests.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/Postgres/PostgresSaveByUniqueInterleaveTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Data; using redb.Core.Exceptions; using redb.Core.Models.Configuration; using redb.Core.Models.Contracts; using redb.Core.Models.Entities; using redb.Core.Providers; using redb.Core.Serialization; using redb.Postgres.Providers; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Postgres; /// /// BR-8 (Tsak report, 2026-09-02), the vanish race: SaveByUniqueAsync resolved the key's row, the /// row was deleted and the key recreated elsewhere (Remove+Set+Set interleave) - the save then /// inserted via the default AutoSwitchToInsert, hit the object-key index, and the old retry /// (guarded by "no existing id") let the violation escape to the caller. The interleave is made /// deterministic through the virtual resolve seam. The retry logic lives in /// ObjectStorageProviderBase and is provider-agnostic; one provider exercises it. /// [Collection("Postgres")] public class PostgresSaveByUniqueInterleaveTests { private readonly PostgresFixture _fixture; public PostgresSaveByUniqueInterleaveTests(PostgresFixture fixture) => _fixture = fixture; [Fact] public async Task VanishedWinner_RecreatedElsewhere_IsRetriedOntoTheNewWinner() { var redb = _fixture.Redb; await redb.SyncSchemeAsync(); var key = $"VU-VANISH-{Guid.NewGuid():N}"; var firstId = await redb.SaveAsync(new RedbObject { name = "vanish-a", ValueUnique = key, Props = new UniqueOrderProps { Note = "first" } }); long recreatedId = 0; var provider = CreateHookedProvider(); provider.AfterFirstResolve = async () => { // The interleave, between SaveByUniqueAsync's lookup and its save: the resolved row // vanishes outright and the key is recreated on a fresh row by "someone else". await redb.Context.ExecuteAsync($"DELETE FROM _objects WHERE _id = {firstId}"); recreatedId = await redb.SaveAsync(new RedbObject { name = "vanish-b", ValueUnique = key, Props = new UniqueOrderProps { Note = "recreated" } }); }; var upsertId = await provider.SaveByUniqueAsync(new RedbObject { name = "vanish-c", ValueUnique = key, Props = new UniqueOrderProps { Note = "last-writer" } }); upsertId.Should().Be(recreatedId, "the upsert must land on the CURRENT owner of the key"); (await redb.LoadAsync(recreatedId, depth: 1))!.Props.Note.Should().Be("last-writer", "exactly one object per key, last writer's content"); (await redb.Context.ExecuteScalarAsync( "SELECT COUNT(*) FROM _objects o JOIN _schemes s ON s._id = o._id_scheme " + $"WHERE s._name = 'UniqueOrder' AND o._value_unique = '{key}'")) .Should().Be(1); } private InterleavingProvider CreateHookedProvider() { var sp = _fixture.ServiceProvider; return new InterleavingProvider( sp.GetRequiredService(), sp.GetRequiredService(), sp.GetRequiredService(), sp.GetRequiredService(), sp.GetRequiredService(), sp.GetRequiredService(), sp.GetService()); } private sealed class InterleavingProvider : PostgresObjectStorageProvider { public Func? AfterFirstResolve; private int _resolves; public InterleavingProvider( IRedbContext context, IRedbObjectSerializer serializer, IPermissionProvider permissionProvider, IRedbSecurityContext securityContext, ISchemeSyncProvider schemeSync, RedbServiceConfiguration configuration, IListProvider? listProvider) : base(context, serializer, permissionProvider, securityContext, schemeSync, configuration, listProvider) { } protected override async Task ResolveObjectIdByUniqueKeyAsync(long schemeId, string? valueUnique, System.Threading.CancellationToken cancellationToken = default) { var id = await base.ResolveObjectIdByUniqueKeyAsync(schemeId, valueUnique, cancellationToken); if (System.Threading.Interlocked.Increment(ref _resolves) == 1 && AfterFirstResolve is { } hook) await hook(); return id; } } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresSaveGraphHashTests.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/Postgres/PostgresSaveGraphHashTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresSaveGraphHashTests : SaveGraphHashTestsBase { public PostgresSaveGraphHashTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresSaveInterceptorTests.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/Postgres/PostgresSaveInterceptorTests.cs ---- using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresSaveInterceptorTests : SaveInterceptorTestsBase { protected override string ConnectionStringName => "Postgres"; protected override void UseProvider(RedbOptionsBuilder options, string connectionString) => options.UsePostgres(connectionString); } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresSaveLockScopeTests.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/Postgres/PostgresSaveLockScopeTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresSaveLockScopeTests : SaveLockScopeTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresSaveOperationGuardTests.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/Postgres/PostgresSaveOperationGuardTests.cs ---- using redb.Core.Models.Entities; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Postgres; /// /// CT-4 (решение владельца 2026-09-04, «как у EF»): контракт «один scope - один поток» защищён /// операционным детектором уровня EF DbContext. Командный страж соединения ловит только /// НАЛОЖИВШИЕСЯ команды; два перемежающихся async-сохранения могли молча перемешать /// pending-состояние ChangeTracking. Детектор ядра общий - одного провайдера достаточно. /// [Collection("Postgres")] public class PostgresSaveOperationGuardTests { private readonly PostgresFixture _fixture; public PostgresSaveOperationGuardTests(PostgresFixture fixture) => _fixture = fixture; [Fact] public async Task ParallelSaves_OnOneScope_AreLoudlyDetected() { var redb = _fixture.Redb; await redb.SyncSchemeAsync(); var t1 = redb.SaveAsync(new RedbObject { name = "guard-1", Props = new SimpleProps { Title = "a" } }); var t2 = redb.SaveAsync(new RedbObject { name = "guard-2", Props = new SimpleProps { Title = "b" } }); var act = async () => await Task.WhenAll(t1, t2); (await act.Should().ThrowAsync( "второе сохранение, вошедшее до завершения первого, обязано быть громким, а не молча перемешивать состояние")) .WithMessage("*SaveAsync*"); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresSchemaInitTests.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/Postgres/PostgresSchemaInitTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Npgsql; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Postgres.Sql; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; /// on PostgreSQL, scratch databases dropped afterwards. public class PostgresSchemaInitTests : SchemaInitTestsBase, IAsyncLifetime { private string _server = null!; private readonly List _databases = []; protected override string ProviderName => "postgres"; protected override string RequiredVersion => new PostgreSqlDialect().Query_PvtRequiredVersion()!; public Task InitializeAsync() { _server = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; return Task.CompletedTask; } public async Task DisposeAsync() { NpgsqlConnection.ClearAllPools(); foreach (var database in _databases) await ExecuteAsync(Maintenance(), $"DROP DATABASE IF EXISTS \"{database}\" WITH (FORCE)"); } protected override async Task NewDatabaseAsync(string suffix) { var name = $"redb_init_{Guid.NewGuid().ToString("N")[..12]}_{suffix}"; _databases.Add(name); await ExecuteAsync(Maintenance(), $"CREATE DATABASE \"{name}\""); return new NpgsqlConnectionStringBuilder(_server) { Database = name }.ConnectionString; } protected override ServiceProvider Build(string cs) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => options.UsePostgres(cs).Configure(c => c.CacheDomain = $"init-{Guid.NewGuid():N}")); return services.BuildServiceProvider(); } protected override async Task ScalarAsync(string cs, string sql) { await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); await using var command = new NpgsqlCommand(sql, connection); return Convert.ToString(await command.ExecuteScalarAsync()); } protected override async Task> CatalogAsync(string cs) { var lines = new List(); await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); foreach (var sql in new[] { "SELECT 'sequence ' || sequencename FROM pg_sequences WHERE schemaname = current_schema() ORDER BY 1", "SELECT 'fk ' || conrelid::regclass || '.' || conname FROM pg_constraint WHERE contype = 'f' ORDER BY 1", "SELECT 'trigger ' || tgrelid::regclass || '.' || tgname || ' ' || tgenabled::text FROM pg_trigger ORDER BY 1", "SELECT 'module ' || pvt_module_version()", }) { await using var command = new NpgsqlCommand(sql, connection); await using var reader = await command.ExecuteReaderAsync(); while (await reader.ReadAsync()) lines.Add(reader.GetString(0)); } return lines; } private string Maintenance() => new NpgsqlConnectionStringBuilder(_server) { Database = "postgres" }.ConnectionString; private static async Task ExecuteAsync(string cs, string sql) { await using var connection = new NpgsqlConnection(cs); await connection.OpenAsync(); await using var command = new NpgsqlCommand(sql, connection); await command.ExecuteNonQueryAsync(); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresSchemaMissingTests.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/Postgres/PostgresSchemaMissingTests.cs ---- using Npgsql; using redb.Core.Extensions; using redb.Postgres.Data; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresSchemaMissingTests : SchemaMissingTestsBase { private readonly string _name = $"redb_probe_empty_{Guid.NewGuid():N}"[..40]; protected override async Task CreateEmptyDatabaseAsync() { await using var admin = new NpgsqlRedbConnection(ConnString("Postgres")); await admin.ExecuteAsync($"CREATE DATABASE \"{_name}\""); return new NpgsqlConnectionStringBuilder(ConnString("Postgres")) { Database = _name }.ConnectionString; } protected override async Task DropDatabaseAsync(string connectionString) { NpgsqlConnection.ClearPool(new NpgsqlConnection(connectionString)); await using var admin = new NpgsqlRedbConnection(ConnString("Postgres")); await admin.ExecuteAsync($"DROP DATABASE IF EXISTS \"{_name}\" WITH (FORCE)"); } protected override void UseProvider(RedbOptionsBuilder options, string connectionString) => options.UsePostgres(connectionString); } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresSchemaUpgradeTests.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/Postgres/PostgresSchemaUpgradeTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Npgsql; using redb.Core.Data; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; /// /// Owns database redb_upgrade_<run> and role redb_noddl_<run> on the test server. Not in any /// collection on purpose: nothing else touches that database, so it can run in parallel with the /// shared-database suites. /// public class PostgresSchemaUpgradeTests : SchemaUpgradeTestsBase { public PostgresSchemaUpgradeTests(SchemaUpgradeCleanup cleanup) : base(cleanup) { } // Virtual so the Pro subclass owns its own database and role: the two classes run in // parallel and must not share the database they deliberately damage. protected virtual string DatabaseName => $"redb_upgrade_{RunSuffix}"; protected virtual string FreshDatabaseName => $"redb_upgrade_fresh_{RunSuffix}"; protected virtual string RestrictedRole => $"redb_noddl_{RunSuffix}"; private const string RestrictedPassword = "noddl"; private static readonly string AdminBase = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; protected override string OwnerConnectionString => new NpgsqlConnectionStringBuilder(AdminBase) { Database = DatabaseName }.ConnectionString; protected override string FreshDatabaseConnectionString => new NpgsqlConnectionStringBuilder(AdminBase) { Database = FreshDatabaseName }.ConnectionString; protected override async Task RecreateFreshDatabaseAsync() { await ExecAdminAsync("postgres", $"DROP DATABASE IF EXISTS \"{FreshDatabaseName}\" WITH (FORCE)"); await ExecAdminAsync("postgres", $"CREATE DATABASE \"{FreshDatabaseName}\""); } protected override string RestrictedConnectionString => new NpgsqlConnectionStringBuilder(AdminBase) { Database = DatabaseName, Username = RestrictedRole, Password = RestrictedPassword }.ConnectionString; protected override void UseProvider(RedbOptionsBuilder options, string connectionString) => options.UsePostgres(connectionString); protected static async Task ExecAdminAsync(string database, string sql) { var cs = new NpgsqlConnectionStringBuilder(AdminBase) { Database = database, Pooling = false }.ConnectionString; await using var conn = new NpgsqlConnection(cs); await conn.OpenAsync(); await using var cmd = conn.CreateCommand(); cmd.CommandText = sql; await cmd.ExecuteNonQueryAsync(); } protected static async Task ScalarAdminAsync(string database, string sql) { var cs = new NpgsqlConnectionStringBuilder(AdminBase) { Database = database, Pooling = false }.ConnectionString; await using var conn = new NpgsqlConnection(cs); await conn.OpenAsync(); await using var cmd = conn.CreateCommand(); cmd.CommandText = sql; var v = await cmd.ExecuteScalarAsync(); return v is null or DBNull ? default : (T)v; } protected override async Task PrepareDatabaseAndLoginAsync() { if (await ScalarAdminAsync("postgres", $"SELECT 1 FROM pg_database WHERE datname = '{DatabaseName}'") is null) await ExecAdminAsync("postgres", $"CREATE DATABASE \"{DatabaseName}\""); if (await ScalarAdminAsync("postgres", $"SELECT 1 FROM pg_roles WHERE rolname = '{RestrictedRole}'") is null) await ExecAdminAsync("postgres", $"CREATE ROLE {RestrictedRole} LOGIN PASSWORD '{RestrictedPassword}'"); await ExecAdminAsync("postgres", $"GRANT CONNECT ON DATABASE \"{DatabaseName}\" TO {RestrictedRole}"); } protected override async Task DropOwnedServerObjectsAsync() { NpgsqlConnection.ClearAllPools(); await ExecAdminAsync("postgres", $"DROP DATABASE IF EXISTS \"{DatabaseName}\" WITH (FORCE)"); await ExecAdminAsync("postgres", $"DROP DATABASE IF EXISTS \"{FreshDatabaseName}\" WITH (FORCE)"); // The role owns nothing outside the dropped databases: its grants went with them. await ExecAdminAsync("postgres", $"DROP ROLE IF EXISTS {RestrictedRole}"); } protected override async Task GrantRestrictedAsync() { // Read and write everything, execute everything, own nothing. Exactly the shape a DBA leaves // an application in after installation. await ExecAdminAsync(DatabaseName, $""" GRANT USAGE ON SCHEMA public TO {RestrictedRole}; GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO {RestrictedRole}; GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA public TO {RestrictedRole}; GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO {RestrictedRole}; """); } protected override Task SetDeployedModuleVersionAsync(string version) => ExecAdminAsync(DatabaseName, $""" CREATE OR REPLACE FUNCTION pvt_module_version() RETURNS text LANGUAGE plpgsql IMMUTABLE AS $$ BEGIN RETURN '{version}'; END $$; """); protected override async Task ReadDeployedModuleVersionAsync() => (await ScalarAdminAsync(DatabaseName, "SELECT pvt_module_version()"))!; protected override Task SetDeployedModuleCompatAsync(string? compat) => ExecAdminAsync(DatabaseName, compat is null ? "DROP FUNCTION IF EXISTS pvt_module_compat()" : $""" CREATE OR REPLACE FUNCTION pvt_module_compat() RETURNS text LANGUAGE sql IMMUTABLE AS $$ SELECT '{compat}'::text $$; """); protected override Task ApplyScriptAsOwnerAsync(IRedbContext ownerContext, string script) => ownerContext.ExecuteAsync(script); protected override async Task ReadSchemaFingerprintAsync() => (await ScalarAdminAsync(DatabaseName, """ SELECT concat_ws('|', (SELECT count(*) FROM pg_constraint WHERE contype = 'f'), (SELECT last_value::text FROM global_identity), (SELECT count(*) FROM pg_trigger WHERE NOT tgisinternal), (SELECT count(*) FROM pg_proc p JOIN pg_namespace n ON n.oid = p.pronamespace WHERE n.nspname = 'public'), (SELECT count(*) FROM _objects), (SELECT count(*) FROM _values), (SELECT count(*) FROM _schemes), (SELECT count(*) FROM _users)) """))!; /// psql with -v ON_ERROR_STOP=1, as the header of the script asks: the run stops at the first error. protected override async Task> RunScriptByHandAsync(string script) { try { await ExecAdminAsync(DatabaseName, script); return []; } catch (PostgresException ex) { return [ex.MessageText]; } } protected override async Task DropV4UpgradeDdlAsync() { await ExecAdminAsync(DatabaseName, """ DROP INDEX IF EXISTS "UIX__values__structure_unique"; DROP INDEX IF EXISTS "UIX__objects__scheme_unique"; ALTER TABLE _values DROP COLUMN IF EXISTS _unique; ALTER TABLE _structures DROP COLUMN IF EXISTS _unique; ALTER TABLE _structures DROP COLUMN IF EXISTS _unique_version; ALTER TABLE _structures DROP COLUMN IF EXISTS _lazy; ALTER TABLE _scheme_metadata_cache DROP COLUMN IF EXISTS _unique; ALTER TABLE _scheme_metadata_cache DROP COLUMN IF EXISTS _unique_version; ALTER TABLE _scheme_metadata_cache DROP COLUMN IF EXISTS _lazy; ALTER TABLE _objects DROP COLUMN IF EXISTS _value_unique; """); } protected override async Task V4UpgradeDdlExistsAsync() { var present = await ScalarAdminAsync(DatabaseName, """ SELECT (SELECT COUNT(*) FROM information_schema.columns WHERE (table_name, column_name) IN (('_values','_unique'), ('_structures','_unique'), ('_structures','_unique_version'), ('_structures','_lazy'), ('_scheme_metadata_cache','_unique'), ('_scheme_metadata_cache','_unique_version'), ('_scheme_metadata_cache','_lazy'), ('_objects','_value_unique'))) + (SELECT COUNT(*) FROM pg_indexes WHERE indexname IN ('UIX__values__structure_unique', 'UIX__objects__scheme_unique')) """); return Convert.ToInt64(present) == 10; } [Fact] public async Task RootDuplicates_EmptyOnesRemoved_OneWithValuesWaitsForTheHandFix() { // A database written before the schema lock holds root fields twice. The module upgrade removes the empty // copies (a nested class with its child among them), keeps the copy with values and leaves the unique key of // root structures unbuilt with a warning; once the copy is resolved by hand, the next upgrade builds it. await using var owner = Build(OwnerConnectionString, autoApply: true, cacheDomain: $"root-dup-{Guid.NewGuid():N}"); var redb = owner.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); var context = owner.GetRequiredService(); var scenario = await RootDuplicatesScenario.PlantAsync(redb, context); try { var logs = new CollectingLoggerProvider(); await SetDeployedModuleVersionAsync("0.0.0-test"); await using (var sp = Build(OwnerConnectionString, autoApply: true, cacheDomain: $"root-dup-{Guid.NewGuid():N}", logs: logs)) { var started = sp.GetRequiredService(); await started.InitializeAsync(ensureCreated: true); scenario.ShouldReportCountOnly(started, logs); } (await RootDuplicatesScenario.StructureExistsAsync(context, scenario.TitleDuplicate)).Should().BeFalse(); (await RootDuplicatesScenario.StructureExistsAsync(context, scenario.PartDuplicate)).Should().BeFalse(); (await RootDuplicatesScenario.StructureExistsAsync(context, scenario.PartDuplicateChild)).Should().BeFalse(); (await RootDuplicatesScenario.StructureExistsAsync(context, scenario.CountDuplicate)).Should().BeTrue("it holds a value"); (await RootKeyExistsAsync()).Should().BeFalse(); // A plain start, no module upgrade: the error again, the same list. var again = new CollectingLoggerProvider(); await using (var sp = Build(OwnerConnectionString, autoApply: true, cacheDomain: $"root-dup-{Guid.NewGuid():N}", logs: again)) { var started = sp.GetRequiredService(); await started.InitializeAsync(ensureCreated: true); scenario.ShouldReportCountOnly(started, again); } await scenario.ResolveByHandAsync(context); await SetDeployedModuleVersionAsync("0.0.0-test"); await using (var sp = Build(OwnerConnectionString, autoApply: true, cacheDomain: $"root-dup-{Guid.NewGuid():N}")) { var started = sp.GetRequiredService(); await started.InitializeAsync(ensureCreated: true); started.SchemaProblems.Should().BeEmpty(); } (await RootKeyExistsAsync()).Should().BeTrue(); } finally { await context.ExecuteAsync($"DELETE FROM _objects WHERE _id = {scenario.ObjectId}"); await scenario.ResolveByHandAsync(context); await context.ExecuteAsync( $"CREATE UNIQUE INDEX IF NOT EXISTS \"{RootStructureKey.IndexName}\" ON _structures (_id_scheme, _name) WHERE _id_parent IS NULL"); } } private async Task RootKeyExistsAsync() => await ScalarAdminAsync(DatabaseName, $"SELECT 1 FROM pg_indexes WHERE indexname = '{RootStructureKey.IndexName}'") != null; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresSchemeLoadValidationTests.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/Postgres/PostgresSchemeLoadValidationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresSchemeLoadValidationTests : SchemeLoadValidationTestsBase { public PostgresSchemeLoadValidationTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresSchemeNamingTests.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/Postgres/PostgresSchemeNamingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresSchemeNamingTests : SchemeNamingTestsBase { public PostgresSchemeNamingTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresSchemeRenameTests.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/Postgres/PostgresSchemeRenameTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresSchemeRenameTests : SchemeRenameTestsBase { public PostgresSchemeRenameTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresSqlPreviewTests.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/Postgres/PostgresSqlPreviewTests.cs ---- using redb.Core.Query; using redb.Core.Query.Aggregation; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresSqlPreviewTests : SqlPreviewTestsBase { public PostgresSqlPreviewTests(PostgresFixture fixture) : base(fixture.Redb) { } // The Free module averages the elements of an array as their sum over their count: it unnests the array and // guards the count with NULLIF, where Pro writes AVG over the element rows. public override async Task Preview_AggAvgOverArray_ContainsUnnestAndNullIf() { var sql = await Redb.Query() .ToAggregateSqlStringAsync(x => new { Avg = Agg.Average(x.Props.SkillLevels.Select(s => s)) }); sql.ToUpperInvariant().Should().Contain("UNNEST(").And.Contain("NULLIF("); sql.Should().ContainEquivalentOf("_long"); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresSubSecondUpdateTests.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/Postgres/PostgresSubSecondUpdateTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresSubSecondUpdateTests : SubSecondUpdateTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTagsFieldTests.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/Postgres/PostgresTagsFieldTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresTagsFieldTests : TagsFieldTestsBase { public PostgresTagsFieldTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTemporalRoundTripTests.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/Postgres/PostgresTemporalRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresTemporalRoundTripTests : TemporalRoundTripTestsBase { public PostgresTemporalRoundTripTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTimeTicksTests.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/Postgres/PostgresTimeTicksTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresTimeTicksTests : TimeTicksTestsBase { public PostgresTimeTicksTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresToStringJsonTests.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/Postgres/PostgresToStringJsonTests.cs ---- using System.Threading; using System.Text.Json; using redb.Core; using redb.Core.Models.Entities; using redb.Core.Providers; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Helpers; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Postgres; /// /// RedbObject.ToString() returns the object's canonical JSON (discussion #12, item 2). The logic /// is provider-independent (one serializer for all), so one provider carries the suite; the /// database round-trip test is the contract check against the real get_object_json. /// [Collection("Postgres")] public class PostgresToStringJsonTests { private readonly IRedbService _redb; public PostgresToStringJsonTests(PostgresFixture fixture) => _redb = fixture.Redb; [Fact] public void ToString_RoundTripsThroughTheSerializer() { // In-memory only: the string must be parseable by the same serializer back into an // equivalent object - that is what "canonical JSON" means. var obj = TestDataFactory.CreateSimple("ToString-probe", 12.5m); obj.id = 424242; obj.scheme_id = 111; var json = obj.ToString(); var parsed = new redb.Core.Serialization.SystemTextJsonRedbSerializer() .Deserialize(json); parsed.id.Should().Be(424242); parsed.name.Should().Be(obj.name); parsed.Props.Title.Should().Be("ToString-probe"); parsed.Props.Price.Should().Be(12.5m); } [Fact] public async Task ToString_MatchesWhatTheDatabaseHolds() { // The contract check: parse get_object_json(id) and parse ToString() - the Props must be // identical. Not compared as raw strings (field order and number formatting may differ); // equality through the shared serializer is the honest form of "the same contract". var obj = TestDataFactory.CreateSimple("ToString-db-probe", 77.25m); obj.id = await _redb.SaveAsync(obj); var loaded = await _redb.LoadAsync(obj.id, depth: 1); var dbJson = await _redb.Context.ExecuteScalarAsync( $"SELECT get_object_json({obj.id}, 1)::text"); var serializer = new redb.Core.Serialization.SystemTextJsonRedbSerializer(); var fromDb = serializer.Deserialize(dbJson!); var fromToString = serializer.Deserialize(loaded!.ToString()); fromToString.id.Should().Be(fromDb.id); fromToString.hash.Should().Be(fromDb.hash); fromToString.Props.Title.Should().Be(fromDb.Props.Title); fromToString.Props.Price.Should().Be(fromDb.Props.Price); fromToString.Props.Count.Should().Be(fromDb.Props.Count); fromToString.Props.CreatedAt.Should().Be(fromDb.Props.CreatedAt); } [Fact] public void ToString_OnATree_UsesTheCanonicalView_NoCycles_NoLoad() { // Review find: the stub write converter matches exactly RedbObject<>, so a // TreeRedbObject serialized by its runtime type would fall into reflection - walking // the Parent/Children cycle and the lazy Props getter. ToString must serialize the // canonical RedbObject view instead. var parent = new TreeRedbObject { id = 1, name = "parent", _lazyLoader = new ExplodingLoader() }; var child = new TreeRedbObject { id = 2, name = "child", Parent = parent, _lazyLoader = new ExplodingLoader() }; parent.Children.Add(child); var json = child.ToString(); json.Should().NotContain("toStringError"); json.Should().NotContain("\"parent\"", "tree navigation is not part of the canonical view"); using var doc = JsonDocument.Parse(json); doc.RootElement.GetProperty("id").GetInt64().Should().Be(2); } [Fact] public void ToString_OnALazyStub_NeverLoads() { // A stub carries base fields and an attached loader; stringifying it must not reach the // database (EF's lazy proxies famously do exactly that from the debugger). The exploding // loader proves it: any load attempt fails the test. var stub = new RedbObject { id = 515151, scheme_id = 111, name = "stub-probe", _lazyLoader = new ExplodingLoader(), }; stub.IsPropsLoaded.Should().BeFalse("the probe must actually be an unloaded stub"); var json = stub.ToString(); json.Should().Contain("\"id\":515151"); json.Should().NotContain("toStringError"); using var doc = JsonDocument.Parse(json); if (doc.RootElement.TryGetProperty("properties", out var props)) props.ValueKind.Should().Be(JsonValueKind.Null, "an unloaded stub has no properties to show"); } private sealed class ExplodingLoader : ILazyPropsLoader { public TProps? LoadProps(long objectId, long schemeId) where TProps : class, new() => throw new InvalidOperationException("ToString must never trigger lazy loading"); public Task LoadPropsAsync(long objectId, long schemeId, CancellationToken cancellationToken = default) where TProps : class, new() => throw new InvalidOperationException("ToString must never trigger lazy loading"); public Task LoadPropsForManyAsync(List> objects, CancellationToken cancellationToken = default) where TProps : class, new() => throw new InvalidOperationException("ToString must never trigger lazy loading"); public Task LoadPropsForManyAsync(List> objects, HashSet? projectedStructureIds, CancellationToken cancellationToken = default) where TProps : class, new() => throw new InvalidOperationException("ToString must never trigger lazy loading"); public Task LoadPropsForManyAsync(List> objects, int? propsDepth, CancellationToken cancellationToken = default) where TProps : class, new() => throw new InvalidOperationException("ToString must never trigger lazy loading"); public Task LoadPropsForManyAsync(List> objects, HashSet? projectedStructureIds, int? propsDepth, CancellationToken cancellationToken = default) where TProps : class, new() => throw new InvalidOperationException("ToString must never trigger lazy loading"); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTransactionIsolationTests.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/Postgres/PostgresTransactionIsolationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresTransactionIsolationTests : TransactionIsolationTestsBase { public PostgresTransactionIsolationTests(PostgresFixture fixture) : base(fixture.Redb) { } protected override string? ReadLevelSql => "SHOW transaction_isolation"; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTrashBackgroundServiceTests.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/Postgres/PostgresTrashBackgroundServiceTests.cs ---- using Npgsql; using redb.Core.Extensions; using redb.Postgres.Data; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresTrashBackgroundServiceTests : TrashBackgroundServiceTestsBase { private readonly string _name = $"redb_probe_trashbg_{Guid.NewGuid():N}"[..40]; protected override async Task CreateEmptyDatabaseAsync() { await using var admin = new NpgsqlRedbConnection(ConnString("Postgres")); await admin.ExecuteAsync($"CREATE DATABASE \"{_name}\""); return new NpgsqlConnectionStringBuilder(ConnString("Postgres")) { Database = _name }.ConnectionString; } protected override async Task DropDatabaseAsync(string connectionString) { NpgsqlConnection.ClearPool(new NpgsqlConnection(connectionString)); await using var admin = new NpgsqlRedbConnection(ConnString("Postgres")); await admin.ExecuteAsync($"DROP DATABASE IF EXISTS \"{_name}\" WITH (FORCE)"); } protected override void UseProvider(RedbOptionsBuilder options, string connectionString) => options.UsePostgres(connectionString); } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTrashPurgeTests.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/Postgres/PostgresTrashPurgeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresTrashPurgeTests : TrashPurgeTestsBase { public PostgresTrashPurgeTests(PostgresFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTrashedReferenceTargetTests.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/Postgres/PostgresTrashedReferenceTargetTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresTrashedReferenceTargetTests : TrashedReferenceTargetTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTreeAggregateTests.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/Postgres/PostgresTreeAggregateTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresTreeAggregateTests : TreeAggregateTestsBase { public PostgresTreeAggregateTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTreeDistinctTests.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/Postgres/PostgresTreeDistinctTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresTreeDistinctTests : TreeDistinctTestsBase { public PostgresTreeDistinctTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTreeLevelAnalyticsTests.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/Postgres/PostgresTreeLevelAnalyticsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresTreeLevelAnalyticsTests : TreeLevelAnalyticsTestsBase { public PostgresTreeLevelAnalyticsTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTreeOrderAndPreviewTests.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/Postgres/PostgresTreeOrderAndPreviewTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresTreeOrderAndPreviewTests : TreeOrderAndPreviewTestsBase { public PostgresTreeOrderAndPreviewTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTreeQueryShapesTests.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/Postgres/PostgresTreeQueryShapesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresTreeQueryShapesTests : TreeQueryShapesTestsBase { public PostgresTreeQueryShapesTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTreeSourceFormTests.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/Postgres/PostgresTreeSourceFormTests.cs ---- using redb.Core; using redb.Core.Models.Entities; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Helpers; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Postgres; /// /// Free PostgreSQL module: a tree query restricts the objects to the walk as o._id = ANY(ARRAY(SELECT _id FROM /// _pvt_tree ...)). The pivot starts from the objects, so the walk is read twice; as an IN subquery the recursive CTE, /// estimated at a few hundred rows, became the inner side of nested loops, and a Props filter over a 100 thousand node /// subtree ran for minutes (E204). The array is computed once and both reads become index lookups. /// [Collection("Postgres")] public class PostgresTreeSourceFormTests { private readonly IRedbService _redb; public PostgresTreeSourceFormTests(PostgresFixture fixture) => _redb = fixture.Redb; [Fact] public async Task TreeQueryWithAPropsFilter_ReadsTheWalkAsAnArray() { await _redb.SyncSchemeAsync(); var root = new TreeRedbObject { name = "form-" + Guid.NewGuid().ToString("N")[..8], Props = TestDataFactory.CreateEmployee(1).Props }; root.id = await _redb.SaveAsync(root); var sql = await _redb.TreeQuery(root.id) .Where(e => e.Salary >= 60000m && e.Salary < 90000m) .ToSqlStringAsync(); sql.Should().Contain("= ANY(ARRAY(SELECT _id FROM _pvt_tree"); sql.Should().NotContain("IN (SELECT _id FROM _pvt_tree"); } [Fact] public async Task TreeQueryWithALevel_ReadsTheWalkDepthAsAnArray() { await _redb.SyncSchemeAsync(); var root = new TreeRedbObject { name = "form-" + Guid.NewGuid().ToString("N")[..8], Props = TestDataFactory.CreateEmployee(1).Props }; root.id = await _redb.SaveAsync(root); var sql = await _redb.TreeQuery(root.id) .Where(e => e.Salary > 0m) .WhereLevel(1) .ToSqlStringAsync(); sql.Should().Contain("= ANY(ARRAY(SELECT _id FROM _pvt_tree GROUP BY _id HAVING"); sql.Should().NotContain("IN (SELECT _id FROM _pvt_tree"); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTreeSqlPreviewTests.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/Postgres/PostgresTreeSqlPreviewTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresTreeSqlPreviewTests : TreeSqlPreviewTestsBase { public PostgresTreeSqlPreviewTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTreeTests.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/Postgres/PostgresTreeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresTreeTests : TreeTestsBase { public PostgresTreeTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresTypeMigrationSyncTests.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/Postgres/PostgresTypeMigrationSyncTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresTypeMigrationSyncTests : TypeMigrationSyncTestsBase { public PostgresTypeMigrationSyncTests(PostgresFixture fixture) : base(fixture.Redb) { } protected override string TextTypeName => "TEXT"; protected override string BoolTrue => "TRUE"; protected override string BoolFalse => "FALSE"; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresUniqueKeyTests.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/Postgres/PostgresUniqueKeyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresUniqueKeyTests : UniqueKeyTestsBase { public PostgresUniqueKeyTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresUnregisteredTreeTargetTests.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/Postgres/PostgresUnregisteredTreeTargetTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresUnregisteredTreeTargetTests : UnregisteredTreeTargetTestsBase { public PostgresUnregisteredTreeTargetTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresUntypedLinkedObjectTests.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/Postgres/PostgresUntypedLinkedObjectTests.cs ---- using Microsoft.Extensions.Configuration; using redb.Core.Extensions; using redb.Postgres.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; public class PostgresUntypedLinkedObjectTests : UntypedLinkedObjectTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresUserConfigurationServiceTests.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/Postgres/PostgresUserConfigurationServiceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresUserConfigurationServiceTests : UserConfigurationServiceTestsBase { public PostgresUserConfigurationServiceTests(PostgresFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresValueOnlyObjectSaveTests.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/Postgres/PostgresValueOnlyObjectSaveTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresValueOnlyObjectSaveTests : ValueOnlyObjectSaveTestsBase { public PostgresValueOnlyObjectSaveTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresValueUniqueTests.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/Postgres/PostgresValueUniqueTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresValueUniqueTests : ValueUniqueTestsBase { public PostgresValueUniqueTests(PostgresFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresValuesFkIndexesTests.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/Postgres/PostgresValuesFkIndexesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresValuesFkIndexesTests : ValuesFkIndexesTestsBase { public PostgresValuesFkIndexesTests(PostgresFixture fixture) : base(fixture.Redb) { } protected override async Task IndexExistsAsync(string indexName) => await Redb.Context.ExecuteScalarAsync( "SELECT COUNT(*) FROM pg_indexes WHERE indexname = '{0}'".Replace("{0}", indexName)) > 0; } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresWhereTests.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/Postgres/PostgresWhereTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresWhereTests : WhereTestsBase { public PostgresWhereTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Postgres/PostgresWindowTests.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/Postgres/PostgresWindowTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Postgres; [Collection("Postgres")] public class PostgresWindowTests : WindowTestsBase { public PostgresWindowTests(PostgresFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProAbsentFieldConsistencyTests.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/PostgresPro/PostgresProAbsentFieldConsistencyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProAbsentFieldConsistencyTests : AbsentFieldConsistencyTestsBase { public PostgresProAbsentFieldConsistencyTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProAbsentValuesTests.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/PostgresPro/PostgresProAbsentValuesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProAbsentValuesTests : AbsentValuesTestsBase { public PostgresProAbsentValuesTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProAggregatePathTests.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/PostgresPro/PostgresProAggregatePathTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProAggregatePathTests : AggregatePathTestsBase { public PostgresProAggregatePathTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProAggregatePreviewTests.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/PostgresPro/PostgresProAggregatePreviewTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProAggregatePreviewTests : ProAggregatePreviewTestsBase { public PostgresProAggregatePreviewTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProAggregationOverArrayTests.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/PostgresPro/PostgresProAggregationOverArrayTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProAggregationOverArrayTests : AggregationOverArrayTestsBase { public PostgresProAggregationOverArrayTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProAggregationTests.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/PostgresPro/PostgresProAggregationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProAggregationTests : AggregationTestsBase { public PostgresProAggregationTests(PostgresProFixture fixture) : base(fixture.Redb, isPro: true) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProAmbientTransactionTests.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/PostgresPro/PostgresProAmbientTransactionTests.cs ---- using redb.Core.Data; using redb.Postgres.Data; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProAmbientTransactionTests : AmbientTransactionTestsBase { public PostgresProAmbientTransactionTests(PostgresProFixture fixture) : base(fixture.ServiceProvider) { } protected override string CreateProbeTableSql => "CREATE TABLE IF NOT EXISTS ambient_tx_rows (tag varchar(100) NOT NULL)"; protected override string SlowStatementSql => "SELECT 1 FROM pg_sleep(2)"; protected override IRedbConnection CreateStandaloneConnection(IServiceProvider services, bool differentSessionSettings) => new NpgsqlRedbConnection(NpgsqlDataSourceFactory.Create( ConnString("Postgres"), stringCollation: null, lazyReferences: differentSessionSettings)); } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProAnalyticsTelemetryTests.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/PostgresPro/PostgresProAnalyticsTelemetryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProAnalyticsTelemetryTests : AnalyticsTelemetryTestsBase { public PostgresProAnalyticsTelemetryTests(PostgresProFixture fixture) : base(fixture.Redb) { } protected override int CommandsPerCall => 1; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProArrayAnyTests.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/PostgresPro/PostgresProArrayAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProArrayAnyTests : ArrayAnyTestsBase { public PostgresProArrayAnyTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProArrayGroupByDeepTests.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/PostgresPro/PostgresProArrayGroupByDeepTests.cs ---- using redb.Core; using redb.Core.Models.Entities; using redb.Core.Query.Aggregation; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Helpers; using redb.Tests.Integration.Models; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProArrayGroupByDeepTests : ArrayGroupByDeepTestsBase { private readonly IRedbService _redb; public PostgresProArrayGroupByDeepTests(PostgresProFixture fixture) : base(fixture.Redb) => _redb = fixture.Redb; private Task UnconditionedPreviewAsync() => _redb.Query() .GroupByArray(e => e.Contacts!.SelectMany(c => c.Metadata!), m => m.Label) .ToSqlStringAsync(g => new { Label = g.Key, Entries = Agg.Count(g), OfA = Agg.Count(g, m => m.Value == "a") }); private Task> UnconditionedGroupingAsync() => _redb.Query() .GroupByArray(e => e.Contacts!.SelectMany(c => c.Metadata!), m => m.Label) .SelectAsync(g => new GroupRow { Label = g.Key, Entries = Agg.Count(g) }); private sealed class GroupRow { public string? Label { get; set; } public int Entries { get; set; } } private Task NestedLoopsAsync() => _redb.Context.ExecuteScalarAsync("SELECT current_setting('enable_nestloop')"); // Without a condition the grouping runs with nested loops off for its one statement: every element is read anyway, // and the merge of each field's range read 29 000 buffers where the walk over the elements read 1.6 million. [Fact] public async Task UnconditionedGrouping_PreviewShowsTheNestedLoopsSetting() { var sql = await UnconditionedPreviewAsync(); sql.Should().Contain("set_config('enable_nestloop', 'off', true)") .And.Contain("set_config('enable_nestloop', current_setting('redb.nestloop_before'), true)"); } // With a condition the walk over the elements is right for a few objects, so the statement keeps its plan. [Fact] public async Task ConditionedGrouping_PreviewHasNoPlannerSetting() { var sql = await _redb.Query() .Where(e => e.HomeAddress!.Building!.Floor > 10) .GroupByArray(e => e.Contacts!.SelectMany(c => c.Metadata!), m => m.Label) .ToSqlStringAsync(g => new { Label = g.Key, Entries = Agg.Count(g) }); sql.Should().NotContain("enable_nestloop"); } // A tree grouping reads the nodes of its subtree, a narrower set than the scheme, so it counts as conditioned. [Fact] public async Task TreeGrouping_PreviewHasNoPlannerSetting() { await _redb.SyncSchemeAsync(); var root = new TreeRedbObject { name = "nl-root-" + Guid.NewGuid().ToString("N")[..8], Props = TestDataFactory.CreateEmployee(0).Props }; root.id = await _redb.SaveAsync(root); var sql = await _redb.TreeQuery(root.id) .GroupByArray(e => e.Contacts!, c => c.Type) .ToSqlStringAsync(g => new { Type = g.Key, Count = Agg.Count(g) }); sql.Should().NotContain("enable_nestloop"); } // The setting lives for the grouping statement only: the next statement on the same connection plans with nested // loops on again, outside a transaction and inside the caller's. [Fact] public async Task UnconditionedGrouping_LeavesNestedLoopsOn_OutsideATransaction() { await _redb.SyncSchemeAsync(); (await NestedLoopsAsync()).Should().Be("on", "precondition"); await UnconditionedGroupingAsync(); (await NestedLoopsAsync()).Should().Be("on"); } [Fact] public async Task UnconditionedGrouping_LeavesNestedLoopsOn_InsideTheCallersTransaction() { await _redb.SyncSchemeAsync(); await using var transaction = await _redb.Context.BeginTransactionAsync(); (await NestedLoopsAsync()).Should().Be("on", "precondition"); await UnconditionedGroupingAsync(); (await NestedLoopsAsync()).Should().Be("on", "the setting is put back inside the caller's transaction"); await transaction.CommitAsync(); (await NestedLoopsAsync()).Should().Be("on"); } // A caller that turned nested loops off itself keeps them off: the grouping changes nothing and puts nothing back. [Fact] public async Task UnconditionedGrouping_KeepsTheCallersOwnSetting() { await _redb.SyncSchemeAsync(); await using var transaction = await _redb.Context.BeginTransactionAsync(); await _redb.Context.ExecuteScalarAsync("SELECT set_config('enable_nestloop', 'off', true)"); await UnconditionedGroupingAsync(); (await NestedLoopsAsync()).Should().Be("off"); await transaction.RollbackAsync(); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProArrayGroupMetadataCacheTests.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/PostgresPro/PostgresProArrayGroupMetadataCacheTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProArrayGroupMetadataCacheTests : ArrayGroupMetadataCacheTestsBase { public PostgresProArrayGroupMetadataCacheTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProArrayOfClassesAnyTests.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/PostgresPro/PostgresProArrayOfClassesAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProArrayOfClassesAnyTests : ArrayOfClassesAnyTestsBase { public PostgresProArrayOfClassesAnyTests(PostgresProFixture fixture) : base(fixture.Redb) { } protected override bool ReadsAnyOverClasses => true; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProArrayParentIndexTests.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/PostgresPro/PostgresProArrayParentIndexTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Npgsql; using redb.Core; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.PostgresPro; /// /// IX__values__array_parent_id is the leading column of IX__values__array_parent_index, which serves the same lookups /// and the cascade of FK__values__array_parent. A new database does not create it; the module drops it on an existing /// database only where a wider index led by _array_parent_id exists, because a database created by an old version may /// lack array_parent_index and the cascade must keep an index. The test owns its database and makes the module apply /// again by removing its version function, as a database with an older module meets it. /// public class PostgresProArrayParentIndexTests : IClassFixture { private const string Narrow = "IX__values__array_parent_id"; private const string Wide = "IX__values__array_parent_index"; private static readonly string AdminBase = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; private readonly SchemaUpgradeCleanup _cleanup; public PostgresProArrayParentIndexTests(SchemaUpgradeCleanup cleanup) { _cleanup = cleanup; cleanup.Register(async () => { NpgsqlConnection.ClearAllPools(); await AdminAsync("postgres", $"DROP DATABASE IF EXISTS \"{DatabaseName}\" WITH (FORCE)"); }); } private string DatabaseName => $"redb_arrparent_{_cleanup.Suffix}"; [Fact] public async Task NarrowIndex_IsLeftOutOfANewDatabase_AndDroppedOnlyWhereTheWideOneExists() { var database = DatabaseName; await AdminAsync("postgres", $"DROP DATABASE IF EXISTS \"{database}\" WITH (FORCE)"); await AdminAsync("postgres", $"CREATE DATABASE \"{database}\""); await StartAsync(database, ensureCreated: true); (await IndexExistsAsync(database, Narrow)).Should().BeFalse("a new database does not create it"); (await IndexExistsAsync(database, Wide)).Should().BeTrue(); // An existing database of an older module: both indexes. The module drops the narrow one. await AdminAsync(database, $"CREATE INDEX \"{Narrow}\" ON _values (_array_parent_id)"); await AdminAsync(database, "DROP FUNCTION pvt_module_version()"); await StartAsync(database, ensureCreated: false); (await IndexExistsAsync(database, Narrow)).Should().BeFalse("the wider index serves its lookups and the cascade"); (await IndexExistsAsync(database, Wide)).Should().BeTrue(); // A database created by an old version without the wide index: the narrow one is the cascade's only index. await AdminAsync(database, $"CREATE INDEX \"{Narrow}\" ON _values (_array_parent_id)"); await AdminAsync(database, $"DROP INDEX \"{Wide}\""); await AdminAsync(database, "DROP FUNCTION pvt_module_version()"); await StartAsync(database, ensureCreated: false); (await IndexExistsAsync(database, Narrow)).Should().BeTrue("without a wider index the cascade keeps this one"); } private static async Task StartAsync(string database, bool ensureCreated) { var cs = new NpgsqlConnectionStringBuilder(AdminBase) { Database = database }.ConnectionString; var license = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build()["Redb:License"]; var services = new ServiceCollection(); services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => { options.UsePostgres(cs).Configure(c => c.EnablePropsCache = false); if (!string.IsNullOrWhiteSpace(license)) options.WithLicense(license); }); await using var provider = services.BuildServiceProvider(); await provider.GetRequiredService().InitializeAsync(ensureCreated); NpgsqlConnection.ClearAllPools(); } private static async Task IndexExistsAsync(string database, string name) => (long)(await AdminScalarAsync(database, $"SELECT count(*) FROM pg_indexes WHERE indexname = '{name}'"))! > 0; private static async Task AdminAsync(string database, string sql) { await using var conn = new NpgsqlConnection(new NpgsqlConnectionStringBuilder(AdminBase) { Database = database, Pooling = false }.ConnectionString); await conn.OpenAsync(); await using var cmd = conn.CreateCommand(); cmd.CommandText = sql; await cmd.ExecuteNonQueryAsync(); } private static async Task AdminScalarAsync(string database, string sql) { await using var conn = new NpgsqlConnection(new NpgsqlConnectionStringBuilder(AdminBase) { Database = database, Pooling = false }.ConnectionString); await conn.OpenAsync(); await using var cmd = conn.CreateCommand(); cmd.CommandText = sql; return await cmd.ExecuteScalarAsync(); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProArrayTests.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/PostgresPro/PostgresProArrayTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProArrayTests : ArrayTestsBase { public PostgresProArrayTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProBareRedbObjectFieldTests.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/PostgresPro/PostgresProBareRedbObjectFieldTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProBareRedbObjectFieldTests : BareRedbObjectFieldTestsBase { public PostgresProBareRedbObjectFieldTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProBaseFieldNameCollisionTests.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/PostgresPro/PostgresProBaseFieldNameCollisionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProBaseFieldNameCollisionTests : BaseFieldNameCollisionTestsBase { public PostgresProBaseFieldNameCollisionTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProBugRegressionTests.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/PostgresPro/PostgresProBugRegressionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProBugRegressionTests : BugRegressionTestsBase { public PostgresProBugRegressionTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProBytesRoundTripTests.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/PostgresPro/PostgresProBytesRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProBytesRoundTripTests : BytesRoundTripTestsBase { public PostgresProBytesRoundTripTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProCacheBehaviorTests.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/PostgresPro/PostgresProCacheBehaviorTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProCacheBehaviorTests : CacheBehaviorTestsBase { public PostgresProCacheBehaviorTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProColdSchemeLinkedObjectTests.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/PostgresPro/PostgresProColdSchemeLinkedObjectTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProColdSchemeLinkedObjectTests : ColdSchemeLinkedObjectTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProColdSchemeTreeFilterTests.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/PostgresPro/PostgresProColdSchemeTreeFilterTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProColdSchemeTreeFilterTests : ColdSchemeTreeFilterTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProCollectionFilterAnalyticsTests.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/PostgresPro/PostgresProCollectionFilterAnalyticsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProCollectionFilterAnalyticsTests : CollectionFilterAnalyticsTestsBase { public PostgresProCollectionFilterAnalyticsTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProCollectionGroupKeyTests.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/PostgresPro/PostgresProCollectionGroupKeyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProCollectionGroupKeyTests : CollectionGroupKeyTestsBase { public PostgresProCollectionGroupKeyTests(PostgresProFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProCollectionKindChangeTests.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/PostgresPro/PostgresProCollectionKindChangeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProCollectionKindChangeTests : CollectionKindChangeTestsBase { public PostgresProCollectionKindChangeTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProComputedComparisonTests.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/PostgresPro/PostgresProComputedComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProComputedComparisonTests : ComputedComparisonTestsBase { public PostgresProComputedComparisonTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProConcurrencyStressTests.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/PostgresPro/PostgresProConcurrencyStressTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProConcurrencyStressTests : ConcurrencyStressTestsBase { public PostgresProConcurrencyStressTests(PostgresProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProConcurrentDeleteCountTests.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/PostgresPro/PostgresProConcurrentDeleteCountTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProConcurrentDeleteCountTests : ConcurrentDeleteCountTestsBase { public PostgresProConcurrentDeleteCountTests(PostgresProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } protected override async Task HoldRowAsync(long objectId) => await RowHolders.PostgresAsync(objectId); } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProConcurrentDeleteListTests.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/PostgresPro/PostgresProConcurrentDeleteListTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Pro.Extensions; using redb.Core.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProConcurrentDeleteListTests : ConcurrentDeleteListTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProConcurrentWritersTests.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/PostgresPro/PostgresProConcurrentWritersTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProConcurrentWritersTests : ConcurrentWritersTestsBase { public PostgresProConcurrentWritersTests(PostgresProFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProConnectionLeaseTests.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/PostgresPro/PostgresProConnectionLeaseTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProConnectionLeaseTests : ConnectionLeaseTestsBase { public PostgresProConnectionLeaseTests(PostgresProFixture fixture) : base(fixture.ServiceProvider) { } protected override string CreateProbeTableSql => "CREATE TABLE IF NOT EXISTS connection_lease_rows (tag varchar(100) NOT NULL)"; protected override bool AmbientLeaseCarriesTransaction => false; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProConstantPredicateTests.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/PostgresPro/PostgresProConstantPredicateTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProConstantPredicateTests : ConstantPredicateTestsBase { public PostgresProConstantPredicateTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProCrudTests.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/PostgresPro/PostgresProCrudTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProCrudTests : CrudTestsBase { public PostgresProCrudTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProCtPerfBenchmarkTests.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/PostgresPro/PostgresProCtPerfBenchmarkTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProCtPerfBenchmarkTests : CtPerfBenchmarkTestsBase { public PostgresProCtPerfBenchmarkTests(PostgresProFixture fixture) : base(fixture.Redb) { } protected override string ProviderName => "PostgresPro"; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProCtSaveInvariantsTests.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/PostgresPro/PostgresProCtSaveInvariantsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProCtSaveInvariantsTests : CtSaveInvariantsTestsBase { public PostgresProCtSaveInvariantsTests(PostgresProFixture fixture) : base(fixture.Redb) { } /// Фикстура гоняет ChangeTracking - строки нетронутых значений обязаны сохранять _id. protected override bool ExpectStableValueRowIds => true; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProDbInfoTests.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/PostgresPro/PostgresProDbInfoTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProDbInfoTests : DbInfoTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } protected override string VersionMarker => "PostgreSQL"; protected override string SizeInBytesSql => "SELECT pg_database_size(current_database())"; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProDecimalRoundTripTests.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/PostgresPro/PostgresProDecimalRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProDecimalRoundTripTests : DecimalRoundTripTestsBase { public PostgresProDecimalRoundTripTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProDeleteBatchCountTests.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/PostgresPro/PostgresProDeleteBatchCountTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProDeleteBatchCountTests : DeleteBatchCountTestsBase { public PostgresProDeleteBatchCountTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProDeleteSubtreeCountTests.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/PostgresPro/PostgresProDeleteSubtreeCountTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Pro.Extensions; using redb.Core.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProDeleteSubtreeCountTests : DeleteSubtreeCountTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProDictionaryEntryKeyFilterTests.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/PostgresPro/PostgresProDictionaryEntryKeyFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProDictionaryEntryKeyFilterTests : DictionaryEntryKeyFilterTestsBase { public PostgresProDictionaryEntryKeyFilterTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProDictionaryEntryLeadsTests.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/PostgresPro/PostgresProDictionaryEntryLeadsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProDictionaryEntryLeadsTests : DictionaryEntryLeadsTestsBase { public PostgresProDictionaryEntryLeadsTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProDictionaryOrderTests.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/PostgresPro/PostgresProDictionaryOrderTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProDictionaryOrderTests : DictionaryOrderTestsBase { public PostgresProDictionaryOrderTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProDictionaryTests.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/PostgresPro/PostgresProDictionaryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProDictionaryTests : DictionaryTestsBase { public PostgresProDictionaryTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProDisposedScopeGuardTests.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/PostgresPro/PostgresProDisposedScopeGuardTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProDisposedScopeGuardTests : DisposedScopeGuardTestsBase { public PostgresProDisposedScopeGuardTests(PostgresProFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProElementFoldOrderTests.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/PostgresPro/PostgresProElementFoldOrderTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProElementFoldOrderTests : ElementFoldOrderTestsBase { public PostgresProElementFoldOrderTests(PostgresProFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProElementIndexFilterTests.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/PostgresPro/PostgresProElementIndexFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProElementIndexFilterTests : ElementIndexFilterTestsBase { public PostgresProElementIndexFilterTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProElementLeafProbeTests.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/PostgresPro/PostgresProElementLeafProbeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.PostgresPro; /// /// With the planner on, a page whose narrow condition is a Contains over an array of simple values reads the element rows /// of the value through the capped probe: fewer than the cap seed the streams, the cap reached keeps the form the query has /// without the probe. The answers are held equal to the other form by PvtPrefilterEquivalenceTestsBase. /// [Collection("PostgresPro")] public class PostgresProElementLeafProbeTests { private readonly redb.Core.IRedbService _redb; public PostgresProElementLeafProbeTests(PostgresProFixture fixture) => _redb = fixture.Redb; [Fact] public async Task Contains_IsProbedOnItsElementRows_UpToTheCap() { var restore = _redb.Configuration.EnablePvtPrefilter; try { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var sql = await _redb.Query().Where(e => e.Skills!.Contains("Azure")).Take(10).ToSqlStringAsync(); sql.Should().Contain("pvt_probe AS MATERIALIZED", "the element rows are probed:\n{0}", sql) .And.Contain("v._array_index IS NOT NULL LIMIT 5000", "up to the cap, on the element rows:\n{0}", sql); } finally { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProEnumComparisonTests.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/PostgresPro/PostgresProEnumComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProEnumComparisonTests : EnumComparisonTestsBase { public PostgresProEnumComparisonTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProEnumDictionaryKeyTests.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/PostgresPro/PostgresProEnumDictionaryKeyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProEnumDictionaryKeyTests : EnumDictionaryKeyTestsBase { public PostgresProEnumDictionaryKeyTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProFieldNamedLikeAFunctionTests.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/PostgresPro/PostgresProFieldNamedLikeAFunctionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProFieldNamedLikeAFunctionTests : FieldNamedLikeAFunctionTestsBase { public PostgresProFieldNamedLikeAFunctionTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProFilterFieldPathTests.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/PostgresPro/PostgresProFilterFieldPathTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProFilterFieldPathTests : FilterFieldPathTestsBase { public PostgresProFilterFieldPathTests(PostgresProFixture fixture) : base(fixture.Redb) { } protected override bool ReadsElementsByIndex => true; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProFreshStatisticsTests.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/PostgresPro/PostgresProFreshStatisticsTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Npgsql; using redb.Core; using redb.Core.Data; using redb.Core.Pro.Extensions; using redb.Core.Query; using redb.Core.Query.Aggregation; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Helpers; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.PostgresPro; /// /// A new database whose tables hold rows but no planner statistics: never analyzed, or analyzed while empty. There /// PostgreSQL took every stream of the streams form for one row and joined them by nested loops that rescan an index /// range per object: a grouping and a window over a range of Props values, and a window over a narrow OR, ran for /// minutes on 600 objects (a test of the equivalence suite ran ten minutes). Each test owns its database, so the /// state of the statistics is its own, and autovacuum is off on both tables so nothing analyzes them meanwhile. /// public class PostgresProFreshStatisticsTests : IClassFixture { private static readonly string AdminBase = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; private readonly SchemaUpgradeCleanup _cleanup; private static readonly string[] Tags = ["q", "s", "k"]; public PostgresProFreshStatisticsTests(SchemaUpgradeCleanup cleanup) { _cleanup = cleanup; cleanup.Register(async () => { NpgsqlConnection.ClearAllPools(); // By name: xUnit makes an instance per test, and the cleanup keeps the removal of the first one only. foreach (var tag in Tags) await AdminAsync("postgres", $"DROP DATABASE IF EXISTS \"{DatabaseName(tag)}\" WITH (FORCE)"); }); } /// /// The range grouping, the range window and the OR window answer within 30 seconds each while the tables have no /// statistics. Before the guard each of them ran past it. /// [Fact] public async Task NoStatistics_GroupingAndWindows_AnswerInBoundedTime() { var (redb, database, provider) = await CreateSeededAsync("q"); (await ReltuplesAsync(database)).Should().BeLessThanOrEqualTo(0, "the test is about tables without statistics"); IRedbQueryable Range() => redb.Query().Where(e => e.Salary > 70000m && e.Age >= 30); IRedbQueryable Or() => redb.Query().Where(e => e.EmployeeCode == "EMP-0010" || e.Age == 33); var limit = TimeSpan.FromSeconds(30); var groups = await Range().GroupBy(x => x.Department) .SelectAsync(g => new { g.Key, Count = Agg.Count(g), Sum = Agg.Sum(g, x => x.Salary) }) .WaitAsync(limit); groups.Should().NotBeEmpty(); var ranked = await Range().Take(20).WithWindow(w => w.PartitionBy(x => x.Department).OrderByDesc(x => x.Salary)) .SelectAsync(x => new { x.Props.Salary, Rank = Win.RowNumber() }) .WaitAsync(limit); ranked.Should().NotBeEmpty(); var orRanked = await Or().Take(20).WithWindow(w => w.PartitionBy(x => x.Department).OrderByDesc(x => x.Salary)) .SelectAsync(x => new { x.Props.Salary, Rank = Win.RowNumber() }) .WaitAsync(limit); orRanked.Should().NotBeEmpty(); (await provider.GetRequiredService().ExecuteScalarAsync("SELECT current_setting('enable_nestloop')")) .Should().Be("on", "the guard puts the setting back after each statement"); } /// /// Start-up analyzes _objects and _values when they hold rows without statistics, as after a pg_restore or a load /// by COPY: a second service starting on the seeded database finds reltuples above zero afterwards. /// [Fact] public async Task Start_AnalyzesTablesThatHoldRowsWithoutStatistics() { var (_, database, _) = await CreateSeededAsync("s"); (await ReltuplesAsync(database)).Should().BeLessThanOrEqualTo(0); await using var provider = BuildServices(database); await provider.GetRequiredService().InitializeAsync(); (await ReltuplesAsync(database)).Should().BeGreaterThan(0, "start-up analyzed the tables"); } /// /// A lookup by object id reads its rows by the primary key, which needs no statistics: while a query by a Props field /// still runs with nested loops off, the same service's lookups by id (one id, an id list, an id with another /// condition) send neither the statistics check nor the switch. /// [Fact] public async Task NoStatistics_LookupById_SendsNoGuard() { var (redb, database, _) = await CreateSeededAsync("k"); (await ReltuplesAsync(database)).Should().BeLessThanOrEqualTo(0, "the test is about tables without statistics"); var ids = (await redb.Query().Take(3).ToListAsync()).Select(o => o.Id).ToArray(); var byField = await GuardStatementsAsync(() => redb.Query().Where(e => e.Age >= 30).Take(5).ToListAsync()); byField.Should().BeGreaterThan(0, "a query by a Props field is still guarded while statistics are missing"); var one = ids[0]; (await GuardStatementsAsync(() => redb.Query().WhereRedb(o => o.Id == one).ToListAsync())).Should().Be(0); (await GuardStatementsAsync(() => redb.Query().WhereRedb(o => ids.Contains(o.Id)).ToListAsync())).Should().Be(0); (await GuardStatementsAsync(() => redb.Query().WhereRedb(o => o.Id == one).Where(e => e.Age >= 0).CountAsync())) .Should().Be(0); (await redb.Query().WhereRedb(o => ids.Contains(o.Id)).ToListAsync()).Select(o => o.Id).Should().BeEquivalentTo(ids); } /// The statements of that check the statistics or set enable_nestloop. private static async Task GuardStatementsAsync(Func> call) { var texts = new List(); var probe = new System.Diagnostics.ActivitySource("redb.Tests.FreshStatisticsGuard"); using var listener = new System.Diagnostics.ActivityListener { ShouldListenTo = s => s.Name.StartsWith("Npgsql", StringComparison.Ordinal) || s.Name == probe.Name, Sample = (ref System.Diagnostics.ActivityCreationOptions _) => System.Diagnostics.ActivitySamplingResult.AllDataAndRecorded, ActivityStopped = a => { var text = (a.GetTagItem("db.query.text") ?? a.GetTagItem("db.statement"))?.ToString(); if (a.Source.Name.StartsWith("Npgsql", StringComparison.Ordinal) && text != null) lock (texts) texts.Add(a.TraceId + "|" + text); }, }; System.Diagnostics.ActivitySource.AddActivityListener(listener); System.Diagnostics.ActivityTraceId trace; using (var parent = probe.StartActivity("guard")!) { trace = parent.TraceId; await call(); } lock (texts) return texts.Count(t => t.StartsWith(trace + "|", StringComparison.Ordinal) && (t.Contains("reltuples", StringComparison.Ordinal) || t.Contains("enable_nestloop", StringComparison.Ordinal))); } private async Task<(IRedbService Redb, string Database, ServiceProvider Provider)> CreateSeededAsync(string tag) { var database = DatabaseName(tag); await AdminAsync("postgres", $"DROP DATABASE IF EXISTS \"{database}\" WITH (FORCE)"); await AdminAsync("postgres", $"CREATE DATABASE \"{database}\""); var provider = BuildServices(database); var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await AdminAsync(database, "ALTER TABLE _objects SET (autovacuum_enabled = false); ALTER TABLE _values SET (autovacuum_enabled = false)"); await redb.SyncSchemeAsync(); await TestDataFactory.SeedEmployees(redb, 600); return (redb, database, provider); } private string DatabaseName(string tag) => $"redb_freshstats_{tag}_{_cleanup.Suffix}"; private static ServiceProvider BuildServices(string database) { var cs = new NpgsqlConnectionStringBuilder(AdminBase) { Database = database }.ConnectionString; var license = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build()["Redb:License"]; var services = new ServiceCollection(); services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => { options.UsePostgres(cs).Configure(c => c.EnablePropsCache = false); if (!string.IsNullOrWhiteSpace(license)) options.WithLicense(license); }); return services.BuildServiceProvider(); } private static async Task ReltuplesAsync(string database) => await AdminScalarAsync(database, "SELECT max(reltuples) FROM pg_class WHERE oid IN (to_regclass('_objects'), to_regclass('_values'))"); private static async Task AdminAsync(string database, string sql) { var cs = new NpgsqlConnectionStringBuilder(AdminBase) { Database = database, Pooling = false }.ConnectionString; await using var conn = new NpgsqlConnection(cs); await conn.OpenAsync(); await using var cmd = conn.CreateCommand(); cmd.CommandText = sql; await cmd.ExecuteNonQueryAsync(); } private static async Task AdminScalarAsync(string database, string sql) { var cs = new NpgsqlConnectionStringBuilder(AdminBase) { Database = database, Pooling = false }.ConnectionString; await using var conn = new NpgsqlConnection(cs); await conn.OpenAsync(); await using var cmd = conn.CreateCommand(); cmd.CommandText = sql; return (T)(await cmd.ExecuteScalarAsync())!; } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProGroupByHavingTests.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/PostgresPro/PostgresProGroupByHavingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProGroupByHavingTests : GroupByHavingTestsBase { public PostgresProGroupByHavingTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProGroupBySelectShapesTests.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/PostgresPro/PostgresProGroupBySelectShapesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProGroupBySelectShapesTests : GroupBySelectShapesTestsBase { public PostgresProGroupBySelectShapesTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProGroupByTests.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/PostgresPro/PostgresProGroupByTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProGroupByTests : GroupByTestsBase { public PostgresProGroupByTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProHashCanonCollisionTests.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/PostgresPro/PostgresProHashCanonCollisionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProHashCanonCollisionTests : HashCanonCollisionTestsBase { public PostgresProHashCanonCollisionTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProIgnoredPropertyWalkTests.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/PostgresPro/PostgresProIgnoredPropertyWalkTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProIgnoredPropertyWalkTests : IgnoredPropertyWalkTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProIndexCatalogTests.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/PostgresPro/PostgresProIndexCatalogTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Models; using redb.Core.Models.Configuration; using redb.Postgres.Pro.Sql; using redb.Postgres.Sql; using redb.Tests.Integration.Tests.Postgres; namespace redb.Tests.Integration.Tests.PostgresPro; /// /// PostgresProIndexCatalog.Pro, the indexes of the streams query form, against a fresh PostgreSQL Pro database of this /// build with the planner on (see ). /// public class PostgresProIndexCatalogTests : PostgresIndexCatalogTests { protected override void AddRedb(IServiceCollection services, string connectionString, Action configure) => redb.Core.Pro.Extensions.RedbProServiceCollectionExtensions.AddRedbPro(services, o => redb.Postgres.Pro.Extensions.PostgresProOptionsExtensions.UsePostgres(o, connectionString).Configure(configure)); protected override IReadOnlyList Catalog => PostgresProIndexCatalog.Pro; protected override IReadOnlyList CoveredElsewhere => PostgresIndexCatalog.Base; protected override (string File, string Namespace, string Class, string Member, RedbIndexOrigin Origin) Target => ("redb.Postgres.Pro/Sql/PostgresProIndexCatalog.g.cs", "redb.Postgres.Pro.Sql", "PostgresProIndexCatalog", "Pro", RedbIndexOrigin.ProModule); } /// The streams indexes of PostgreSQL Pro are built once (see ). public class PostgresProStreamsIndexOnceTests : Base.StreamsIndexOnceTestsBase { protected override async Task CreateDatabaseAsync(string name) { await PostgresIndexCatalogTests.ExecAdminAsync($"CREATE DATABASE \"{name}\""); return new Npgsql.NpgsqlConnectionStringBuilder(PostgresIndexCatalogTests.AdminBase) { Database = name }.ConnectionString; } protected override async Task DropDatabaseAsync(string name) { Npgsql.NpgsqlConnection.ClearAllPools(); await PostgresIndexCatalogTests.ExecAdminAsync($"DROP DATABASE IF EXISTS \"{name}\" WITH (FORCE)"); } protected override void AddRedbPro(IServiceCollection services, string connectionString, Action configure) => redb.Core.Pro.Extensions.RedbProServiceCollectionExtensions.AddRedbPro(services, o => redb.Postgres.Pro.Extensions.PostgresProOptionsExtensions.UsePostgres(o, connectionString).Configure(configure)); protected override string StreamsIndex => "IX__objects__scheme_id"; protected override string DropStreamsIndexSql => "DROP INDEX \"IX__objects__scheme_id\""; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProIntegerAverageTests.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/PostgresPro/PostgresProIntegerAverageTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProIntegerAverageTests : IntegerAverageTestsBase { public PostgresProIntegerAverageTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProKeyCacheRepeatTests.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/PostgresPro/PostgresProKeyCacheRepeatTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProKeyCacheRepeatTests : KeyCacheRepeatTestsBase { public PostgresProKeyCacheRepeatTests(PostgresProFixture fixture) { _ = fixture; } protected override ServiceProvider Build(string applicationName) { var config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); var cs = config.GetConnectionString("Postgres")! + $";Application Name={applicationName}"; var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => { options.UsePostgres(cs).Configure(c => c.EnablePvtPrefilter = ProTestOptions.PvtPrefilter); if (config["Redb:License"] is { Length: > 0 } license) options.WithLicense(license); }); return services.BuildServiceProvider(); } protected override string SequenceTopSql => "SELECT last_value FROM global_identity"; protected override string SequenceRestartSql(long next) => $"SELECT setval('global_identity', {next - 1})"; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProKeyDrawTests.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/PostgresPro/PostgresProKeyDrawTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProKeyDrawTests : KeyDrawTestsBase { public PostgresProKeyDrawTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProKeywordNamesTests.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/PostgresPro/PostgresProKeywordNamesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProKeywordNamesTests : KeywordNamesTestsBase { public PostgresProKeywordNamesTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProLazyHostTests.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/PostgresPro/PostgresProLazyHostTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProLazyHostTests : LazyHostTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } protected override string ReadFlagSql => "SELECT current_setting('redb.lazy_refs', true)"; /// The Pro materializer reads the global option live; its registrations do not arm the session flag. protected override bool SessionFlagIsTheChannel => false; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProLazyReferenceTests.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/PostgresPro/PostgresProLazyReferenceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProLazyReferenceTests : LazyReferenceTestsBase { public PostgresProLazyReferenceTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProLazyReferencesOptionTests.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/PostgresPro/PostgresProLazyReferencesOptionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProLazyReferencesOptionTests : LazyReferencesOptionTestsBase { public PostgresProLazyReferencesOptionTests(PostgresProFixture fixture) : base(fixture.Redb) { } // Л2 boundary: the Pro materializer reads the global option, not the session flag. protected override bool PerQueryOverrideWorks => false; protected override bool GlobalMutationAffects => true; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProLikeEscapingTests.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/PostgresPro/PostgresProLikeEscapingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProLikeEscapingTests : LikeEscapingTestsBase { public PostgresProLikeEscapingTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProListItemArrayAnyTests.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/PostgresPro/PostgresProListItemArrayAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProListItemArrayAnyTests : ListItemArrayAnyTestsBase { public PostgresProListItemArrayAnyTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProListItemObjectLoaderLeakTests.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/PostgresPro/PostgresProListItemObjectLoaderLeakTests.cs ---- using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProListItemObjectLoaderLeakTests : PostgresListItemObjectLoaderLeakTestsBase { protected override bool IsPro => true; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProListItemObjectWalkTests.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/PostgresPro/PostgresProListItemObjectWalkTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProListItemObjectWalkTests : ListItemObjectWalkTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProListReadPropsOnceTests.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/PostgresPro/PostgresProListReadPropsOnceTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Pro.Extensions; using redb.Core.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProListReadPropsOnceTests : ListReadPropsOnceTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProListRoundTripsTests.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/PostgresPro/PostgresProListRoundTripsTests.cs ---- using System.Diagnostics; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProListRoundTripsTests : ListRoundTripsTestsBase { private const string ProbeName = "redb.Tests.PostgresProListRoundTrips"; private static readonly ActivitySource Probe = new(ProbeName); protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } /// /// The statements Npgsql sends for , one activity each, without the statistics guard's own: until /// the tables have planner statistics it checks them and sets enable_nestloop, on a recheck interval, so whether a /// counted call meets it depends on timing. Everything else counts, the scheme hash and the type table included. /// protected override async Task CountRoundTripsAsync(Func call) { var statements = new List(); using var listener = new ActivityListener { ShouldListenTo = s => s.Name.StartsWith("Npgsql", StringComparison.Ordinal) || s.Name == ProbeName, Sample = (ref ActivityCreationOptions _) => ActivitySamplingResult.AllDataAndRecorded, ActivityStopped = a => { lock (statements) statements.Add(a); }, }; ActivitySource.AddActivityListener(listener); ActivityTraceId trace; using (var parent = Probe.StartActivity("round-trips")!) { trace = parent.TraceId; await call(); } lock (statements) return statements.Count(a => a.Source.Name.StartsWith("Npgsql", StringComparison.Ordinal) && a.TraceId == trace && !IsStatisticsGuard((a.GetTagItem("db.query.text") ?? a.GetTagItem("db.statement"))?.ToString())); } /// /// The list goes to the server as its builder writes it (the statement ToSqlStringAsync shows), with the scheme hash /// as a second command of the same batch: no wrapper around the page. Two wrapped forms made large pages slower. /// [Fact] public async Task ListStatement_IsSentAsBuilt_WithTheHashBesideIt() { var run = Guid.NewGuid().ToString("N")[..8]; var services = new ServiceCollection(); Register(services, options => { UseProvider(options); options.Configure(c => { c.EnablePropsCache = false; c.CacheDomain = $"round-trips-text-{run}"; }); }); await using var sp = services.BuildServiceProvider(); var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); var query = redb.Query().Where(p => p.Tag == run).OrderBy(p => p.Number).Take(10); await query.ToListAsync(); var preview = await query.ToSqlStringAsync(); var built = string.Join("\n", preview.Split('\n').Where(l => !l.TrimStart().StartsWith("--", StringComparison.Ordinal))).Trim(); var sent = new List(); using var listener = new ActivityListener { ShouldListenTo = s => s.Name.StartsWith("Npgsql", StringComparison.Ordinal), Sample = (ref ActivityCreationOptions _) => ActivitySamplingResult.AllDataAndRecorded, ActivityStopped = a => { if ((a.GetTagItem("db.query.text") ?? a.GetTagItem("db.statement"))?.ToString() is { } text) lock (sent) sent.Add(text); }, }; ActivitySource.AddActivityListener(listener); await query.ToListAsync(); lock (sent) { sent.Should().NotContain(s => s.Contains("redb_page", StringComparison.Ordinal), "the page is not wrapped"); sent.Should().Contain(s => s.Contains(built, StringComparison.Ordinal), "the list goes as its builder writes it"); sent.Should().Contain(s => s.Contains("_structure_hash FROM _schemes", StringComparison.Ordinal), "the hash rides in the batch"); } } private static bool IsStatisticsGuard(string? statement) => statement != null && (statement.Contains("reltuples", StringComparison.Ordinal) || statement.Contains("enable_nestloop", StringComparison.Ordinal)); } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProListTests.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/PostgresPro/PostgresProListTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProListTests : ListTestsBase { protected override bool IsPro => true; public PostgresProListTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProLongBaseFilterTests.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/PostgresPro/PostgresProLongBaseFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProLongBaseFilterTests : LongBaseFilterTestsBase { public PostgresProLongBaseFilterTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProMaintenanceTests.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/PostgresPro/PostgresProMaintenanceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProMaintenanceTests : MaintenanceTestsBase { public PostgresProMaintenanceTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProMaterializationFidelityTests.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/PostgresPro/PostgresProMaterializationFidelityTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProMaterializationFidelityTests : MaterializationFidelityTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProMaterializerConversionTests.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/PostgresPro/PostgresProMaterializerConversionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProMaterializerConversionTests : ProMaterializerConversionTestsBase { public PostgresProMaterializerConversionTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProMigrationTargetAddressingTests.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/PostgresPro/PostgresProMigrationTargetAddressingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProMigrationTargetAddressingTests : MigrationTargetAddressingTestsBase { public PostgresProMigrationTargetAddressingTests(PostgresProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProMigrationTests.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/PostgresPro/PostgresProMigrationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProMigrationTests : MigrationTestsBase { public PostgresProMigrationTests(PostgresProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProMigrationTransformArithmeticTests.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/PostgresPro/PostgresProMigrationTransformArithmeticTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProMigrationTransformArithmeticTests : MigrationTransformArithmeticTestsBase { public PostgresProMigrationTransformArithmeticTests(PostgresProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProNestedDictionaryFilterTests.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/PostgresPro/PostgresProNestedDictionaryFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProNestedDictionaryFilterTests : NestedDictionaryFilterTestsBase { public PostgresProNestedDictionaryFilterTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProNullComparisonTests.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/PostgresPro/PostgresProNullComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProNullComparisonTests : NullComparisonTestsBase { public PostgresProNullComparisonTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProNullableCollectionsTests.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/PostgresPro/PostgresProNullableCollectionsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProNullableCollectionsTests : NullableCollectionsTestsBase { public PostgresProNullableCollectionsTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProOlderModelTests.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/PostgresPro/PostgresProOlderModelTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProOlderModelTests : OlderModelTestsBase { public PostgresProOlderModelTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProOrderAbsentValueTests.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/PostgresPro/PostgresProOrderAbsentValueTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProOrderAbsentValueTests : OrderAbsentValueTestsBase { public PostgresProOrderAbsentValueTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProOrderingTests.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/PostgresPro/PostgresProOrderingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProOrderingTests : OrderingTestsBase { public PostgresProOrderingTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProPageValuesGraphTests.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/PostgresPro/PostgresProPageValuesGraphTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProPageValuesGraphTests : PageValuesGraphTestsBase { public PostgresProPageValuesGraphTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProPolymorphicTreeTests.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/PostgresPro/PostgresProPolymorphicTreeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProPolymorphicTreeTests : PolymorphicTreeTestsBase { public PostgresProPolymorphicTreeTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProProQueryTests.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/PostgresPro/PostgresProProQueryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProProQueryTests : ProQueryTestsBase { public PostgresProProQueryTests(PostgresProFixture fixture) : base(fixture.Redb, isPro: true) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProProjectionTests.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/PostgresPro/PostgresProProjectionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProProjectionTests : ProjectionTestsBase { public PostgresProProjectionTests(PostgresProFixture fixture) : base(fixture.Redb) { } protected override bool ReadsOnlyProjectedRows => true; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProPropertyRenameTests.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/PostgresPro/PostgresProPropertyRenameTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProPropertyRenameTests : PropertyRenameTestsBase { public PostgresProPropertyRenameTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProPropsCacheHeaderTests.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/PostgresPro/PostgresProPropsCacheHeaderTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProPropsCacheHeaderTests : PropsCacheHeaderTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProPropsCacheSkipValidationTests.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/PostgresPro/PostgresProPropsCacheSkipValidationTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProPropsCacheSkipValidationTests : PropsCacheSkipValidationTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProPropsCacheTransactionKeepTests.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/PostgresPro/PostgresProPropsCacheTransactionKeepTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Pro.Extensions; using redb.Core.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProPropsCacheTransactionKeepTests : PropsCacheTransactionKeepTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProPropsCacheTransactionTests.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/PostgresPro/PostgresProPropsCacheTransactionTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Pro.Extensions; using redb.Core.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProPropsCacheTransactionTests : PropsCacheTransactionTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProPropsDepthBoundaryTests.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/PostgresPro/PostgresProPropsDepthBoundaryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProPropsDepthBoundaryTests : PropsDepthBoundaryTestsBase { public PostgresProPropsDepthBoundaryTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProPurityTests.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/PostgresPro/PostgresProPurityTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProPurityTests : ProPgPurityTestsBase { public PostgresProPurityTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProPvtAuditTests.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/PostgresPro/PostgresProPvtAuditTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; /// /// Pro PG run of the shared PVT audit suite (). /// Pro must reach the same observable LINQ behaviour as Free; SQL dialects /// differ but the test assertions are dialect-agnostic. /// [Collection("PostgresPro")] public class PostgresProPvtAuditTests : PvtAuditTestsBase { public PostgresProPvtAuditTests(PostgresProFixture fixture) : base(fixture.Redb, isPro: true) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProPvtPickAggregateTests.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/PostgresPro/PostgresProPvtPickAggregateTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProPvtPickAggregateTests : ProPgPvtPickAggregateTestsBase { public PostgresProPvtPickAggregateTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProPvtPrefilterEquivalenceTests.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/PostgresPro/PostgresProPvtPrefilterEquivalenceTests.cs ---- using redb.Core.Models.Contracts; using redb.Core.Models.Entities; using redb.Core.Query; using redb.Core.Query.Aggregation; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Helpers; using redb.Tests.Integration.Models; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProPvtPrefilterEquivalenceTests : PvtPrefilterEquivalenceTestsBase { public PostgresProPvtPrefilterEquivalenceTests(PostgresProFixture fixture) : base(fixture.Redb) { } /// /// PostgreSQL only: an aggregate, a grouping and a window over an open range read the range from the /// index of values first, as a page does (weight over 7 500, 410 points of 689 thousand: 330-410 ms /// -> 9-11 ms). Asserted on the SQL of the grouping; every answer must not change. /// [Fact] public async Task OpenRange_ProbedInAggregateGroupingAndWindow() { await TestDataFactory.SeedEmployees(Redb, 40); var restore = Redb.Configuration.EnablePvtPrefilter; try { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); IRedbQueryable Q() => Redb.Query().Where(e => e.Salary > 70000m && e.Age >= 30); (await Q().GroupBy(x => x.Department) .ToSqlStringAsync(g => new { g.Key, Count = Agg.Count(g) })) .Should().Contain("pvt_narrow", "the open range is probed"); async Task Answers() { var agg = await Q().AggregateAsync(x => new { Sum = Agg.Sum(x.Props.Salary), Count = Agg.Count() }); var groups = (await Q().GroupBy(x => x.Department) .SelectAsync(g => new { g.Key, Count = Agg.Count(g), Sum = Agg.Sum(g, x => x.Salary) })) .OrderBy(g => g.Key).ToList(); var ranked = (await Q().Take(20) .WithWindow(w => w.PartitionBy(x => x.Department).OrderByDesc(x => x.Salary)) .SelectAsync(x => new { x.Props.Salary, Rank = Win.RowNumber() })) .Select(x => x.Salary).OrderByDescending(s => s).ToList(); return System.Text.Json.JsonSerializer.Serialize(new { agg, groups, ranked }); } var on = await Answers(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = await Answers(); on.Should().Be(off, "the probe changes the plan, not the answer"); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// PostgreSQL only: a page sorted by a Props field and then by others (ThenBy) is led by the first /// field, and the walk reads on through the run of the value it stops at (pvt_bound); a run of equal /// first keys cut by the walk would come out in the wrong order of the rest. Pages of 689 thousand /// points 548-592 ms -> 10-11 ms. Compared by the sequence of both keys. /// [Fact] public async Task LeadingForm_ThenBy_SameKeysAsAggregateForm() { await TestDataFactory.SeedEmployees(Redb, 40); var restore = Redb.Configuration.EnablePvtPrefilter; try { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); IRedbQueryable Page(int skip) => Redb.Query() .Where(e => e.Salary > 0m && e.Age >= 20) .OrderByDescending(e => e.Salary).ThenBy(e => e.Age).ThenBy(e => e.LastName) .Skip(skip).Take(10); var sql = await Page(0).ToSqlStringAsync(); sql.Should().Contain("-- PVT leading form:"); sql.Should().Contain("pvt_bound", "with ThenBy the walk must know where it stops"); foreach (var skip in new[] { 0, 5 }) { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var on = (await Page(skip).ToListAsync()).Select(r => (r.Props.Salary, r.Props.Age, r.Props.LastName)).ToList(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = (await Page(skip).ToListAsync()).Select(r => (r.Props.Salary, r.Props.Age, r.Props.LastName)).ToList(); on.Should().Equal(off, $"the leading form changes the plan, not the order (Skip {skip})"); } } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// PostgreSQL only: with ThenBy the walk of the leading form reads on to the end of the run of equal /// sort values it stops in (pvt_bound, pvt_span). Take 10 walks 1 000 entries: 5 objects at the top /// value, then a run of 1 200 equal values whose smallest titles sit past the first thousand entries. /// A run longer than twice the walk (2 100 objects) leaves the page to the streams. Both pages are /// compared with the prefilter off by the sequence of both keys. /// [Fact] public async Task LeadingForm_ThenBy_RunOfEqualValuesAtTheBound() { const long top = 9_000_100, run = 9_000_090, longRun = 9_000_080; var objects = new List>(); void Add(long value, int count) { // Titles fall as the objects are created, so the first titles of a run are its last entries. for (var i = 0; i < count; i++) objects.Add(new RedbObject { name = $"run-{value}-{i}", Props = new SimpleProps { Title = $"t{value}-{count - i:D5}", OptionalNumber = value } }); } Add(top, 5); Add(run, 1200); Add(longRun, 2100); await Redb.SaveAsync(objects); var restore = Redb.Configuration.EnablePvtPrefilter; try { IRedbQueryable Run() => Redb.Query() .Where(p => p.OptionalNumber >= run) .OrderByDescending(p => p.OptionalNumber).ThenBy(p => p.Title) .Take(10); IRedbQueryable LongRun() => Redb.Query() .Where(p => p.OptionalNumber >= longRun) .OrderBy(p => p.OptionalNumber).ThenBy(p => p.Title) .Take(10); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var sql = await Run().ToSqlStringAsync(); sql.Should().Contain("-- PVT leading form:"); sql.Should().Contain("pvt_span", "with ThenBy the walk reads the run it stops in to the end"); foreach (var (name, page) in new[] { ("run", (Func>)Run), ("long run", LongRun) }) { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var on = (await page().ToListAsync()).Select(r => (r.Props.OptionalNumber, r.Props.Title)).ToList(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = (await page().ToListAsync()).Select(r => (r.Props.OptionalNumber, r.Props.Title)).ToList(); on.Should().HaveCount(10); on.Should().Equal(off, $"the leading form changes the plan, not the order ({name})"); } } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// PostgreSQL only: under a filter on the object's own columns (WhereRedb) a text field is read by a probe per /// object (LATERAL), not by a hash join over every row of the field in the scheme; a number field keeps the plain /// join, its value is in the index. A window of 2 843 objects of 50 000 with 128 MB of shared buffers took /// 1.4-5 s for a grouping or a null check by a text field. Asserted on the SQL; the answers must not change. /// [Fact] public async Task WhereRedb_TextFieldReadPerObject_SameAnswers() { await TestDataFactory.SeedEmployees(Redb, 40); var restore = Redb.Configuration.EnablePvtPrefilter; try { var from = DateTime.UtcNow.AddDays(-1); IRedbQueryable Window() => Redb.Query().WhereRedb(o => o.DateCreate >= from); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var sql = await Window().Where(e => e.EmployeeCode == null).Take(10).ToSqlStringAsync(); sql.Should().Contain("LEFT JOIN LATERAL (SELECT f._string", "the text field is read per object of the window"); (await Window().Where(e => e.Age > 30).Take(10).ToSqlStringAsync()) .Should().NotContain("LATERAL", "a number field is in the index of values and keeps the plain join"); async Task<(int Nulls, List<(string Key, int Count)> Groups)> AnswersAsync() => ( await Window().Where(e => e.EmployeeCode == null).CountAsync(), (await Window().GroupBy(e => e.Department).SelectAsync(g => new { Key = g.Key, Count = Agg.Count(g) })) .Select(g => (g.Key, g.Count)).OrderBy(g => g.Key).ToList()); var on = await AnswersAsync(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = await AnswersAsync(); on.Nulls.Should().Be(off.Nulls); on.Nulls.Should().BeGreaterThan(0, "the seed leaves every third employee without a code"); on.Groups.Should().Equal(off.Groups); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// PostgreSQL only: an OR of narrow branches that the row prefilter cannot take (a sort, a projection or an aggregate /// over another field, a leaf next to the OR) is probed: its branches are read from the index of values up to the cap /// and seed the streams (a sort by another field over 100 000 objects: 224 ms -> 13 ms). The pure OR keeps the row /// prefilter; an OR with a wide branch and an OR under NOT are not narrowed. Every shape, pages with Skip included, /// must answer as with the prefilter off. /// [Fact] public async Task NarrowOr_ProbedWhereTheRowPrefilterCannot_SameAnswers() { await TestDataFactory.SeedEmployees(Redb, 40); var from = DateTime.UtcNow.AddDays(-1); var restore = Redb.Configuration.EnablePvtPrefilter; try { IRedbQueryable Or() => Redb.Query().Where(e => e.Department == "Engineering" || e.Position == "Developer"); const string orProbe = "-- PVT probe: an OR of narrow branches"; Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); (await Or().OrderBy(e => e.Salary).Skip(3).Take(5).ToSqlStringAsync()) .Should().Contain(orProbe, "a sort by another field leaves the OR to the streams"); (await Redb.Query().Where(e => e.LastName == "Last005" && (e.Department == "Engineering" || e.Position == "Developer")) .Take(5).ToSqlStringAsync()) .Should().Contain(orProbe, "next to a leaf the probe decides which of the two drives"); var pure = await Or().ToSqlStringAsync(); pure.Should().Contain("-- PVT prefilter: Row form").And.NotContain(orProbe, "the pure OR keeps the row prefilter"); (await Or().GroupBy(e => e.Position).ToSqlStringAsync(g => new { g.Key, Count = Agg.Count(g) })) .Should().Contain("pvt_narrow", "a grouping over the OR is probed"); (await Redb.Query().Where(e => e.Department == "Engineering" || e.Salary > 60000m).OrderBy(e => e.Age).Take(5).ToSqlStringAsync()) .Should().NotContain(orProbe, "a wide branch leaves nothing to narrow"); (await Redb.Query().Where(e => !(e.Department == "Engineering" || e.Position == "Developer")).OrderBy(e => e.Age).Take(5).ToSqlStringAsync()) .Should().NotContain(orProbe, "an OR under NOT does not bound the objects"); static string Ids(IEnumerable rows) => string.Join(",", rows.Select(r => r.Id)); async Task AnswersAsync() { var parts = new List { "sort other: " + Ids(await Or().OrderBy(e => e.Salary).ThenByRedb(o => o.Id).Skip(3).Take(5).ToListAsync()), // Other tests seed the same names into this database: the id settles ties. "sort own: " + Ids(await Or().OrderBy(e => e.Department).ThenBy(e => e.LastName).ThenByRedb(o => o.Id).Skip(2).Take(5).ToListAsync()), "sort id: " + Ids(await Or().OrderByRedb(o => o.Id).Skip(2).Take(5).ToListAsync()), "leading: " + Ids(await Redb.Query().Where(e => (e.Department == "Engineering" || e.Position == "Developer") && e.Salary > 0m) .OrderByDescending(e => e.Salary).ThenBy(e => e.Age).ThenByRedb(o => o.Id).Skip(1).Take(5).ToListAsync()), "projection: " + string.Join(",", (await Or().OrderBy(e => e.Salary).ThenByRedb(o => o.Id).Take(5) .Select(x => new { x.Props.LastName, x.Props.Salary }).ToListAsync()).Select(x => $"{x.LastName}:{x.Salary}")), $"count: {await Or().CountAsync()} any: {await Or().AnyAsync()}", $"leaf next to it: {await Redb.Query().Where(e => e.LastName == "Last005" && (e.Department == "Engineering" || e.Position == "Developer")).CountAsync()}", "range next to it: " + Ids(await Redb.Query().Where(e => (e.Department == "Engineering" || e.Position == "Developer") && e.Age > 30) .OrderBy(e => e.Salary).ThenByRedb(o => o.Id).Skip(1).Take(5).ToListAsync()), $"sum: {await Or().AggregateAsync(x => new { Sum = Agg.Sum(x.Props.Salary), Count = Agg.Count() })}", "groups: " + string.Join(",", (await Or().GroupBy(e => e.Position).SelectAsync(g => new { g.Key, Count = Agg.Count(g), Sum = Agg.Sum(g, x => x.Salary) })) .OrderBy(g => g.Key).Select(g => $"{g.Key}:{g.Count}:{g.Sum}")), "window: " + string.Join(",", (await Or().Take(10).WithWindow(w => w.PartitionBy(x => x.Department).OrderByDesc(x => x.Salary)) .SelectAsync(x => new { x.Props.Salary, Rank = Win.RowNumber() })).Select(x => x.Salary).OrderByDescending(s => s)), $"whereredb: {await Or().WhereRedb(o => o.DateCreate >= from).CountAsync()}", $"wide branch: {await Redb.Query().Where(e => e.Department == "Engineering" || e.Salary > 60000m).CountAsync()}", $"under not: {await Redb.Query().Where(e => !(e.Department == "Engineering" || e.Position == "Developer")).CountAsync()}", }; return string.Join("\n", parts); } var on = await AnswersAsync(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = await AnswersAsync(); on.Should().Be(off, "the probe of the OR changes the plan, not the answer"); on.Should().NotContain("count: 0 ", "the seed has engineers and developers"); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// PostgreSQL only: both sides of the cap of the OR probe (5 000 rows). Ten objects match the OR of a small tag, 5 100 /// the OR of a large one: the first is seeded from the probe, the second keeps the form it has without the probe. /// Pages with Skip, counts and a grouping must answer as with the prefilter off on both sides. /// [Fact] public async Task NarrowOr_BothSidesOfTheProbeCap_SameAnswers() { var tag = Guid.NewGuid().ToString("N")[..8]; var (small, large) = ($"or-small-{tag}", $"or-large-{tag}"); var objects = Enumerable.Range(0, 5110).Select(i => (IRedbObject)new RedbObject { name = $"or-cap-{tag}-{i}", Props = new SimpleProps { Title = i < 10 ? small : large, Price = 1000m - i % 997, Count = i % 7, IsActive = i % 2 == 0, Description = $"d-{tag}-{i}" } }).ToList(); await Redb.AddNewObjectsAsync(objects); var restore = Redb.Configuration.EnablePvtPrefilter; try { IRedbQueryable Or(string title) => Redb.Query().Where(p => p.Title == title || p.Description == $"d-{tag}-none"); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); foreach (var title in new[] { small, large }) (await Or(title).OrderBy(p => p.Price).Take(5).ToSqlStringAsync()) .Should().Contain("-- PVT probe: an OR of narrow branches", "the cap is checked when the query runs, the SQL holds both forms"); async Task AnswersAsync(string title) => string.Join("\n", string.Join(",", (await Or(title).OrderBy(p => p.Price).ThenByRedb(o => o.Id).Skip(4).Take(5).ToListAsync()).Select(r => r.Id)), string.Join(",", (await Or(title).OrderByDescending(p => p.Count).ThenBy(p => p.Price).ThenByRedb(o => o.Id).Skip(1).Take(3).ToListAsync()).Select(r => r.Id)), $"{await Or(title).CountAsync()}", string.Join(",", (await Or(title).GroupBy(p => p.IsActive).SelectAsync(g => new { g.Key, Count = Agg.Count(g), Sum = Agg.Sum(g, x => x.Price) })) .OrderBy(g => g.Key).Select(g => $"{g.Key}:{g.Count}:{g.Sum}"))); foreach (var title in new[] { small, large }) { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var on = await AnswersAsync(title); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = await AnswersAsync(title); on.Should().Be(off, $"the probe changes the plan, not the answer ({title})"); } (await Or(large).CountAsync()).Should().Be(5100, "the large tag is past the cap"); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// PostgreSQL only: under WhereRedb the text field of a narrow equality or IN of the top-level AND is joined plainly, /// not by the LATERAL probe per object, so its condition reaches the index of text values and PostgreSQL may start /// from the matching values (one department among 95 000 objects of a wide window: 166 ms -> 2.5 ms). The id /// conditions of the top-level AND are repeated on that join; one under OR or NOT is not. Another text field keeps /// the LATERAL read. Asserted on the SQL; every answer must equal the one with the prefilter off. /// [Fact] public async Task WhereRedb_NarrowTextLeafJoinedPlainly_IdBoundsCarried_SameAnswers() { var ids = (await TestDataFactory.SeedEmployees(Redb, 40)).OrderBy(i => i).ToList(); var (low, high) = (ids[5], ids[30]); var picked = new[] { ids[2], ids[3], ids[10], ids[11] }; var one = ids[2]; var from = DateTime.UtcNow.AddDays(-1); var restore = Redb.Configuration.EnablePvtPrefilter; try { IRedbQueryable Engineering() => Redb.Query().Where(e => e.Department == "Engineering"); var shapes = new (string Name, Func> Query, string[] Carried)[] { ("date window", () => Engineering().WhereRedb(o => o.DateCreate >= from), []), ("id range", () => Engineering().WhereRedb(o => o.Id > low), [">"]), ("id both ends", () => Engineering().WhereRedb(o => o.Id >= low && o.Id < high), [">=", "<"]), ("id both ends and a date", () => Engineering().WhereRedb(o => o.Id > low && o.DateCreate >= from && o.Id <= high), [">", "<="]), ("id equality", () => Engineering().WhereRedb(o => o.Id == one), ["="]), ("id in", () => Engineering().WhereInRedb(o => o.Id, picked), ["= ANY("]), ("id under or", () => Engineering().WhereRedb(o => o.Id > high || o.Id < low), []), ("id under not", () => Engineering().WhereRedb(o => !(o.Id > low && o.Id < high)), []), }; Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); foreach (var (name, query, carried) in shapes) { var sql = await query().Take(10).ToSqlStringAsync(); sql.Should().NotContain("LATERAL", $"the equality's own text field is joined plainly ({name})"); // The id conditions on the join, not the join itself (f0._id_object = o_src._id). var bounds = System.Text.RegularExpressions.Regex.Matches(sql, @"f\d+\._id_object (>=|<=|>|<|= ANY\(|=)(?! o_src\.)") .Select(m => m.Groups[1].Value).OrderBy(s => s, StringComparer.Ordinal).ToArray(); bounds.Should().Equal(carried.OrderBy(s => s, StringComparer.Ordinal), $"the id bounds carried over ({name})"); } // A text field that is not the chosen leaf keeps its LATERAL read; the equality's field does not. var mixed = await Engineering().Where(e => e.LastName != "nobody").WhereRedb(o => o.Id > low).Take(10).ToSqlStringAsync(); System.Text.RegularExpressions.Regex.Matches(mixed, "LEFT JOIN LATERAL").Count .Should().Be(1, "LastName is read per object, Department is joined plainly"); async Task AnswersAsync() { var parts = new List(); foreach (var (name, query, _) in shapes) { var count = await query().CountAsync(); var page = (await query().OrderByRedb(o => o.Id).Take(5).ToListAsync()).Select(r => r.id); var any = await query().AnyAsync(); parts.Add($"{name}: {count} {any} [{string.Join(",", page)}]"); } parts.Add($"mixed: {await Engineering().Where(e => e.LastName != "nobody").WhereRedb(o => o.Id > low).CountAsync()}"); return string.Join("; ", parts); } var on = await AnswersAsync(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = await AnswersAsync(); on.Should().Be(off, "the plain join and the carried bounds change the plan, not the answer"); on.Should().Contain("id range: ").And.NotContain("id range: 0 ", "the seed has engineers past the bound"); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// PostgreSQL only: an aggregate without any condition reads each field from the index range of that field alone, the /// trash subtracted, and counts the objects in _objects (Sum of one field over 100 000 objects: 35 ms -> 18 ms). Its /// answers must equal the joined form's (prefilter off) for numbers of every column type, nulls, a nested-class field, /// base fields, an empty scheme and objects in the trash; an array field, a filter or WhereRedb keep the other forms. /// This also guards the invariant the form relies on: the values of a structure of the scheme belong to objects of the /// scheme or to the trash. /// [Fact] public async Task UnfilteredAggregate_ReadFromTheIndexOfValues_SameAnswers() { var ids = await TestDataFactory.SeedEmployees(Redb, 30); await Redb.SoftDeleteAsync(new[] { ids[1], ids[2], ids[7] }); await Redb.SyncSchemeAsync(); const string fromValues = "AND v._array_index IS NULL AND v._id_object NOT IN (SELECT t._id FROM _objects t WHERE t._id_scheme = -10))"; var restore = Redb.Configuration.EnablePvtPrefilter; try { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); IRedbQueryable All() => Redb.Query(); (await All().ToAggregateSqlStringAsync(x => new { S = Agg.Sum(x.Props.Salary), C = Agg.Count() })) .Should().Contain(fromValues, "no condition: the field is read from its index range"); (await All().Where(e => e.Age > 0).ToAggregateSqlStringAsync(x => new { S = Agg.Sum(x.Props.Salary) })) .Should().NotContain(fromValues, "a filter keeps the streams form"); (await All().WhereRedb(o => o.Id > 0).ToAggregateSqlStringAsync(x => new { S = Agg.Sum(x.Props.Salary) })) .Should().NotContain(fromValues, "WhereRedb keeps the streams form"); (await All().ToAggregateSqlStringAsync(x => new { S = Agg.Sum(x.Props.SkillLevels!) })) .Should().NotContain(fromValues, "an array is aggregated over its element rows elsewhere"); async Task AnswersAsync() => System.Text.Json.JsonSerializer.Serialize(new object[] { await All().AggregateAsync(x => new { Sum = Agg.Sum(x.Props.Salary), Avg = Agg.Average(x.Props.Salary), MinAge = Agg.Min(x.Props.Age), MaxAge = Agg.Max(x.Props.Age), SumAge = Agg.Sum(x.Props.Age), AvgAge = Agg.Average(x.Props.Age), Count = Agg.Count() }), // Rating is a double, null on every fourth employee. await All().AggregateAsync(x => new { Sum = Agg.Sum(x.Props.Rating), Min = Agg.Min(x.Props.Rating), Max = Agg.Max(x.Props.Rating), Count = Agg.Count() }), await All().AggregateAsync(x => new { Floors = Agg.Sum(x.Props.HomeAddress!.Building!.Floor), Top = Agg.Max(x.Props.HomeAddress!.Building!.Floor) }), await All().AggregateAsync(x => new { FirstId = Agg.Min(x.Id), LastId = Agg.Max(x.Id), Count = Agg.Count(), Sum = Agg.Sum(x.Props.Salary) }), await All().AggregateAsync(x => new { Skills = Agg.Sum(x.Props.SkillLevels!) }), await Redb.Query().AggregateAsync(x => new { Sum = Agg.Sum(x.Props.Number), Min = Agg.Min(x.Props.Amount), Max = Agg.Max(x.Props.Ratio), Count = Agg.Count() }), await All().CountAsync(), }); var on = await AnswersAsync(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = await AnswersAsync(); on.Should().Be(off, "reading the index of values changes the plan, not the answer"); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); (await All().AggregateAsync(x => new { Count = Agg.Count() })).Count .Should().Be(await All().CountAsync(), "COUNT(*) counts the live objects, not the rows of a field"); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// PostgreSQL only: AllAsync over one text field without any other condition first looks for a counterexample among the /// first 1 000 objects of the scheme, then compares the objects of the scheme with the values of the field that satisfy /// the predicate (165 ms -> 35 ms over 100 000 objects when All holds). 1 100 objects of a scheme of their own put the /// counterexamples past the probe, so the counts decide: a different value at the end, an object without the value, the /// same object moved to the trash; a pattern; All after Where and WhereRedb and over a number field keep their forms. /// Every answer must equal the one with the prefilter off. /// [Fact] public async Task AllOfATextField_ProbeThenCounts_SameAnswers() { var objects = Enumerable.Range(0, 1100).Select(i => (IRedbObject)new RedbObject { name = $"all-text-{i}", // The last object holds another name; the one before it has no note. Props = new AllTextProbeProps { Name = i == 1099 ? "b" : "a", Note = i == 1098 ? null : "n" } }).ToList(); var ids = await Redb.AddNewObjectsAsync(objects); var restore = Redb.Configuration.EnablePvtPrefilter; try { IRedbQueryable Q() => Redb.Query(); async Task AnswersAsync() => string.Join(",", await Q().AllAsync(p => p.Name == "a"), await Q().AllAsync(p => p.Name != "zzz"), await Q().AllAsync(p => p.Name.StartsWith("a")), await Q().AllAsync(p => p.Note != null), await Q().AllAsync(p => p.Note == "n"), await Q().Where(p => p.Note == "n").AllAsync(p => p.Name == "a"), await Q().WhereRedb(o => o.Id < ids[1099]).AllAsync(p => p.Name == "a")); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var on = await AnswersAsync(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = await AnswersAsync(); on.Should().Be(off, "the probe and the counts change the plan, not the answer"); on.Should().Be("False,True,False,False,False,False,True", "one late other name, one object without a note; Where keeps the object with another name"); // The objects past the probe moved to the trash: their values stay until the purge and must not count. await Redb.SoftDeleteAsync(new[] { ids[1098], ids[1099] }); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var trashedOn = await AnswersAsync(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var trashedOff = await AnswersAsync(); trashedOn.Should().Be(trashedOff, "the trash is subtracted from the values counted"); trashedOn.Should().Be("True,True,True,True,True,True,True", "the objects left all hold the name and the note"); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// PostgreSQL only: a grouping, an aggregate or a window driven off a narrow leaf reads each text field by its own row per /// object (LATERAL), not through the index by object that holds every row of the object (the Pachot grouping by the nested /// lab name, 12 575 objects with 11 fields each: 86 ms -> 53 ms). A text field the filter narrows keeps its plain join, /// so its condition reaches the index of text values. Asserted on the SQL; every answer must equal the one with the /// prefilter off, for a wide set, a narrow one and a narrow title next to a wide count. /// [Fact] public async Task TextReadAfterANarrowLeaf_ByItsOwnRow_SameAnswers() { var tag = Guid.NewGuid().ToString("N")[..8]; var objects = Enumerable.Range(0, 610).Select(i => (IRedbObject)new RedbObject { name = $"text-read-{tag}-{i}", // 600 objects with Count 777 011 and Price 41; 10 with Count 777 012 and Price 42. The description groups them // into seven, one of them without a value. Props = new SimpleProps { Title = $"t-{tag}-{i}", Count = i < 600 ? 777_011 : 777_012, Price = i < 600 ? 41m : 42m, Description = i % 7 == 0 ? null : $"d-{tag}-{i % 7}", IsActive = i % 2 == 0 } }).ToList(); await Redb.AddNewObjectsAsync(objects); var restore = Redb.Configuration.EnablePvtPrefilter; try { IRedbQueryable Wide() => Redb.Query().Where(p => p.Count == 777_011 && p.Price == 41m); IRedbQueryable Narrow() => Redb.Query().Where(p => p.Count == 777_012 && p.Price == 42m); var title = $"t-{tag}-17"; IRedbQueryable Tie() => Redb.Query().Where(p => p.Count == 777_011 && p.Title == title); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); (await Wide().GroupBy(p => p.Description).ToSqlStringAsync(g => new { g.Key, C = Agg.Count(g) })) .Should().Contain("LEFT JOIN LATERAL (SELECT f._string", "the description is read by its own row per object"); var tie = await Tie().GroupBy(p => p.Description).ToSqlStringAsync(g => new { g.Key, C = Agg.Count(g) }); System.Text.RegularExpressions.Regex.Matches(tie, "LEFT JOIN LATERAL").Count .Should().Be(1, "the title the filter narrows keeps its plain join, the description goes per object"); async Task AnswersAsync(Func> q) => string.Join("|", string.Join(",", (await q().GroupBy(p => p.Description).SelectAsync(g => new { g.Key, C = Agg.Count(g), S = Agg.Sum(g, x => x.Price) })) .Select(g => $"{g.Key}:{g.C}:{g.S}").OrderBy(s => s, StringComparer.Ordinal)), string.Join(",", (await q().GroupBy(p => p.IsActive).SelectAsync(g => new { g.Key, C = Agg.Count(g), M = Agg.Max(g, x => x.Description) })) .Select(g => $"{g.Key}:{g.C}:{g.M}").OrderBy(s => s, StringComparer.Ordinal)), $"{await q().AggregateAsync(x => new { S = Agg.Sum(x.Props.Price), C = Agg.Count() })}"); foreach (var (name, q) in new[] { ("wide", (Func>)Wide), ("narrow", Narrow), ("tie", Tie) }) { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var on = await AnswersAsync(q); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = await AnswersAsync(q); on.Should().Be(off, $"reading the text by its own row changes the plan, not the answer ({name})"); } } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// PostgreSQL only: the OFFSET 0 fence of the streams form stays for a wide filter and is dropped /// when the top-level AND holds a narrow leaf. With the fence such a leaf was checked above the /// streams after every object of the scheme had been joined: 2.4 s for one order number among /// 689 thousand points, 31 ms without it. Asserted on the SQL, and the answer must not change. /// [Fact] public async Task Streams_NarrowLeafDropsTheFence_WideFilterKeepsIt() { await TestDataFactory.SeedEmployees(Redb, 40); var restore = Redb.Configuration.EnablePvtPrefilter; try { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); IRedbQueryable Narrow() => Redb.Query() .Where(e => e.Department == "Engineering" && e.Age > 30) .OrderByRedb(o => o.Id).Take(100); IRedbQueryable Wide() => Redb.Query() .Where(e => e.Age > 30 && e.Department != "") .OrderByRedb(o => o.Id).Take(100); var narrow = await Narrow().ToSqlStringAsync(); narrow.Should().Contain("-- PVT form: Streams,"); narrow.Should().Contain("-- PVT streams fence: dropped", "an equality in the top-level AND is narrow by its shape"); narrow.Should().NotContain("OFFSET 0"); var wide = await Wide().ToSqlStringAsync(); wide.Should().Contain("-- PVT form: Streams,"); wide.Should().Contain("OFFSET 0", "an open range and an inequality are wide by their shape, the fence keeps merge joins"); // An OR of narrow branches cannot be pushed into one stream: it stays on the aggregate // form, where the row prefilter reads every branch from the index. var narrowOr = await Redb.Query() .Where(e => e.Department == "Engineering" || e.Position == "Developer" || e.LastName == "Smith") .ToSqlStringAsync(); narrowOr.Should().Contain("Streams not applied, the filter is an OR of narrow branches"); narrowOr.Should().Contain("-- PVT prefilter: Row form, 3 branch(es)"); var on = (await Narrow().ToListAsync()).Select(r => r.id).ToList(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = (await Narrow().ToListAsync()).Select(r => r.id).ToList(); on.Should().Equal(off, "dropping the fence changes the plan, not the answer"); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProPvtPrefilterListItemTests.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/PostgresPro/PostgresProPvtPrefilterListItemTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProPvtPrefilterListItemTests : PvtPrefilterListItemTestsBase { public PostgresProPvtPrefilterListItemTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProQueryOrderTests.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/PostgresPro/PostgresProQueryOrderTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProQueryOrderTests : QueryOrderTestsBase { public PostgresProQueryOrderTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProQueryPlannerBlockTests.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/PostgresPro/PostgresProQueryPlannerBlockTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProQueryPlannerBlockTests : QueryPlannerBlockTestsBase { public PostgresProQueryPlannerBlockTests(PostgresProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProReaderConnectionTests.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/PostgresPro/PostgresProReaderConnectionTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProReaderConnectionTests : ReaderConnectionTestsBase { protected override string SlowScalarSql => "SELECT count(*) FROM (SELECT pg_sleep(2)) AS s"; protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProRedundantArrayGuardTests.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/PostgresPro/PostgresProRedundantArrayGuardTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProRedundantArrayGuardTests : RedundantArrayGuardTestsBase { public PostgresProRedundantArrayGuardTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProReferenceListSaveTests.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/PostgresPro/PostgresProReferenceListSaveTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProReferenceListSaveTests : ReferenceListSaveTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProRegexQueryTests.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/PostgresPro/PostgresProRegexQueryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProRegexQueryTests : RegexQueryTestsBase { public PostgresProRegexQueryTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProRowMapperKindsTests.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/PostgresPro/PostgresProRowMapperKindsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProRowMapperKindsTests : RowMapperKindsTestsBase { public PostgresProRowMapperKindsTests(PostgresProFixture fixture) : base(fixture.Redb) { } protected override string KindsSql => @"SELECT 1::bigint AS _id, 7::bigint AS count, NULL::bigint AS maybe_long, 12.50::numeric AS amount, 1.5::float8 AS from_double, 0.25::float8 AS ratio, true AS flag, '6f1d0c3e-2b4a-4c8e-9a51-3d2f7e8b9c01'::uuid AS key_value, '2026-01-02 03:04:05+00'::timestamptz AS when_at, NULL::timestamp AS day, '\x0102'::bytea AS bytes, 'abc'::text AS ""NAME"", 'shown'::text AS display_name, '2026-03-04 00:00:00+00'::timestamptz AS first_seen, 'x'::text AS zzz"; protected override string EnumSql => "SELECT 2 AS kind"; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProSaveGraphHashTests.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/PostgresPro/PostgresProSaveGraphHashTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProSaveGraphHashTests : SaveGraphHashTestsBase { public PostgresProSaveGraphHashTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProSaveInterceptorTests.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/PostgresPro/PostgresProSaveInterceptorTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Models.Configuration; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProSaveInterceptorTests : SaveInterceptorTestsBase { protected override string ConnectionStringName => "Postgres"; protected override PropsSaveStrategy Strategy => PropsSaveStrategy.ChangeTracking; protected override void AddRedbServices(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options, string connectionString) => options.UsePostgres(connectionString); } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProSaveLockScopeTests.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/PostgresPro/PostgresProSaveLockScopeTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Pro.Extensions; using redb.Core.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProSaveLockScopeTests : SaveLockScopeTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProSchemaUpgradeTests.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/PostgresPro/PostgresProSchemaUpgradeTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; /// /// The same upgrade contract as the Free suite, but started through AddRedbPro: an existing /// 3.x database must gain the V4 columns on the first start of a Pro build too. It did not - the Pro /// service skipped the module deployment entirely ("Pro uses its own C# PVT generator"), which is /// true of the module's FUNCTIONS but not of the DDL that ships in the same bundle, so /// _values._unique and its siblings were never created and start-up died on the first read of /// a scheme. Owns its own database and role: this suite deliberately damages the schema. /// public class PostgresProSchemaUpgradeTests : redb.Tests.Integration.Tests.Postgres.PostgresSchemaUpgradeTests { public PostgresProSchemaUpgradeTests(SchemaUpgradeCleanup cleanup) : base(cleanup) { } protected override string DatabaseName => $"redb_upgrade_pro_{RunSuffix}"; protected override string FreshDatabaseName => $"redb_upgrade_pro_fresh_{RunSuffix}"; protected override string RestrictedRole => $"redb_noddl_pro_{RunSuffix}"; protected override void AddRedbServices(IServiceCollection services, Action configure) => services.AddRedbPro(configure); // Resolves to the Pro overload through this file's using of redb.Postgres.Pro.Extensions. protected override void UseProvider(RedbOptionsBuilder options, string connectionString) => options.UsePostgres(connectionString); } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProSchemeLoadValidationTests.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/PostgresPro/PostgresProSchemeLoadValidationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProSchemeLoadValidationTests : SchemeLoadValidationTestsBase { public PostgresProSchemeLoadValidationTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProSchemeNamingTests.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/PostgresPro/PostgresProSchemeNamingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProSchemeNamingTests : SchemeNamingTestsBase { public PostgresProSchemeNamingTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProSchemeRenameTests.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/PostgresPro/PostgresProSchemeRenameTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProSchemeRenameTests : SchemeRenameTestsBase { public PostgresProSchemeRenameTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProSqlPreviewTests.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/PostgresPro/PostgresProSqlPreviewTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProSqlPreviewTests : SqlPreviewTestsBase { public PostgresProSqlPreviewTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProSubSecondUpdateTests.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/PostgresPro/PostgresProSubSecondUpdateTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Models.Configuration; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProSubSecondUpdateTests : SubSecondUpdateTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override PropsSaveStrategy SaveStrategy => PropsSaveStrategy.ChangeTracking; protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProSyncLoadTests.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/PostgresPro/PostgresProSyncLoadTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProSyncLoadTests : ProSyncLoadTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProTagsFieldTests.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/PostgresPro/PostgresProTagsFieldTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProTagsFieldTests : TagsFieldTestsBase { public PostgresProTagsFieldTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProTemporalRoundTripTests.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/PostgresPro/PostgresProTemporalRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProTemporalRoundTripTests : TemporalRoundTripTestsBase { public PostgresProTemporalRoundTripTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProTimeTicksTests.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/PostgresPro/PostgresProTimeTicksTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProTimeTicksTests : TimeTicksTestsBase { public PostgresProTimeTicksTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProTrashPurgeTests.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/PostgresPro/PostgresProTrashPurgeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProTrashPurgeTests : TrashPurgeTestsBase { public PostgresProTrashPurgeTests(PostgresProFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProTrashedReferenceTargetTests.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/PostgresPro/PostgresProTrashedReferenceTargetTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; public class PostgresProTrashedReferenceTargetTests : TrashedReferenceTargetTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override bool ProPropsCache => true; protected override void UseProvider(RedbOptionsBuilder options) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetConnectionString("Postgres")!; options.UsePostgres(cs); } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProTreeAggregateTests.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/PostgresPro/PostgresProTreeAggregateTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProTreeAggregateTests : TreeAggregateTestsBase { public PostgresProTreeAggregateTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProTreeDistinctTests.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/PostgresPro/PostgresProTreeDistinctTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProTreeDistinctTests : TreeDistinctTestsBase { public PostgresProTreeDistinctTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProTreeLevelAnalyticsTests.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/PostgresPro/PostgresProTreeLevelAnalyticsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProTreeLevelAnalyticsTests : TreeLevelAnalyticsTestsBase { public PostgresProTreeLevelAnalyticsTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProTreeOrderAndPreviewTests.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/PostgresPro/PostgresProTreeOrderAndPreviewTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProTreeOrderAndPreviewTests : TreeOrderAndPreviewTestsBase { public PostgresProTreeOrderAndPreviewTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProTreeQueryShapesTests.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/PostgresPro/PostgresProTreeQueryShapesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProTreeQueryShapesTests : TreeQueryShapesTestsBase { public PostgresProTreeQueryShapesTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProTreeTests.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/PostgresPro/PostgresProTreeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProTreeTests : ProTreeTestsBase { public PostgresProTreeTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProTypeChangeTicksAndKeysTests.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/PostgresPro/PostgresProTypeChangeTicksAndKeysTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProTypeChangeTicksAndKeysTests : TypeChangeTicksAndKeysTestsBase { public PostgresProTypeChangeTicksAndKeysTests(PostgresProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } protected override string TextType => "TEXT"; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProUniqueKeyTests.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/PostgresPro/PostgresProUniqueKeyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProUniqueKeyTests : UniqueKeyTestsBase { public PostgresProUniqueKeyTests(PostgresProFixture fixture) : base(fixture.Redb) { } // The Pro fixture runs PropsSaveStrategy.ChangeTracking: an in-batch key swap may hit the // index mid-way - the documented boundary of §4.6 (typed error, never corruption). protected override bool KeySwapMustPass => false; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProUnregisteredTreeTargetTests.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/PostgresPro/PostgresProUnregisteredTreeTargetTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProUnregisteredTreeTargetTests : UnregisteredTreeTargetTestsBase { public PostgresProUnregisteredTreeTargetTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProUserConfigurationServiceTests.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/PostgresPro/PostgresProUserConfigurationServiceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProUserConfigurationServiceTests : UserConfigurationServiceTestsBase { public PostgresProUserConfigurationServiceTests(PostgresProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProValueOnlyObjectSaveTests.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/PostgresPro/PostgresProValueOnlyObjectSaveTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProValueOnlyObjectSaveTests : ValueOnlyObjectSaveTestsBase { public PostgresProValueOnlyObjectSaveTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProValueUniqueTests.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/PostgresPro/PostgresProValueUniqueTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProValueUniqueTests : ValueUniqueTestsBase { public PostgresProValueUniqueTests(PostgresProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProValuesFkIndexesTests.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/PostgresPro/PostgresProValuesFkIndexesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProValuesFkIndexesTests : ValuesFkIndexesTestsBase { public PostgresProValuesFkIndexesTests(PostgresProFixture fixture) : base(fixture.Redb) { } protected override async Task IndexExistsAsync(string indexName) => await Redb.Context.ExecuteScalarAsync( "SELECT COUNT(*) FROM pg_indexes WHERE indexname = '{0}'".Replace("{0}", indexName)) > 0; } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProWhereTests.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/PostgresPro/PostgresProWhereTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProWhereTests : WhereTestsBase { public PostgresProWhereTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProWideEqualityLeadsTests.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/PostgresPro/PostgresProWideEqualityLeadsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProWideEqualityLeadsTests : WideEqualityLeadsTestsBase { public PostgresProWideEqualityLeadsTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/PostgresPro/PostgresProWindowTests.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/PostgresPro/PostgresProWindowTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.PostgresPro; [Collection("PostgresPro")] public class PostgresProWindowTests : ProWindowTestsBase { public PostgresProWindowTests(PostgresProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteAbsentValuesTests.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/Sqlite/SqliteAbsentValuesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteAbsentValuesTests : AbsentValuesTestsBase { public SqliteAbsentValuesTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteAggregatePathTests.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/Sqlite/SqliteAggregatePathTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteAggregatePathTests : AggregatePathTestsBase { public SqliteAggregatePathTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteAggregatePreviewTests.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/Sqlite/SqliteAggregatePreviewTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteAggregatePreviewTests : FreeAggregatePreviewTestsBase { public SqliteAggregatePreviewTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteAggregationOverArrayTests.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/Sqlite/SqliteAggregationOverArrayTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteAggregationOverArrayTests : AggregationOverArrayTestsBase { public SqliteAggregationOverArrayTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteAggregationTests.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/Sqlite/SqliteAggregationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteAggregationTests : AggregationTestsBase { public SqliteAggregationTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteAmbientTransactionTests.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/Sqlite/SqliteAmbientTransactionTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Data; using redb.SQLite.Data; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteAmbientTransactionTests : AmbientTransactionTestsBase { public SqliteAmbientTransactionTests(SqliteFixture fixture) : base(fixture.ServiceProvider) { } protected override string CreateProbeTableSql => "CREATE TABLE IF NOT EXISTS ambient_tx_rows (tag TEXT NOT NULL)"; // No sleep function in SQLite: a recursive count that runs for seconds. protected override string SlowStatementSql => "WITH RECURSIVE c(x) AS (SELECT 1 UNION ALL SELECT x + 1 FROM c WHERE x < 20000000) SELECT count(*) FROM c"; // Case folding, not lazy references: the lazy flag needs the native extension, the case folding functions do not. protected override IRedbConnection CreateStandaloneConnection(IServiceProvider services, bool differentSessionSettings) => new SqliteRedbConnection(SqliteDataSource.Create( services.GetService()?.ConnectionString ?? ConnString("Sqlite"), unicodeCaseFolding: differentSessionSettings, lazyReferences: false)); } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteAnalyticsTelemetryTests.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/Sqlite/SqliteAnalyticsTelemetryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteAnalyticsTelemetryTests : AnalyticsTelemetryTestsBase { public SqliteAnalyticsTelemetryTests(SqliteFixture fixture) : base(fixture.Redb) { } protected override int CommandsPerCall => 2; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteAnyExistsTests.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/Sqlite/SqliteAnyExistsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteAnyExistsTests : FreeAnyExistsTestsBase { public SqliteAnyExistsTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteApplyTemporaryConfigurationTests.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/Sqlite/SqliteApplyTemporaryConfigurationTests.cs ---- #pragma warning disable CS0618 // implements or uses the deprecated object permissions and roles (RedbDeprecation) using redb.Core; using redb.Core.Extensions; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.Sqlite; /// /// ApplyTemporary (review CFG-1). The builder form built on the live configuration, so the change was applied /// before the snapshot meant to undo it was taken, and the scope "restored" the changed values. The configuration /// form applied and restored a hand-written list of fourteen settings out of thirty-six. Any provider would do; /// SQLite is the cheapest host. /// [Collection("Sqlite")] public class SqliteApplyTemporaryConfigurationTests { private readonly IRedbService _redb; public SqliteApplyTemporaryConfigurationTests(SqliteFixture fixture) => _redb = fixture.Redb; [Fact] public void TheBuilderForm_IsUndoneWhenTheScopeEnds() { var before = _redb.Configuration.DefaultCheckPermissionsOnDelete; before.Should().BeTrue("precondition: the default checks permissions on delete"); using (_redb.ApplyTemporary(b => b.WithoutPermissionChecks())) _redb.Configuration.DefaultCheckPermissionsOnDelete.Should().BeFalse(); _redb.Configuration.DefaultCheckPermissionsOnDelete.Should().Be(before); } [Fact] public void TheConfigurationForm_AppliesEveryBehaviourSetting_AndKeepsTheConnection() { var connection = _redb.Configuration.ConnectionString; var prefilter = _redb.Configuration.EnablePvtPrefilter; var temporary = _redb.Configuration.Clone(); temporary.EnablePvtPrefilter = !prefilter; temporary.ConnectionString = null; using (_redb.ApplyTemporary(temporary)) { _redb.Configuration.EnablePvtPrefilter.Should().Be(!prefilter, "a setting outside the old list of fourteen applies too"); _redb.Configuration.ConnectionString.Should().Be(connection, "a temporary scope changes behaviour, not the connection"); } _redb.Configuration.EnablePvtPrefilter.Should().Be(prefilter); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteArrayAnyTests.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/Sqlite/SqliteArrayAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteArrayAnyTests : ArrayAnyTestsBase { public SqliteArrayAnyTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteArrayGroupByDeepTests.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/Sqlite/SqliteArrayGroupByDeepTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteArrayGroupByDeepTests : ArrayGroupByDeepTestsBase { public SqliteArrayGroupByDeepTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteArrayGroupModuleGuardTests.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/Sqlite/SqliteArrayGroupModuleGuardTests.cs ---- using redb.Core; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Sqlite; /// /// A14: the free module's array grouping refuses, with a reason, what it cannot answer instead of reading it as a /// field with no rows: an unknown '$' token, '$element' on an array of classes, a field of an array of simple values, /// a field the elements do not have, a dictionary in the array path. The core refuses these forms before they reach /// SQL, so the function is called directly - the SQL is the public surface for callers that submit the JSON themselves. /// [Collection("Sqlite")] public class SqliteArrayGroupModuleGuardTests { private readonly IRedbService _redb; public SqliteArrayGroupModuleGuardTests(SqliteFixture fixture) => _redb = fixture.Redb; private async Task BuildAsync(string arrayPath, string groupByJson) { var scheme = await _redb.SyncSchemeAsync(); return await _redb.Context.ExecuteScalarAsync( "SELECT pvt_build_array_groupby_sql(" + scheme.Id + ", $1, NULL, $2, NULL)", new object[] { arrayPath, groupByJson }); } [Theory] [InlineData("Contacts", "[{\"field\":\"$foo\",\"alias\":\"x\"}]", "*\"$foo\" is not a field of the elements of \"Contacts\"*")] [InlineData("Contacts", "[{\"field\":\"$element\",\"alias\":\"x\"}]", "*\"$element\" names the element itself*")] [InlineData("Skills", "[{\"field\":\"Name\",\"alias\":\"x\"}]", "*simple values and have no field \"Name\"*")] [InlineData("Contacts.Metadata", "[{\"field\":\"Type\",\"alias\":\"x\"}]", "*\"Type\" is not a field of the elements of \"Contacts.Metadata\"*")] [InlineData("PhoneDirectory", "[{\"field\":\"$element\",\"alias\":\"x\"}]", "*dictionary*")] [InlineData("HomeAddress", "[{\"field\":\"City\",\"alias\":\"x\"}]", "*\"HomeAddress\" is not an array*")] public async Task WhatItCannotAnswer_IsRefusedWithAReason(string arrayPath, string groupByJson, string message) { var act = async () => await BuildAsync(arrayPath, groupByJson); (await act.Should().ThrowAsync()).Which.Message.Should().Match(message); } [Fact] public async Task AnInnerArrayAndTheElementOfASimpleArray_AreBuilt() { (await BuildAsync("Contacts.Metadata", "[{\"field\":\"Label\",\"alias\":\"Label\"}]")).Should().Contain("GROUP BY"); (await BuildAsync("Skills", "[{\"field\":\"$element\",\"alias\":\"Skill\"}]")).Should().Contain("GROUP BY"); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteArrayOfClassesAnyTests.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/Sqlite/SqliteArrayOfClassesAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteArrayOfClassesAnyTests : ArrayOfClassesAnyTestsBase { public SqliteArrayOfClassesAnyTests(SqliteFixture fixture) : base(fixture.Redb) { } protected override bool ReadsAnyOverClasses => false; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteArrayTests.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/Sqlite/SqliteArrayTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteArrayTests : ArrayTestsBase { public SqliteArrayTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteBareRedbObjectFieldTests.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/Sqlite/SqliteBareRedbObjectFieldTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteBareRedbObjectFieldTests : BareRedbObjectFieldTestsBase { public SqliteBareRedbObjectFieldTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteBugRegressionTests.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/Sqlite/SqliteBugRegressionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteBugRegressionTests : BugRegressionTestsBase { public SqliteBugRegressionTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteBulkCreateAtomicityTests.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/Sqlite/SqliteBulkCreateAtomicityTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteBulkCreateAtomicityTests : BulkCreateAtomicityTestsBase { public SqliteBulkCreateAtomicityTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteBytesRoundTripTests.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/Sqlite/SqliteBytesRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteBytesRoundTripTests : BytesRoundTripTestsBase { public SqliteBytesRoundTripTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteCacheBehaviorTests.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/Sqlite/SqliteCacheBehaviorTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteCacheBehaviorTests : CacheBehaviorTestsBase { public SqliteCacheBehaviorTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteCancellationTests.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/Sqlite/SqliteCancellationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteCancellationTests : CancellationTestsBase { public SqliteCancellationTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteCaptiveServiceReaderTests.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/Sqlite/SqliteCaptiveServiceReaderTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Extensions; using redb.Core.Models.Entities; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Sqlite; /// /// A service resolved from the root provider is captive: it lives as long as the process, and the ambient frame it /// enters is inherited by every flow (review after 4.0.0, finding 4; owner decision 2026-09-17: the concept stays - the /// captive service is the reader - but outside a transaction it lends lazy loads its scope factory, never its one /// connection). Before, every parallel lazy load of a shared instance ran on that one connection and the command gate /// refused the second. Inside its own transaction the connection is the transaction, and a lazy load stays on it. /// public class SqliteCaptiveServiceReaderTests { private const int Parallelism = 16; [Fact] public async Task ParallelLazyLoads_OnSharedInstances_ThroughACaptiveService_AllSucceed() { await using var provider = Build("props"); // From the container itself, on purpose: the captive service of a Program.cs. Resolved in this flow: the frame the // service enters is an AsyncLocal, and one set inside an awaited helper would not flow back here. var redb = provider.GetRequiredService(); await BootAsync(redb); var tag = NewTag(); var rootId = await SaveRootWithChildrenAsync(redb, tag); // Cached, so shared: its stubs read on the ambient reader of whoever touches them - the captive service. var root = (await redb.LoadAsync(rootId, depth: 1))!; var stubs = root.Props.Children!; stubs.Should().HaveCount(Parallelism); stubs.Should().OnlyContain(s => !s.IsPropsLoaded, "precondition: at depth 1 the references are stubs"); // Every flow touches its stub at the same moment: on one connection the command gate refuses all but the first. var labels = await AtOnce(stubs, stub => stub.Props!.Label!); labels.Should().BeEquivalentTo(Enumerable.Range(0, Parallelism).Select(i => $"child-{i}"), "a captive reader lends each lazy load a fresh scope of its container instead of its one connection"); } [Fact] public async Task ParallelListItemObjects_OfACachedList_ThroughACaptiveService_AllSucceed() { await using var provider = Build("items"); // From the container itself, on purpose: the captive service of a Program.cs. Resolved in this flow: the frame the // service enters is an AsyncLocal, and one set inside an awaited helper would not flow back here. var redb = provider.GetRequiredService(); await BootAsync(redb); var tag = NewTag(); var list = await redb.ListProvider.SaveListAsync(RedbList.Create($"captive-list-{tag}", "captive")); for (var i = 0; i < Parallelism; i++) { var objectId = await redb.SaveAsync(new RedbObject { name = $"captive-item-{tag}-{i}", Props = new LazyNodeProps { Label = $"item-{i}" } }); await redb.ListProvider.SaveListItemAsync(new RedbListItem { IdList = list.Id, Value = $"item-{i}", IdObject = objectId }); } // Cached, so shared; the objects behind the items load on first touch (PreloadListItemLinkedObjects = false). var items = await redb.ListProvider.GetListItemsAsync(list.Id); (await redb.ListProvider.GetListItemsAsync(list.Id)).Should().BeSameAs(items, "precondition: the list is served from the cache"); items.Should().HaveCount(Parallelism); var labels = await AtOnce(items, item => ((RedbObject)item.Object!).Props.Label!); labels.Should().BeEquivalentTo(Enumerable.Range(0, Parallelism).Select(i => $"item-{i}"), "a captive reader lends each list item load a fresh scope of its container instead of its one connection"); } [Fact] public async Task ALazyLoad_InsideTheCaptiveServicesTransaction_ReadsWhatTheTransactionWrote() { await using var provider = Build("tx"); // From the container itself, on purpose: the captive service of a Program.cs. Resolved in this flow: the frame the // service enters is an AsyncLocal, and one set inside an awaited helper would not flow back here. var redb = provider.GetRequiredService(); await BootAsync(redb); var tag = NewTag(); await using var transaction = await redb.Context.BeginTransactionAsync(); var childId = await redb.SaveAsync(new RedbObject { name = $"captive-tx-child-{tag}", Props = new LazyNodeProps { Label = "written-here" } }); var rootId = await redb.SaveAsync(new RedbObject { name = $"captive-tx-root-{tag}", Props = new LazyNodeProps { Label = "root", Next = new RedbObject { id = childId } } }); var root = (await redb.LoadAsync(rootId, depth: 1))!; root.Props.Next!.IsPropsLoaded.Should().BeFalse("precondition: at depth 1 the reference is a stub"); // Inside its transaction the captive service's connection is the transaction: the stub loads on it and sees the // uncommitted child. A fresh scope would read committed state, where the child does not exist yet. root.Props.Next.Props!.Label.Should().Be("written-here"); await transaction.RollbackAsync(); } [Fact] public async Task AnObjectLoadedThroughALentScope_LeavesStubsThatLoadAgain() { // No props cache: a cached instance is shared, and a shared instance never loads on an origin (only on a live // scope of the reader, owner decision 2026-09-15). This fact is about the origin of what a lent scope materializes. await using var provider = Build("chain", propsCache: false); // Resolved on another thread, like a test fixture or a host built elsewhere: the frame the service enters stays // there, and this flow has no live scope - a read here relies on the origin of what it touches. var redb = await Task.Run(() => provider.GetRequiredService()); await BootAsync(redb); var tag = NewTag(); var leafId = await redb.SaveAsync(new RedbObject { name = $"captive-leaf-{tag}", Props = new LazyNodeProps { Label = "leaf" } }); var midId = await redb.SaveAsync(new RedbObject { name = $"captive-mid-{tag}", Props = new LazyNodeProps { Label = "mid", Next = new RedbObject { id = leafId } } }); var rootId = await redb.SaveAsync(new RedbObject { name = $"captive-root-{tag}", Props = new LazyNodeProps { Label = "root", Next = new RedbObject { id = midId } } }); // No scope is current here: the stub loads on its origin, the captive service, which lends a scope. var root = (await redb.LoadAsync(rootId, depth: 1))!; var mid = root.Props.Next!.Props!; mid.Label.Should().Be("mid"); var leaf = mid.Next!; leaf.IsPropsLoaded.Should().BeFalse("precondition: the lent scope loads one object, its references stay stubs"); // The lent scope ended with the load. What it materialized belongs to the captive reader, not to that scope: // the stub under it names the captive service as its origin, and loads through a lent scope of its own. leaf.Props!.Label.Should().Be("leaf"); } private static ServiceProvider Build(string suffix, bool propsCache = true) { global::redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var cs = $"Data Source=redb_tests_captive_{suffix}.db"; SqliteTestSupport.DeleteDbFiles(cs); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => { options.UseSqlite(cs); options.Configure(c => { c.EnablePropsCache = propsCache; c.PreloadListItemLinkedObjects = false; c.CacheDomain = $"captive-{suffix}-{Guid.NewGuid():N}"; }); }); return services.BuildServiceProvider(); } private static async Task BootAsync(IRedbService redb) { await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); await redb.InitializeTypeRegistryAsync(); } private static async Task SaveRootWithChildrenAsync(IRedbService redb, string tag) { var children = new List>(); for (var i = 0; i < Parallelism; i++) { var childId = await redb.SaveAsync(new RedbObject { name = $"captive-child-{tag}-{i}", Props = new LazyNodeProps { Label = $"child-{i}" } }); children.Add(new RedbObject { id = childId }); } return await redb.SaveAsync(new RedbObject { name = $"captive-root-{tag}", Props = new LazyNodeProps { Label = "root", Children = children } }); } /// Runs on every element at the same moment, each on its own thread pool thread. private static async Task AtOnce(IEnumerable elements, Func read) { var start = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var reads = elements.Select(element => Task.Run(async () => { await start.Task; return read(element); })).ToArray(); start.SetResult(); return await Task.WhenAll(reads); } private static string NewTag() => Guid.NewGuid().ToString("N")[..8]; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteColdSchemeLinkedObjectTests.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/Sqlite/SqliteColdSchemeLinkedObjectTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteColdSchemeLinkedObjectTests : ColdSchemeLinkedObjectTestsBase { private const string Cs = "Data Source=redb_tests_cold_scheme_free.db"; private bool _prepared; protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); // A fresh file per test, shared by the writer and the reader host of that test. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteColdSchemeTreeFilterTests.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/Sqlite/SqliteColdSchemeTreeFilterTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteColdSchemeTreeFilterTests : ColdSchemeTreeFilterTestsBase { private const string Cs = "Data Source=redb_tests_cold_tree_free.db"; private bool _prepared; protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); // A fresh file per test, shared by the writer and the reader host of that test. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteCollectionFilterAnalyticsTests.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/Sqlite/SqliteCollectionFilterAnalyticsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteCollectionFilterAnalyticsTests : CollectionFilterAnalyticsTestsBase { public SqliteCollectionFilterAnalyticsTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteCollectionKindChangeTests.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/Sqlite/SqliteCollectionKindChangeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteCollectionKindChangeTests : CollectionKindChangeTestsBase { public SqliteCollectionKindChangeTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteComputedComparisonTests.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/Sqlite/SqliteComputedComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteComputedComparisonTests : ComputedComparisonTestsBase { public SqliteComputedComparisonTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteConcurrentDeleteListTests.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/Sqlite/SqliteConcurrentDeleteListTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteConcurrentDeleteListTests : ConcurrentDeleteListTestsBase { private const string Cs = "Data Source=redb_tests_cdel_free.db"; private bool _prepared; protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); // A fresh file per test, shared by every provider the test builds (its own and the writer's). Deleted per // provider, the file went away under the open connection of the first one wherever an open file can be // deleted (Linux), and the writer wrote into a new file the reader never saw. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteConcurrentWritersTests.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/Sqlite/SqliteConcurrentWritersTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteConcurrentWritersTests : ConcurrentWritersTestsBase { public SqliteConcurrentWritersTests(SqliteFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteConnectionLeaseTests.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/Sqlite/SqliteConnectionLeaseTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteConnectionLeaseTests : ConnectionLeaseTestsBase { public SqliteConnectionLeaseTests(SqliteFixture fixture) : base(fixture.ServiceProvider) { } protected override string CreateProbeTableSql => "CREATE TABLE IF NOT EXISTS connection_lease_rows (tag TEXT NOT NULL)"; protected override bool AmbientLeaseCarriesTransaction => true; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteConnectionTeardownTests.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/Sqlite/SqliteConnectionTeardownTests.cs ---- using redb.Core.Data; using redb.SQLite.Data; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteConnectionTeardownTests : ConnectionTeardownTestsBase { protected override IRedbConnection CreateConnection() => new SqliteRedbConnection(ConnString("Sqlite")); // SQLite has no sleep(): a recursive counter burns roughly the requested time // (~15-20M rows/s on the CI box; the pin only needs "still running at +300ms"). protected override string SleepSql(double seconds) => "WITH RECURSIVE c(x) AS (SELECT 1 UNION ALL SELECT x + 1 FROM c WHERE x < " + $"{(long)(seconds * 18_000_000)}) SELECT COUNT(*) FROM c"; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteConstantPredicateTests.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/Sqlite/SqliteConstantPredicateTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteConstantPredicateTests : ConstantPredicateTestsBase { public SqliteConstantPredicateTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteCrudTests.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/Sqlite/SqliteCrudTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteCrudTests : CrudTestsBase { public SqliteCrudTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteCtSaveInvariantsTests.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/Sqlite/SqliteCtSaveInvariantsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteCtSaveInvariantsTests : CtSaveInvariantsTestsBase { public SqliteCtSaveInvariantsTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteDataSourceOwnershipTests.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/Sqlite/SqliteDataSourceOwnershipTests.cs ---- using AwesomeAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Extensions; using redb.Core.Models.Configuration; using redb.SQLite.Data; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using Xunit; namespace redb.Tests.Integration.Tests.Sqlite; /// /// Ownership of the SQLite connection pool (the SQLite counterpart of the NpgsqlDataSource /// ownership fix): Microsoft.Data.Sqlite pools are static, keyed by connection string, and a /// pooled handle keeps the database FILE locked. The container that registered the /// owns that pool: when the container dies (test host teardown, /// a hot-reloaded module), the file must be deletable again. /// public class SqliteDataSourceOwnershipTests { [Fact] public async Task DisposingContainer_ReleasesTheDatabaseFile() { var dbPath = Path.Combine(Path.GetTempPath(), $"redb_ownership_{Guid.NewGuid():N}.db"); var cs = $"Data Source={dbPath}"; SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(o => o .UseSqlite(cs) .Configure(c => { c.PropsSaveStrategy = PropsSaveStrategy.DeleteInsert; c.EnablePropsCache = false; })); var sp = services.BuildServiceProvider(); try { var redb = sp.GetRequiredService(); try { await redb.InitializeAsync(ensureCreated: true); } catch { await redb.InitializeAsync(); } } finally { await sp.DisposeAsync(); } // The container is gone; nothing of this application is using the database any more. // The pooled connections belonged to that container's data source - a file still locked // here is an orphaned pool (the exact failure the test-suite worked around for years // with process exits and manual ClearAllPools). var act = () => { File.Delete(dbPath); var wal = dbPath + "-wal"; var shm = dbPath + "-shm"; if (File.Exists(wal)) File.Delete(wal); if (File.Exists(shm)) File.Delete(shm); }; act.Should().NotThrow("disposing the container must release every pooled connection of its data source"); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteDbInfoTests.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/Sqlite/SqliteDbInfoTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteDbInfoTests : DbInfoTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); const string cs = "Data Source=redb_tests_dbinfo_free.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } protected override string VersionMarker => "3."; protected override string SizeInBytesSql => "SELECT page_count * page_size FROM pragma_page_count(), pragma_page_size()"; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteDeleteBatchCountTests.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/Sqlite/SqliteDeleteBatchCountTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteDeleteBatchCountTests : DeleteBatchCountTestsBase { public SqliteDeleteBatchCountTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteDeleteSubtreeAtomicityTests.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/Sqlite/SqliteDeleteSubtreeAtomicityTests.cs ---- using AwesomeAssertions; using redb.Core; using redb.Core.Models.Entities; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; using Xunit; namespace redb.Tests.Integration.Tests.Sqlite; /// /// DeleteSubtree ran its two DELETEs as separate statements, so a live FK reference into the /// subtree made the second one fail **after** the first had committed: the objects survived with /// every value already gone (DataLoss p.2). Both statements now share one transaction, so the /// failure leaves the subtree untouched. /// [Collection("Sqlite")] public class SqliteDeleteSubtreeAtomicityTests(SqliteFixture fixture) { private async Task<(long RootId, long ChildId)> SeedReferencedSubtreeAsync() { var redb = fixture.Redb; await redb.SyncSchemeAsync(); var root = new RedbObject { name = "root", Props = new GraphNodeProps { Title = "root" } }; await redb.SaveAsync(root); var child = new RedbObject { name = "child", Props = new GraphNodeProps { Title = "child" } }; child.parent_id = root.id; await redb.SaveAsync(child); // A live object outside the subtree holds a reference to the child, so deleting the child // row would violate _values._Object. var referer = new RedbObject { name = "referer", Props = new GraphNodeProps { Title = "referer", Left = child } }; await redb.SaveAsync(referer); return (root.id, child.id); } [Fact] public async Task DeleteSubtree_WithLiveReferenceIntoSubtree_LeavesEverythingInPlace() { var redb = fixture.Redb; var (rootId, childId) = await SeedReferencedSubtreeAsync(); var root = await redb.LoadAsync(rootId); var act = async () => await redb.DeleteSubtreeAsync(root!); // The reference blocks the object delete, and because both statements now share a // transaction, the failure also undoes the values delete. await act.Should().ThrowAsync(); var reloadedChild = await redb.LoadAsync(childId); reloadedChild.Should().NotBeNull(); reloadedChild!.Props.Title.Should().Be("child", "the rolled-back delete must not strip the subtree of its values"); var reloadedRoot = await redb.LoadAsync(rootId); reloadedRoot.Should().NotBeNull("the root itself must still be there after the failed delete"); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteDeleteSubtreeCountTests.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/Sqlite/SqliteDeleteSubtreeCountTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteDeleteSubtreeCountTests : DeleteSubtreeCountTestsBase { private const string Cs = "Data Source=redb_tests_subc_free.db"; private bool _prepared; protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); // A fresh file per test, shared by every provider the test builds (its own and the writer's). Deleted per // provider, the file went away under the open connection of the first one wherever an open file can be // deleted (Linux), and the writer wrote into a new file the reader never saw. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteDiagnosticWarningTests.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/Sqlite/SqliteDiagnosticWarningTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Extensions; using redb.Core.Models.Configuration; using redb.Core.Models.Entities; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Sqlite; /// /// Diagnostics a production host relies on (props cache under load, 2026-09-15): the service created its props cache /// without a logger, and loads that rent a scope of their own went unnoticed when they ran one at a time. Such loads now /// happen only by explicit option (LazyLoadWithoutScope = FreshScope) and are warned by rate. Every test builds its own /// host and database file; services are resolved in helper methods, so no redb scope stays current for the test body. /// public class SqliteDiagnosticWarningTests { private static ServiceProvider Build(string dbFile, CapturingLoggerProvider capture, Action configure) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var cs = $"Data Source={dbFile}"; SqliteTestSupport.DeleteDbFiles(cs); var services = new ServiceCollection(); services.AddLogging(b => b.AddProvider(capture).SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => options.UseSqlite(cs).Configure(c => { c.CacheDomain = $"diagnostic-{dbFile}"; configure(c); })); return services.BuildServiceProvider(); } [Fact] public async Task PropsCache_GetsTheServiceLogger_WorkingSetAboveTheLimitIsWarned() { var capture = new CapturingLoggerProvider(); await using var sp = Build("redb_tests_diag_propscache.db", capture, c => { c.EnablePropsCache = true; c.PropsCacheMaxSize = 10; }); await using var scope = sp.CreateAsyncScope(); var redb = scope.ServiceProvider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); ((RedbServiceBase)redb).PropsCache.Instance.Should().NotBeNull("the props cache must be active, or this test proves nothing"); var ids = new List(); for (var i = 0; i < 40; i++) ids.Add(await redb.SaveAsync(new RedbObject { name = $"diag-{i}", Props = new SimpleProps { Title = $"diag-{i}" } })); foreach (var id in ids) (await redb.LoadAsync(id)).Should().NotBeNull(); capture.Warnings.Should().ContainSingle(m => m.Contains("PropsCacheMaxSize"), "the service hands its logger to the props cache it creates"); } private const int ItemCount = 220; /// Seeds a list of linked items and returns them from a scope that has ended. private static async Task> ItemsFromAScopeThatEndsAsync(ServiceProvider sp) { long listId; await using (var seed = sp.CreateAsyncScope()) { var redb = seed.ServiceProvider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); await redb.InitializeTypeRegistryAsync(); var targetId = await redb.SaveAsync(new RedbObject { name = "diag-target", Props = new SimpleProps { Title = "target" } }); var list = await redb.ListProvider.SaveListAsync(RedbList.Create("diag-fresh-scope", "diag-fresh-scope")); listId = list.Id; for (var i = 0; i < ItemCount; i++) await redb.ListProvider.SaveListItemAsync(new RedbListItem { IdList = list.Id, Value = $"item-{i}", IdObject = targetId }); } await using var reader = sp.CreateAsyncScope(); return await reader.ServiceProvider.GetRequiredService().ListProvider.GetListItemsAsync(listId); } [Fact] public async Task FreshScopeLoads_OneAtATime_AreWarnedByRate() { var capture = new CapturingLoggerProvider(); await using var sp = Build("redb_tests_diag_freshscope.db", capture, c => { c.PreloadListItemLinkedObjects = false; c.LazyLoadWithoutScope = LazyLoadWithoutScopeMode.FreshScope; }); var items = await ItemsFromAScopeThatEndsAsync(sp); items.Should().HaveCount(ItemCount); items.Should().OnlyContain(i => !i.IsObjectLoaded, "precondition: with the preload off every object is still lazy"); // No redb scope is live here: with the option each read opens a scope of its own. foreach (var item in items) item.Object.Should().NotBeNull(); capture.Warnings.Should().ContainSingle(m => m.Contains("Lazy loads in fresh scopes"), "a steady stream of fresh-scope loads drains the pool even when they run one at a time"); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteDictionaryInterfaceRefusalTests.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/Sqlite/SqliteDictionaryInterfaceRefusalTests.cs ---- using redb.Core; using redb.Core.Models.Entities; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Sqlite; /// /// DataLoss p.3: a dictionary-structure field whose runtime value is not a plain /// Dictionary<K,V> was skipped in silence, while DeleteInsert had already deleted the /// stored values - the field disappeared. It is refused now, before anything is written, and a plain /// dictionary in the same interface-typed property still round-trips. /// [Collection("Sqlite")] public class SqliteDictionaryInterfaceRefusalTests : IAsyncLifetime { private readonly IRedbService _redb; public SqliteDictionaryInterfaceRefusalTests(SqliteFixture fixture) => _redb = fixture.Redb; public async Task InitializeAsync() => await ResetAsync(); public async Task DisposeAsync() => await ResetAsync(); private async Task ResetAsync() { // Order matters: the scheme row is removed too, so the shared SQLite file does not carry an // extra probe scheme for the rest of the run (a scheme count assertion elsewhere would trip). await _redb.Context.ExecuteAsync( "DELETE FROM _objects WHERE _id_scheme IN " + "(SELECT _id FROM _schemes WHERE _name = 'DictionaryInterfaceProbe')"); await _redb.Context.ExecuteAsync( "DELETE FROM _structures WHERE _id_scheme IN " + "(SELECT _id FROM _schemes WHERE _name = 'DictionaryInterfaceProbe')"); await _redb.Context.ExecuteAsync("DELETE FROM _schemes WHERE _name = 'DictionaryInterfaceProbe'"); } [Fact] public async Task NonDictionaryImplementation_IsRefused_BeforeAnythingIsWritten() { await _redb.SyncSchemeAsync(); // SortedDictionary implements IDictionary<,>, so the property accepts it, but it is not the // Dictionary<,> instance the save path can enumerate into rows. var act = async () => await _redb.SaveAsync(new RedbObject { name = "iface-dict-refused", Props = new DictionaryInterfaceProbeProps { Label = "probe", Tags = new SortedDictionary { ["a"] = "1" }, }, }); var thrown = await act.Should().ThrowAsync(); thrown.Which.Message.Should().Contain("Tags", "the message names the field that cannot be stored"); var objects = await _redb.Context.ExecuteScalarAsync( "SELECT COUNT(*) FROM _objects WHERE _name = 'iface-dict-refused'"); objects.Should().Be(0, "the refusal lands while values are built, before any delete or insert"); } [Fact] public async Task DictionaryImplementation_RoundTrips() { await _redb.SyncSchemeAsync(); var id = await _redb.SaveAsync(new RedbObject { name = "iface-dict-ok", Props = new DictionaryInterfaceProbeProps { Label = "probe", Tags = new Dictionary { ["a"] = "1", ["b"] = "2" }, }, }); var loaded = await _redb.LoadAsync(id, depth: 1); loaded!.Props.Tags.Should().NotBeNull(); loaded.Props.Tags!["a"].Should().Be("1"); loaded.Props.Tags!["b"].Should().Be("2"); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteDictionaryOrderTests.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/Sqlite/SqliteDictionaryOrderTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteDictionaryOrderTests : DictionaryOrderTestsBase { public SqliteDictionaryOrderTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteDictionaryTests.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/Sqlite/SqliteDictionaryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteDictionaryTests : DictionaryTestsBase { public SqliteDictionaryTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteDisposedScopeGuardTests.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/Sqlite/SqliteDisposedScopeGuardTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteDisposedScopeGuardTests : DisposedScopeGuardTestsBase { public SqliteDisposedScopeGuardTests(SqliteFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteDomainRegistryConflictTests.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/Sqlite/SqliteDomainRegistryConflictTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Extensions; using redb.Core.Models.Configuration; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.Sqlite; /// /// Every service registers its database for the lazy loads that find no live scope, and the most recent /// registration wins - a host rebuilt in place (tests, hot reload) must take over from the disposed one. Two hosts of /// one database that disagree on therefore flip the policy /// with every service constructed; that was silent. /// public class SqliteDomainRegistryConflictTests { [Fact] public void TwoHostsOfOneDatabase_WithDifferentLazyLoadPolicies_AreReportedOnce() { const string cs = "Data Source=redb_tests_domain_conflict.db"; SqliteTestSupport.DeleteDbFiles(cs); var logs = new CapturingLoggerProvider(); using var refusing = Build(cs, LazyLoadWithoutScopeMode.Refuse, logs); using var fresh = Build(cs, LazyLoadWithoutScopeMode.FreshScope, logs); using var freshAgain = Build(cs, LazyLoadWithoutScopeMode.FreshScope, logs); Construct(refusing); Construct(fresh); Construct(freshAgain); Construct(refusing); logs.Warnings.Where(w => w.Contains("LazyLoadWithoutScope")).Should().ContainSingle( "the conflict is reported when first seen, not on every construction") .Which.Should().Contain("Refuse").And.Contain("FreshScope"); } private static void Construct(ServiceProvider host) { using var scope = host.CreateScope(); scope.ServiceProvider.GetRequiredService(); } private static ServiceProvider Build(string cs, LazyLoadWithoutScopeMode mode, CapturingLoggerProvider logs) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning).AddProvider(logs)); services.AddRedb(options => { options.UseSqlite(cs); options.Configure(c => c.LazyLoadWithoutScope = mode); }); return services.BuildServiceProvider(); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteEnumComparisonTests.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/Sqlite/SqliteEnumComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteEnumComparisonTests : EnumComparisonTestsBase { public SqliteEnumComparisonTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteEnumDictionaryKeyTests.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/Sqlite/SqliteEnumDictionaryKeyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteEnumDictionaryKeyTests : EnumDictionaryKeyTestsBase { public SqliteEnumDictionaryKeyTests(SqliteFixture fixture) : base(fixture.Redb) { } /// /// Free reads the dictionary from the JSON its module builds; the shared converter refuses the key with a JsonException /// that names the field's path but not the key. Free is not changed on develop (owner, 2026-11-27): this pins it. /// protected override void AssertUnreadableKey(Exception thrown) => thrown.ToString().Should().Contain("EntryByShade", "the path of the field is named"); } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteExportImportTests.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/Sqlite/SqliteExportImportTests.cs ---- using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Extensions; using redb.Core.Models.Entities; using redb.Export.Providers; using redb.Export.Services; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Sqlite; /// /// redb.Export between two SQLite files (review 2026-09-24): a round trip keeps the metadata the schema carries, /// and an import that cannot finish changes nothing - no half-filled database, no emptied one. Turning the foreign /// keys back on after the load checks nothing already there, so the import checks the loaded rows itself and refuses /// a file with references to rows it does not hold. /// public class SqliteExportImportTests { [Fact] public async Task ARoundTrip_KeepsSchemeAndFieldTags_AndTheUniqueScope() { var source = NewDatabase("src"); await using (var provider = Build(source)) { var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); } // Written straight into the catalog, the way an extension or [RedbTags] leaves them. Ids survive an import. var schemeId = await ScalarAsync(source, "SELECT MIN(_id) FROM _schemes WHERE _name LIKE '%SimpleProps%'"); var structureId = await ScalarAsync(source, $"SELECT MIN(_id) FROM _structures WHERE _id_scheme = {schemeId}"); schemeId.Should().NotBeNull("precondition: the scheme was synced"); structureId.Should().NotBeNull("precondition: the scheme has fields"); await ExecuteAsync(source, $"UPDATE _schemes SET _tags = 'scheme-tag' WHERE _id = {schemeId}"); await ExecuteAsync(source, $"UPDATE _structures SET _tags = 'field-tag', _unique_scope = 2 WHERE _id = {structureId}"); var file = await ExportAsync(source); var target = NewDatabase("dst"); await CreateEmptyAsync(target); await ImportAsync(target, file); (await ScalarAsync(target, $"SELECT _tags FROM _schemes WHERE _id = {schemeId}")).Should().Be("scheme-tag", "the scheme's marker travels with the export"); (await ScalarAsync(target, $"SELECT _tags || ':' || _unique_scope FROM _structures WHERE _id = {structureId}")).Should().Be("field-tag:2", "so do the field's marker and the scope of its unique key, or the meaning of the constraint changes"); } [Fact] public async Task AnImportOfACutFile_ChangesNothing_EvenWithCleaning() { var source = NewDatabase("src"); await using (var provider = Build(source)) { var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); for (var i = 0; i < 5; i++) await redb.SaveAsync(new RedbObject { name = $"exported-{i}", Props = new SimpleProps { Title = $"t{i}" } }); } var file = await ExportAsync(source); // The file loses its tail - the footer and the last records - as a copy that stopped half-way would. var lines = await File.ReadAllLinesAsync(file); lines.Should().HaveCountGreaterThan(4, "precondition: an export of a seeded database has records"); await File.WriteAllLinesAsync(file, lines.Take(lines.Length - 3)); var target = NewDatabase("dst"); await using (var provider = Build(target)) { var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); await redb.SaveAsync(new RedbObject { name = "already-here", Props = new SimpleProps { Title = "keep" } }); } var before = await ScalarAsync(target, "SELECT COUNT(*) FROM _objects"); var importing = async () => await ImportAsync(target, file); await importing.Should().ThrowAsync().WithMessage("*footer*"); (await ScalarAsync(target, "SELECT COUNT(*) FROM _objects")).Should().Be(before, "a failed import - cleaning included - leaves the database as it found it"); (await ScalarAsync(target, "SELECT COUNT(*) FROM _objects WHERE _name = 'already-here'")).Should().Be("1"); } [Fact] public async Task AnImportOfAFileWithAMissingParent_IsRefusedNamingTheKey_AndChangesNothing() { const long missing = 999_999_999; var source = NewDatabase("src"); long childId; await using (var provider = Build(source)) { var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); childId = await redb.SaveAsync(new RedbObject { name = "orphan", Props = new SimpleProps { Title = "o" } }); await redb.SaveAsync(new RedbObject { name = "sibling", Props = new SimpleProps { Title = "s" } }); } // The key would refuse the update; with the keys off it goes in, as it would from a broken file. await ExecuteAsync(source, $"PRAGMA foreign_keys = OFF; UPDATE _objects SET _id_parent = {missing} WHERE _id = {childId}"); var file = await ExportAsync(source); var target = await NewTargetWithOneObjectAsync(); var before = await ScalarAsync(target, "SELECT COUNT(*) FROM _objects"); var importing = async () => await ImportAsync(target, file); var refusal = await importing.Should().ThrowAsync(); refusal.Which.Message.Should() .Contain("_objects._id_parent: 1 row(s) of _objects point at a missing row of _objects (_id)") .And.Contain($"_id = {childId}, _id_parent = {missing}") .And.Contain("Nothing was imported; the database is unchanged."); (await ScalarAsync(target, "SELECT COUNT(*) FROM _objects")).Should().Be(before, "the refusal rolls back the whole import, the cleaning included"); (await ScalarAsync(target, "SELECT COUNT(*) FROM _objects WHERE _name = 'already-here'")).Should().Be("1"); } [Fact] public async Task AFileExportedWithSchemes_WhoseObjectPointsIntoASchemeLeftOut_IsRefused_NamingTheReference() { var source = NewDatabase("src"); long parentId, childId; await using (var provider = Build(source)) { var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); await redb.SyncSchemeAsync(); parentId = await redb.SaveAsync(new RedbObject { name = "parent-left-out", Props = new CityProps { Name = "c" } }); childId = await redb.SaveAsync(new RedbObject { name = "child-exported", parent_id = parentId, Props = new SimpleProps { Title = "t" } }); } var simpleScheme = long.Parse((await ScalarAsync(source, "SELECT MIN(_id) FROM _schemes WHERE _name LIKE '%SimpleProps%'"))!); var file = await ExportAsync(source, [simpleScheme]); var target = await NewTargetWithOneObjectAsync(); var importing = async () => await ImportAsync(target, file); var refusal = await importing.Should().ThrowAsync(); refusal.Which.Message.Should() .Contain("--schemes") .And.Contain("_objects._id_parent: 1 row(s) of _objects point at a missing row of _objects (_id)") .And.Contain($"_id = {childId}, _id_parent = {parentId}"); } [Fact] public async Task AWholeFile_WithAChildBeforeItsParent_StillImports() { var source = NewDatabase("src"); long childId, parentId; await using (var provider = Build(source)) { var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); // The child gets the lower id, so the export writes it before its parent. childId = await redb.SaveAsync(new RedbObject { name = "child", Props = new SimpleProps { Title = "c" } }); parentId = await redb.SaveAsync(new RedbObject { name = "parent", Props = new SimpleProps { Title = "p" } }); } await ExecuteAsync(source, $"UPDATE _objects SET _id_parent = {parentId} WHERE _id = {childId}"); var file = await ExportAsync(source); var target = await NewTargetWithOneObjectAsync(); await ImportAsync(target, file); (await ScalarAsync(target, $"SELECT _id_parent FROM _objects WHERE _id = {childId}")).Should().Be(parentId.ToString(), "a reference the file holds both ends of passes the check, whatever the order of the rows"); } private static async Task NewTargetWithOneObjectAsync() { var target = NewDatabase("dst"); await using var provider = Build(target); var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); await redb.SaveAsync(new RedbObject { name = "already-here", Props = new SimpleProps { Title = "keep" } }); return target; } private static string NewDatabase(string suffix) { global::redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var cs = $"Data Source=redb_tests_export_{suffix}_{Guid.NewGuid():N}.db"; SqliteTestSupport.DeleteDbFiles(cs); return cs; } private static ServiceProvider Build(string cs) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => { options.UseSqlite(cs); options.Configure(c => c.CacheDomain = $"export-{Guid.NewGuid():N}"); }); return services.BuildServiceProvider(); } private static async Task CreateEmptyAsync(string cs) { await using var provider = Build(cs); await provider.GetRequiredService().InitializeAsync(ensureCreated: true); } private static async Task ExportAsync(string cs, long[]? schemeIds = null) { var file = Path.Combine(Path.GetTempPath(), $"redb-export-{Guid.NewGuid():N}.redb"); await using var provider = ProviderFactory.Create("sqlite"); await provider.OpenAsync(cs); await new ExportService(provider, verbose: false, batchSize: 1000).ExportAsync(file, schemeIds, compress: false, dryRun: false); return file; } private static async Task ImportAsync(string cs, string file) { await using var provider = ProviderFactory.Create("sqlite"); await provider.OpenAsync(cs); await new ImportService(provider, verbose: false, batchSize: 1000).ImportAsync(file, clean: true, dryRun: false); } private static async Task ExecuteAsync(string cs, string sql) { await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = sql; await command.ExecuteNonQueryAsync(); } private static async Task ScalarAsync(string cs, string sql) { await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = sql; return (await command.ExecuteScalarAsync())?.ToString(); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteExportRenameHistoryTests.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/Sqlite/SqliteExportRenameHistoryTests.cs ---- using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; /// on SQLite, scratch files deleted afterwards. public class SqliteExportRenameHistoryTests : ExportRenameHistoryTestsBase, IAsyncLifetime { private readonly List _databases = []; private readonly List _files = []; protected override string ProviderName => "sqlite"; public Task InitializeAsync() => Task.CompletedTask; public Task DisposeAsync() { SqliteConnection.ClearAllPools(); foreach (var database in _databases) SqliteTestSupport.DeleteDbFiles(database); foreach (var file in _files) File.Delete(file); return Task.CompletedTask; } protected override Task NewDatabaseAsync(string suffix) { global::redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var cs = $"Data Source=redb_tests_export_ren_{suffix}_{Guid.NewGuid():N}.db"; SqliteTestSupport.DeleteDbFiles(cs); _databases.Add(cs); return Task.FromResult(cs); } protected override ServiceProvider Build(string cs) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => { options.UseSqlite(cs); options.Configure(c => c.CacheDomain = $"export-ren-{Guid.NewGuid():N}"); }); return services.BuildServiceProvider(); } protected override string NewFile() { var file = Path.Combine(Path.GetTempPath(), $"redb-export-ren-{Guid.NewGuid():N}.redb"); _files.Add(file); return file; } protected override async Task ScalarAsync(string cs, string sql) { await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = sql; return AsText(await command.ExecuteScalarAsync()); } protected override async Task ExecuteSqlAsync(string cs, string sql) { await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = sql; await command.ExecuteNonQueryAsync(); } protected override async Task> PairsAsync(string cs, string sql) { await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = sql; await using var reader = await command.ExecuteReaderAsync(); var rows = new List<(string?, string?)>(); while (await reader.ReadAsync()) rows.Add((AsText(reader.GetValue(0)), AsText(reader.GetValue(1)))); return rows; } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteExportSchemaGateTests.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/Sqlite/SqliteExportSchemaGateTests.cs ---- using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; /// /// on SQLite, scratch files deleted afterwards. SQLite loads over one /// connection, so the parallel case does not apply. /// public class SqliteExportSchemaGateTests : ExportSchemaGateTestsBase, IAsyncLifetime { private readonly List _databases = []; private readonly List _files = []; private static int SchemaVersion => global::redb.SQLite.RedbService.SchemaVersion; protected override string ProviderName => "sqlite"; protected override bool SupportsParallel => false; protected override string SchemesTableCountSql => "SELECT COUNT(*) FROM sqlite_master WHERE type = 'table' AND name = '_schemes'"; protected override string OutdatedRemedy => "Upgrade the file with `redb init --provider sqlite`"; protected override string SchemaVersionSql => "PRAGMA user_version"; public Task InitializeAsync() => Task.CompletedTask; public Task DisposeAsync() { SqliteConnection.ClearAllPools(); foreach (var database in _databases) SqliteTestSupport.DeleteDbFiles(database); foreach (var file in _files) File.Delete(file); return Task.CompletedTask; } protected override Task NewDatabaseAsync(string suffix) { global::redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var cs = $"Data Source=redb_tests_export_gate_{suffix}_{Guid.NewGuid():N}.db"; SqliteTestSupport.DeleteDbFiles(cs); _databases.Add(cs); return Task.FromResult(cs); } protected override ServiceProvider Build(string cs) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => { options.UseSqlite(cs); options.Configure(c => c.CacheDomain = $"export-gate-{Guid.NewGuid():N}"); }); return services.BuildServiceProvider(); } protected override string NewFile() { var file = Path.Combine(Path.GetTempPath(), $"redb-export-gate-{Guid.NewGuid():N}.redb"); _files.Add(file); return file; } protected override Task StageOlderAsync(string cs) => ExecuteAsync(cs, $""" ALTER TABLE _schemes DROP COLUMN _renamed_from; ALTER TABLE _structures DROP COLUMN _renamed_from; PRAGMA user_version = {SchemaVersion - 1}; """); protected override Task StageNewerAsync(string cs, bool servesThisBuild) { var minReader = servesThisBuild ? SchemaVersion : SchemaVersion + 1; return ExecuteAsync(cs, $""" DELETE FROM _schema_compat; INSERT INTO _schema_compat (_min_reader, _package) VALUES ({minReader}, '{(servesThisBuild ? "4.8.0" : "99.0.0")}'); PRAGMA user_version = {SchemaVersion + 1}; """); } protected override async Task ScalarAsync(string cs, string sql) { await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = sql; return Convert.ToString(await command.ExecuteScalarAsync()); } protected override async Task> ProviderStateAsync(string cs) { var lines = new List(); await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = "SELECT 'index ' || tbl_name || '.' || name FROM sqlite_master WHERE type = 'index' ORDER BY 1"; await using var reader = await command.ExecuteReaderAsync(); while (await reader.ReadAsync()) lines.Add(reader.GetString(0)); return lines; } protected override Task ExecuteSqlAsync(string cs, string sql) => ExecuteAsync(cs, sql); private static async Task ExecuteAsync(string cs, string sql) { await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = sql; await command.ExecuteNonQueryAsync(); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteFieldNamedLikeAFunctionTests.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/Sqlite/SqliteFieldNamedLikeAFunctionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteFieldNamedLikeAFunctionTests : FieldNamedLikeAFunctionTestsBase { public SqliteFieldNamedLikeAFunctionTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteFilterFieldPathTests.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/Sqlite/SqliteFilterFieldPathTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteFilterFieldPathTests : FilterFieldPathTestsBase { public SqliteFilterFieldPathTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteFlatExportTimeTicksTests.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/Sqlite/SqliteFlatExportTimeTicksTests.cs ---- using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Extensions; using redb.Core.Models.Contracts; using redb.Core.Models.Entities; using redb.Export.Flat; using redb.Export.Providers; using redb.SQLite.Data; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Sqlite; /// /// The flat export reads TimeSpan and TimeOnly from _values._Long (their Ticks) and writes the target's own time forms; /// it read them from _String before, where they no longer are. /// public class SqliteFlatExportTimeTicksTests : IDisposable { private readonly string _source = Path.Combine(Path.GetTempPath(), $"redb_flat_src_{Guid.NewGuid():N}.db"); private readonly string _target = Path.Combine(Path.GetTempPath(), $"redb_flat_dst_{Guid.NewGuid():N}.db"); [Fact] public async Task FlatExport_WritesTimeSpanAndTimeOnly_FromTheirTicks() { SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var span = TimeSpan.FromDays(3).Add(TimeSpan.FromHours(-5)).Add(TimeSpan.FromTicks(123)); var clock = new TimeOnly(21, 45, 7, 250); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => options.UseSqlite($"Data Source={_source}")); await using (var sp = services.BuildServiceProvider()) { var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); await redb.SaveAsync(new RedbObject { name = "flat", Props = new TimeTicksProps { Tag = "flat", Span = span, Clock = clock } }); } SqliteConnection.ClearAllPools(); await using (var source = ProviderFactory.Create("sqlite")) await using (var target = ProviderFactory.Create("sqlite")) { await source.OpenAsync($"Data Source={_source}"); await target.OpenAsync($"Data Source={_target}"); await new FlatExportService(source, target, verbose: false, batchSize: 100).ExportAsync([typeof(TimeTicksProps)]); } SqliteConnection.ClearAllPools(); await using var connection = new SqliteConnection($"Data Source={_target}"); await connection.OpenAsync(); string? table = null; await using (var tables = connection.CreateCommand()) { tables.CommandText = "SELECT name FROM sqlite_master WHERE type = 'table'"; await using var reader = await tables.ExecuteReaderAsync(); var names = new List(); while (await reader.ReadAsync()) names.Add(reader.GetString(0)); foreach (var name in names) { await using var columns = connection.CreateCommand(); columns.CommandText = $"SELECT COUNT(*) FROM pragma_table_info('{name.Replace("'", "''")}') WHERE name IN ('Span', 'Clock')"; if ((long)(await columns.ExecuteScalarAsync())! == 2) table = name; } } table.Should().NotBeNull("the export writes a table with the Span and Clock columns"); await using var select = connection.CreateCommand(); select.CommandText = $"SELECT \"Span\", \"Clock\" FROM \"{table}\""; await using var row = await select.ExecuteReaderAsync(); (await row.ReadAsync()).Should().BeTrue(); TimeSpan.Parse(row.GetString(0), System.Globalization.CultureInfo.InvariantCulture).Should().Be(span); TimeOnly.Parse(row.GetString(1), System.Globalization.CultureInfo.InvariantCulture).Should().Be(clock); } public void Dispose() { SqliteConnection.ClearAllPools(); foreach (var f in new[] { _source, _target }) foreach (var x in new[] { f, f + "-wal", f + "-shm" }) if (File.Exists(x)) File.Delete(x); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteFreeListItemJsonTests.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/Sqlite/SqliteFreeListItemJsonTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteFreeListItemJsonTests : FreeListItemJsonTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); // A fresh file per host. const string cs = "Data Source=redb_tests_listitem_json_free.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteGroupByHavingTests.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/Sqlite/SqliteGroupByHavingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteGroupByHavingTests : GroupByHavingTestsBase { public SqliteGroupByHavingTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteGroupBySelectShapesTests.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/Sqlite/SqliteGroupBySelectShapesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteGroupBySelectShapesTests : GroupBySelectShapesTestsBase { public SqliteGroupBySelectShapesTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteGroupByTests.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/Sqlite/SqliteGroupByTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteGroupByTests : GroupByTestsBase { public SqliteGroupByTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteHashStorageTests.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/Sqlite/SqliteHashStorageTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Data; using redb.Core.Extensions; using redb.Core.Models.Entities; using redb.Core.Pro.Extensions; using redb.SQLite.Data; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Sqlite; /// /// V4: the 128-bit hashes in SQLite — _objects._hash, _schemes._structure_hash, /// _users._hash — are stored as BLOB(16) in RFC 4122 byte order, not as 36-character /// TEXT (see ). Three things have to hold, on Free (native extension writes /// and reads the hash in its own statements) and on Pro (pure C#) alike: /// /// /// the byte order is the text order — one Guid, written from C#, reads back as the same Guid, /// and hex(_hash) in SQL spells the Guid's canonical text; /// a database created before V4, holding the hashes as TEXT, is converted on the next open, /// driven by opening it and nothing else; /// a query filtering by hash still finds the object — the uuid TEXT the filter carries is /// converted on the value side, in the extension for Free and in the SQL builder for Pro. /// /// /// /// Each test owns a temporary file and opens it as many times as it needs: the shared fixtures delete /// their database on every run and can model a new database only. /// /// public class SqliteHashStorageTests : IDisposable { private readonly string _dbPath = Path.Combine(Path.GetTempPath(), $"redb_hashblob_{Guid.NewGuid():N}.db"); private string ConnectionString => $"Data Source={_dbPath}"; private static ServiceProvider BuildServices(string connectionString, bool pro) { SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); if (pro) { var license = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build()["Redb:License"]; services.AddRedbPro(options => { redb.SQLite.Pro.Extensions.SqliteProOptionsExtensions.UseSqlite(options, connectionString); if (!string.IsNullOrWhiteSpace(license)) options.WithLicense(license); }); } else { services.AddRedb(options => redb.SQLite.Extensions.SqliteOptionsExtensions.UseSqlite(options, connectionString)); } return services.BuildServiceProvider(); } private static string CanonicalHex(Guid g) => g.ToString("N").ToUpperInvariant(); /// No database: the helper alone. The bytes are the text, left to right. [Fact] public void ByteOrder_IsTheTextOrder() { var g = Guid.Parse("00112233-4455-6677-8899-aabbccddeeff"); var blob = SqliteHash.ToBlob(g); Convert.ToHexString(blob).Should().Be("00112233445566778899AABBCCDDEEFF", "Guid.ToByteArray() would give 33221100-5544-7766-…; the stored form is the text order"); SqliteHash.FromBlob(blob).Should().Be(g); SqliteHash.FromDbValue(blob).Should().Be(g); SqliteHash.FromDbValue(g.ToString()).Should().Be(g, "a TEXT value (data guid, or a hash not yet converted) still reads"); SqliteHash.FromText("$1").Should().Be("unhex(replace($1,'-',''))"); } [Theory] [InlineData(false)] [InlineData(true)] public async Task NewDatabase_StoresHashesAsBlob_InTextOrder(bool pro) { await using var sp = BuildServices(ConnectionString, pro); var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); var obj = new RedbObject { name = "hash-blob", Props = new ProjectMetricsProps { ProjectId = 1, TasksTotal = 5, TasksCompleted = 2 } }; var id = await redb.SaveAsync(obj); var loaded = await redb.LoadAsync(id, depth: 1); loaded!.hash.Should().NotBeNull(); var ctx = sp.GetRequiredService(); (await ctx.ExecuteScalarAsync($"SELECT typeof(_hash) FROM _objects WHERE _id = {id}")) .Should().Be("blob"); (await ctx.ExecuteScalarAsync($"SELECT hex(_hash) FROM _objects WHERE _id = {id}")) .Should().Be(CanonicalHex(loaded.hash!.Value), "hex() of the stored bytes spells the Guid's text"); (await ctx.ExecuteScalarAsync($"SELECT typeof(_structure_hash) FROM _schemes WHERE _id = {loaded.scheme_id}")) .Should().Be("blob"); // The stored hash is the one the object computes for itself — the round trip is lossless. var live = loaded.ComputeHash(); loaded.hash.Should().Be(live); } [Theory] [InlineData(false)] [InlineData(true)] public async Task LegacyTextHashes_AreConvertedOnNextOpen(bool pro) { long id; long schemeId; Guid savedHash; // First open: create and save, then roll the storage back to what a pre-V4 build wrote — // the same value as 36-character lower-case TEXT. await using (var sp = BuildServices(ConnectionString, pro)) { var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); id = await redb.SaveAsync(new RedbObject { name = "legacy", Props = new ProjectMetricsProps { ProjectId = 2, TasksTotal = 8, TasksCompleted = 1 } }); var loaded = (await redb.LoadAsync(id, depth: 1))!; savedHash = loaded.hash!.Value; schemeId = loaded.scheme_id; var ctx = sp.GetRequiredService(); foreach (var (table, column) in new[] { ("_objects", "_hash"), ("_schemes", "_structure_hash"), ("_users", "_hash") }) { await ctx.ExecuteAsync( $"UPDATE {table} SET {column} = lower(substr(hex({column}),1,8)||'-'||substr(hex({column}),9,4)||'-'||" + $"substr(hex({column}),13,4)||'-'||substr(hex({column}),17,4)||'-'||substr(hex({column}),21,12)) " + $"WHERE typeof({column}) = 'blob'"); } // A pre-V4 file carries no schema stamp: PRAGMA user_version is 0 there. await ctx.ExecuteAsync("PRAGMA user_version = 0"); (await ctx.ExecuteScalarAsync($"SELECT typeof(_hash) FROM _objects WHERE _id = {id}")) .Should().Be("text", "the legacy state must be staged"); (await ctx.ExecuteScalarAsync($"SELECT _hash FROM _objects WHERE _id = {id}")) .Should().Be(savedHash.ToString(), "staged as the canonical text a pre-V4 build wrote"); } // Second open: the same file, a new service — the upgrade path. await using (var sp = BuildServices(ConnectionString, pro)) { var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); var ctx = sp.GetRequiredService(); (await ctx.ExecuteScalarAsync($"SELECT typeof(_hash) FROM _objects WHERE _id = {id}")) .Should().Be("blob", "opening an existing database must convert the hashes"); (await ctx.ExecuteScalarAsync($"SELECT hex(_hash) FROM _objects WHERE _id = {id}")) .Should().Be(CanonicalHex(savedHash), "the conversion keeps the value: same text, now as bytes"); (await ctx.ExecuteScalarAsync($"SELECT typeof(_structure_hash) FROM _schemes WHERE _id = {schemeId}")) .Should().Be("blob"); (await ctx.ExecuteScalarAsync("PRAGMA user_version")).Should().BeGreaterThan(0, "the pass stamps the file so the next open skips it instead of scanning _objects again"); var loaded = await redb.LoadAsync(id, depth: 1); loaded!.hash.Should().Be(savedHash); loaded.Props.TasksTotal.Should().Be(8); } // Third open: nothing left to convert — the step is a no-op, not a rewrite. await using (var sp = BuildServices(ConnectionString, pro)) { var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); (await redb.LoadAsync(id, depth: 1))!.hash.Should().Be(savedHash); } } [Theory] [InlineData(false)] [InlineData(true)] public async Task FilterByHash_FindsTheObject(bool pro) { await using var sp = BuildServices(ConnectionString, pro); var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); var ids = new List(); for (var i = 0; i < 3; i++) { ids.Add(await redb.SaveAsync(new RedbObject { name = $"filter-{i}", Props = new ProjectMetricsProps { ProjectId = 10 + i, TasksTotal = 3 + i, TasksCompleted = i } })); } var wanted = (await redb.LoadAsync(ids[1], depth: 1))!.hash!.Value; var found = await redb.Query() .WhereRedb(o => o.Hash == wanted) .ToListAsync(); found.Should().ContainSingle("the uuid text of the filter is converted to the stored bytes on the value side") .Which.id.Should().Be(ids[1]); } public void Dispose() { Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools(); foreach (var suffix in new[] { "", "-wal", "-shm" }) { try { File.Delete(_dbPath + suffix); } catch { /* best effort */ } } } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteIgnoredPropertyWalkTests.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/Sqlite/SqliteIgnoredPropertyWalkTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteIgnoredPropertyWalkTests : IgnoredPropertyWalkTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); // A fresh file per host. const string cs = "Data Source=redb_tests_ignored_walk_free.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteIndexCatalogTests.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/Sqlite/SqliteIndexCatalogTests.cs ---- using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using redb.Core.Data; using redb.Core.Extensions; using redb.Core.Models; using redb.Core.Models.Configuration; using redb.SQLite.Data; using redb.SQLite.Extensions; using redb.SQLite.Sql; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; /// SqliteIndexCatalog.Base against a fresh SQLite file of this build (see ). public class SqliteIndexCatalogTests : IndexCatalogTestsBase { private readonly Dictionary _files = new(); protected override Task CreateDatabaseAsync(string name) { SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var path = Path.Combine(Path.GetTempPath(), name + ".db"); _files[name] = path; return Task.FromResult($"Data Source={path}"); } protected override Task DropDatabaseAsync(string name) { SqliteConnection.ClearAllPools(); if (_files.TryGetValue(name, out var path)) foreach (var file in new[] { path, path + "-wal", path + "-shm" }) { try { if (File.Exists(file)) File.Delete(file); } catch (IOException) { } } return Task.CompletedTask; } protected override void AddRedb(IServiceCollection services, string connectionString, Action configure) => services.AddRedb(o => o.UseSqlite(connectionString).Configure(configure)); protected override async Task> ReadCreateStatementsAsync(IRedbContext context) { var rows = await context.QueryAsync("SELECT name AS \"Name\", sql AS \"Sql\" FROM sqlite_master WHERE type = 'index' AND sql IS NOT NULL"); return rows.ToDictionary(r => r.Name!, r => r.Sql!, StringComparer.OrdinalIgnoreCase); } protected override IReadOnlyList Catalog => SqliteIndexCatalog.Base; protected override (string File, string Namespace, string Class, string Member, RedbIndexOrigin Origin) Target => ("redb.SQLite/sql/SqliteIndexCatalog.g.cs", "redb.SQLite.Sql", "SqliteIndexCatalog", "Base", RedbIndexOrigin.Base); private sealed class SqlRow { public string? Name { get; set; } public string? Sql { get; set; } } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteIndexRepairTests.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/Sqlite/SqliteIndexRepairTests.cs ---- using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Models.Configuration; using redb.SQLite.Data; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; /// The index check and its repair on a SQLite file, see . public class SqliteIndexRepairTests : IndexRepairTestsBase { private readonly Dictionary _files = new(); protected override Task CreateDatabaseAsync(string name) { SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var path = Path.Combine(Path.GetTempPath(), name + ".db"); _files[name] = path; return Task.FromResult($"Data Source={path}"); } protected override Task DropDatabaseAsync(string name) { SqliteConnection.ClearAllPools(); if (_files.TryGetValue(name, out var path)) foreach (var file in new[] { path, path + "-wal", path + "-shm" }) { try { if (File.Exists(file)) File.Delete(file); } catch (IOException) { } } return Task.CompletedTask; } protected override void AddRedb(IServiceCollection services, string connectionString, Action configure) => services.AddRedb(o => o.UseSqlite(connectionString).Configure(configure)); protected override string DropIndexSql(string table, string index) => $"DROP INDEX \"{index}\""; protected override string CreateOtherIndexSql(string index) => $"CREATE INDEX \"{index}\" ON _objects (_note)"; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteIntegerAverageTests.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/Sqlite/SqliteIntegerAverageTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteIntegerAverageTests : IntegerAverageTestsBase { public SqliteIntegerAverageTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteInterfaceCollectionsTests.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/Sqlite/SqliteInterfaceCollectionsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteInterfaceCollectionsTests : InterfaceCollectionsTestsBase { public SqliteInterfaceCollectionsTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteKeyCacheRepeatTests.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/Sqlite/SqliteKeyCacheRepeatTests.cs ---- using AwesomeAssertions.Execution; using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Data; using redb.Core.Extensions; using redb.Core.Models.Entities; using redb.Export.Providers; using redb.Export.Services; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Sqlite; /// /// The key cache of a process is kept per domain, and the domain is the hash of the connection string, not the /// database. Two cases where the cache hands out an id another row already has: /// /// two connection strings to one SQLite file in one process: the mark that keeps a range handed out in a /// rolled-back transaction from being handed out again is per string, so the other string repeats the range; /// an import into a database the process already used: the block the process cached before the import is /// handed out over the imported rows. /// /// The save looked new objects up as existing after it had given them their ids, so a repeated id did not fail: the /// create updated the row that had the id. Objects the save gives an id are now inserted; a repeated id fails once with /// a clear error, the cache of the domain is reset and the next save takes a fresh range. An id the caller set is still /// saved onto the row that has it (save by id): the two cases built on such an id are limits of 4.8 and skipped. /// public class SqliteKeyCacheRepeatTests { private const string SequenceTopSql = "SELECT seq FROM sqlite_sequence WHERE name = '_global_identity'"; [Fact(Skip = "Limit of 4.8: the key domain is the connection string, so the mark of ids handed out in a rolled-back " + "transaction is per string; an id the caller kept is then handed out under the other string and saving it " + "by id writes over that row.")] public async Task TwoConnectionStringsToOneFile_ARangeRolledBackUnderOne_IsNotHandedOutAgainUnderTheOther() { var file = $"redb_tests_keydomain_{Guid.NewGuid():N}.db"; var csA = $"Data Source={file}"; var csB = $"Data Source={Path.GetFullPath(file)}"; SqliteTestSupport.DeleteDbFiles(csA); await using var providerA = Build(csA); await using var providerB = Build(csB); var a = providerA.GetRequiredService(); var b = providerB.GetRequiredService(); await a.InitializeAsync(ensureCreated: true); await a.SyncSchemeAsync(); await b.InitializeAsync(); await b.SyncSchemeAsync(); ((RedbKeyGeneratorBase)a.Context.Keys).Domain.Should().NotBe(((RedbKeyGeneratorBase)b.Context.Keys).Domain, "precondition: the two strings name one file and give two key domains"); // Under string A: an id the application takes inside its own transaction, which then rolls back. long held; await using (var tx = await a.Context.BeginTransactionAsync()) { RedbKeyGeneratorBase.ClearAllCaches(); var top = await a.Context.ExecuteScalarAsync(SequenceTopSql); held = (await a.Context.NextObjectIdBatchAsync(1))[0]; held.Should().BeGreaterThan(top, "precondition: the id came from inside the transaction"); await tx.RollbackAsync(); } // Under string B: its next range (its cache ran out, which emptying the caches stands for). RedbKeyGeneratorBase.ClearAllCaches(); var victim = new RedbObject { name = "keydomain-B", Props = new SimpleProps { Title = "written by B" } }; var victimId = await b.SaveAsync(victim); // Under string A again: the application saves its object with the id it kept. var kept = new RedbObject { name = "keydomain-A", Props = new SimpleProps { Title = "written by A" } }; kept.Id = held; await a.SaveAsync(kept); var victimNow = await b.LoadAsync(victimId); using (new AssertionScope()) { victimId.Should().NotBe(held, "an id handed out under string A is not handed out again under string B"); victimNow!.name.Should().Be("keydomain-B", "saving A's object does not write over B's row"); victimNow.Props.Title.Should().Be("written by B"); } } [Fact] public async Task ImportIntoADatabaseTheProcessUsed_TheNextSave_FailsOnceAndLeavesTheImportedRows() { var (target, source) = (NewDatabase("tgt"), NewDatabase("src")); await using var providerT = Build(target); var redb = providerT.GetRequiredService(); await SeedAsync(redb, 1); var importedIds = await SeedSourceAndImportAsync(source, target, 20); // The block this process cached before the import is still handed out: the create gets an imported id. var created = new RedbObject { name = "keyimport-new", Props = new SimpleProps { Title = "after the import" } }; var first = async () => await redb.SaveAsync(created); await first.Should().ThrowAsync().WithMessage("*key cache*restore or an import*"); created.Id.Should().Be(0, "the failed save gives the object its id 0 back"); await AssertImportedIntactAsync(target, importedIds); // The cache was reset: the same object is created with a fresh id. var id = await redb.SaveAsync(created); importedIds.Should().NotContain(id); (await redb.LoadAsync(id))!.Props.Title.Should().Be("after the import"); await AssertImportedIntactAsync(target, importedIds); } [Fact] public async Task ImportIntoADatabaseTheProcessUsed_TheNextAddNewObjects_FailsOnceAndLeavesTheImportedRows() { var (target, source) = (NewDatabase("tgt"), NewDatabase("src")); await using var providerT = Build(target); var redb = providerT.GetRequiredService(); await SeedAsync(redb, 1); var importedIds = await SeedSourceAndImportAsync(source, target, 20); var created = new RedbObject { name = "keyimport-bulk", Props = new SimpleProps { Title = "bulk after the import" } }; var first = async () => await redb.AddNewObjectsAsync(new[] { created }); await first.Should().ThrowAsync().WithMessage("*key cache*restore or an import*"); created.Id.Should().Be(0); await AssertImportedIntactAsync(target, importedIds); var ids = await redb.AddNewObjectsAsync(new[] { created }); importedIds.Should().NotContain(ids[0]); (await redb.LoadAsync(ids[0]))!.Props.Title.Should().Be("bulk after the import"); await AssertImportedIntactAsync(target, importedIds); } private static async Task AssertImportedIntactAsync(string target, List importedIds) { var names = await ScalarAsync(target, $"SELECT COUNT(*) FROM _objects WHERE _name LIKE 'keyimport-src-%' AND _id IN ({string.Join(",", importedIds)})"); names.Should().Be(importedIds.Count.ToString(), "every imported object keeps its row"); } [Fact(Skip = "Limit of 4.8 by design: an id the caller set is saved onto the row that has it (save by id). An id taken " + "before an import and saved after it writes over the imported row; restart the application after an import.")] public async Task ImportIntoADatabaseTheProcessUsed_AnIdTakenBefore_DoesNotWriteOverAnImportedRow() { var (target, source) = (NewDatabase("tgt"), NewDatabase("src")); await using var providerT = Build(target); var redb = providerT.GetRequiredService(); await SeedAsync(redb, 1); var held = (await redb.Context.NextObjectIdBatchAsync(1))[0]; var importedIds = await SeedSourceAndImportAsync(source, target, 20); importedIds.Should().Contain(held, "precondition: the imported rows took the id the process had already handed out"); var importedName = await ScalarAsync(target, $"SELECT _name FROM _objects WHERE _id = {held}"); var kept = new RedbObject { name = "keyimport-kept", Props = new SimpleProps { Title = "taken before the import" } }; kept.Id = held; await redb.SaveAsync(kept); (await ScalarAsync(target, $"SELECT _name FROM _objects WHERE _id = {held}")).Should().Be(importedName, "an object saved with an id taken before the import does not write over the imported row of that id"); } private static async Task SeedAsync(IRedbService redb, int count) { await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); for (var i = 0; i < count; i++) await redb.SaveAsync(new RedbObject { name = $"keyimport-tgt-{i}", Props = new SimpleProps { Title = $"t{i}" } }); } /// /// A second database built by the same steps hands out the same ids; it saves more objects, so its rows cover /// the ids the target process holds next. Exported and imported into the target with cleaning, the way a backup /// of another installation is loaded. /// private static async Task> SeedSourceAndImportAsync(string source, string target, int count) { await using (var provider = Build(source)) { var src = provider.GetRequiredService(); await src.InitializeAsync(ensureCreated: true); await src.SyncSchemeAsync(); for (var i = 0; i < count; i++) await src.SaveAsync(new RedbObject { name = $"keyimport-src-{i}", Props = new SimpleProps { Title = $"s{i}" } }); } var file = Path.Combine(Path.GetTempPath(), $"redb-export-{Guid.NewGuid():N}.redb"); await using (var provider = ProviderFactory.Create("sqlite")) { await provider.OpenAsync(source); await new ExportService(provider, verbose: false, batchSize: 1000).ExportAsync(file, null, compress: false, dryRun: false); } await using (var provider = ProviderFactory.Create("sqlite")) { await provider.OpenAsync(target); await new ImportService(provider, verbose: false, batchSize: 1000).ImportAsync(file, clean: true, dryRun: false); } File.Delete(file); var ids = new List(); await using var connection = new SqliteConnection(target); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = "SELECT _id FROM _objects WHERE _name LIKE 'keyimport-src-%'"; await using var reader = await command.ExecuteReaderAsync(); while (await reader.ReadAsync()) ids.Add(reader.GetInt64(0)); return ids; } private static string NewDatabase(string suffix) { var cs = $"Data Source=redb_tests_keyimport_{suffix}_{Guid.NewGuid():N}.db"; SqliteTestSupport.DeleteDbFiles(cs); return cs; } private static ServiceProvider Build(string cs) { global::redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => { options.UseSqlite(cs); options.Configure(c => c.CacheDomain = $"keycache-{Guid.NewGuid():N}"); }); return services.BuildServiceProvider(); } private static async Task ScalarAsync(string cs, string sql) { await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = sql; return (await command.ExecuteScalarAsync())?.ToString(); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteKeygenInTransactionTests.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/Sqlite/SqliteKeygenInTransactionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteKeygenInTransactionTests : SqliteKeygenInTransactionTestsBase { public SqliteKeygenInTransactionTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteLazyHostTests.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/Sqlite/SqliteLazyHostTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteLazyHostTests : LazyHostTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); const string cs = "Data Source=redb_tests_lazyhost_free.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } protected override string ReadFlagSql => "SELECT redb_lazy_refs()"; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteLazyReferenceTests.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/Sqlite/SqliteLazyReferenceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteLazyReferenceTests : LazyReferenceTestsBase { public SqliteLazyReferenceTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteLazyReferencesOptionTests.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/Sqlite/SqliteLazyReferencesOptionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteLazyReferencesOptionTests : LazyReferencesOptionTestsBase { public SqliteLazyReferencesOptionTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteLikeEscapingTests.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/Sqlite/SqliteLikeEscapingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteLikeEscapingTests : LikeEscapingTestsBase { public SqliteLikeEscapingTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteListItemArrayAnyTests.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/Sqlite/SqliteListItemArrayAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteListItemArrayAnyTests : ListItemArrayAnyTestsBase { public SqliteListItemArrayAnyTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteListItemObjectWalkTests.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/Sqlite/SqliteListItemObjectWalkTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteListItemObjectWalkTests : ListItemObjectWalkTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); // A fresh file per host. const string cs = "Data Source=redb_tests_listitem_walk_free.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteListItemPreloadTests.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/Sqlite/SqliteListItemPreloadTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Extensions; using redb.Core.Models.Entities; using redb.SQLite.Pro.Extensions; namespace redb.Tests.Integration.Tests.Sqlite; /// /// Hand-out preload of list-item linked objects (a production freeze, 2026-09-09): a production loop /// touching lazy Object on fresh items caused ~150 detached loads per second and, through the /// old getter, a process-wide freeze. With PreloadListItemLinkedObjects (default ON) the list /// provider resolves the linked objects in ONE batch at hand-out, so touching Object is a /// field read. The OFF branch pins the previous lazy behaviour. /// public class SqliteListItemPreloadTests { private static ServiceProvider Build(bool preload) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build() .GetConnectionString("Sqlite")! .Replace("redb_tests_sqlite.db", "redb_tests_sqlite_preload.db"); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(o => { o.UseSqlite(cs); o.Configure(c => { c.PreloadListItemLinkedObjects = preload; c.CacheDomain = "listitem-preload-" + preload; }); }); return services.BuildServiceProvider(); } private static async Task SeedListAsync(IRedbService redb, string marker) { var list = await redb.ListProvider.SaveListAsync(new RedbList { Name = $"PreloadProbe-{marker}-{Guid.NewGuid():N}" }); for (var i = 0; i < 3; i++) { var obj = new RedbObject { name = $"preload-{marker}-{i}", Props = new Models.SimpleProps { Title = $"linked-{i}" }, }; var objId = await redb.SaveAsync(obj); await redb.ListProvider.SaveListItemAsync(new RedbListItem { IdList = list.Id, Value = "v" + i, IdObject = objId }); } return list.Id; } [Fact] public async Task HandOut_PreloadsLinkedObjects_InOneBatch() { await using var sp = Build(preload: true); var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); var listId = await SeedListAsync(redb, "on"); var items = (await redb.ListProvider.GetListItemsAsync(listId)) .Where(i => i.IdObject.HasValue).ToList(); items.Should().HaveCount(3); items.Should().OnlyContain(i => i.IsObjectLoaded, "the hand-out resolves linked objects up front - touching Object must be a field read"); items.Select(i => i.Object!.Name).Should().OnlyContain(n => n!.StartsWith("preload-on-")); } [Fact] public async Task HandOut_WithPreloadDisabled_StaysLazy() { await using var sp = Build(preload: false); var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); var listId = await SeedListAsync(redb, "off"); var items = (await redb.ListProvider.GetListItemsAsync(listId)) .Where(i => i.IdObject.HasValue).ToList(); items.Should().HaveCount(3); items.Should().OnlyContain(i => !i.IsObjectLoaded, "with the option off the items keep the previous lazy contract"); items[0].Object.Should().NotBeNull("the lazy path still works when actually touched"); } [Fact] public async Task GetObjectAsync_ResolvesWithoutBlocking() { await using var sp = Build(preload: false); var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); var listId = await SeedListAsync(redb, "async"); var item = (await redb.ListProvider.GetListItemsAsync(listId)).First(i => i.IdObject.HasValue); item.IsObjectLoaded.Should().BeFalse(); var obj = await item.GetObjectAsync(); obj.Should().NotBeNull(); item.IsObjectLoaded.Should().BeTrue("the async path publishes exactly like the getter"); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteListItemSyncGetterTests.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/Sqlite/SqliteListItemSyncGetterTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Exceptions; using redb.Core.Extensions; using redb.Core.Models.Configuration; using redb.Core.Models.Entities; using redb.SQLite.Pro.Extensions; namespace redb.Tests.Integration.Tests.Sqlite; /// /// The thread-pool-free sync path of end to end: the getter runs the /// whole load - scheme lookup, permission check, get_object_json, deserialization - on the calling /// thread down to ADO.NET, on the reader's scope. A saturated thread pool can no longer slow or /// deadlock a lazy touch. Preload is OFF here so every touch really exercises the lazy chain. /// public class SqliteListItemSyncGetterTests { private static ServiceProvider Build(Action? configure = null) { var cs = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build() .GetConnectionString("Sqlite")! .Replace("redb_tests_sqlite.db", "redb_tests_sqlite_syncgetter.db"); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(o => { o.UseSqlite(cs); o.Configure(c => { c.PreloadListItemLinkedObjects = false; c.CacheDomain = "listitem-syncgetter"; configure?.Invoke(c); }); }); return services.BuildServiceProvider(); } private static async Task SeedListAsync(IRedbService redb, string marker) { var list = await redb.ListProvider.SaveListAsync(new RedbList { Name = $"SyncGetterProbe-{marker}-{Guid.NewGuid():N}" }); for (var i = 0; i < 2; i++) { var obj = new RedbObject { name = $"syncget-{marker}-{i}", Props = new Models.SimpleProps { Title = $"linked-{i}" }, }; var objId = await redb.SaveAsync(obj); await redb.ListProvider.SaveListItemAsync(new RedbListItem { IdList = list.Id, Value = "v" + i, IdObject = objId }); } return list.Id; } [Fact] public async Task LazyTouch_LoadsThroughTheSyncChain() { await using var sp = Build(); var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); var listId = await SeedListAsync(redb, "live"); var items = (await redb.ListProvider.GetListItemsAsync(listId)) .Where(i => i.IdObject.HasValue).ToList(); items.Should().HaveCount(2); items.Should().OnlyContain(i => !i.IsObjectLoaded, "preload is off - the items stay lazy"); foreach (var item in items) { var obj = item.Object; obj.Should().NotBeNull(); obj!.Name.Should().StartWith("syncget-live-"); item.IsObjectLoaded.Should().BeTrue(); } } /// Seeds and hands the items out of a scope that ends - in this helper, so nothing stays current. private static async Task> ItemsOfADeadScopeAsync(ServiceProvider sp) { await using var scope = sp.CreateAsyncScope(); var redb = scope.ServiceProvider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); var listId = await SeedListAsync(redb, "dead"); return (await redb.ListProvider.GetListItemsAsync(listId)).Where(i => i.IdObject.HasValue).ToList(); } [Fact] public async Task LazyTouch_AfterTheScopeDied_Refuses() { await using var sp = Build(); var survivors = await ItemsOfADeadScopeAsync(sp); survivors.Should().HaveCount(2); // The scope that handed the items out is gone and no other scope reads here: a clear refusal, never a scope // opened behind the reader's back (owner decision 2026-09-15). foreach (var item in survivors) { Action touch = () => _ = item.Object; touch.Should().Throw(); item.IsObjectLoaded.Should().BeFalse(); } } [Fact] public async Task LazyTouch_AfterTheScopeDied_LoadsInAFreshScopeSynchronously_WhenConfigured() { await using var sp = Build(c => c.LazyLoadWithoutScope = LazyLoadWithoutScopeMode.FreshScope); var survivors = await ItemsOfADeadScopeAsync(sp); foreach (var item in survivors) { var obj = item.Object; obj.Should().NotBeNull("the option opens a fresh scope for the load, on the calling thread"); obj!.Name.Should().StartWith("syncget-dead-"); } } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteListReadPropsOnceTests.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/Sqlite/SqliteListReadPropsOnceTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteListReadPropsOnceTests : ListReadPropsOnceTestsBase { private const string Cs = "Data Source=redb_tests_once_free.db"; private bool _prepared; protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); // A fresh file per test, shared by every provider the test builds (its own and the writer's). Deleted per // provider, the file went away under the open connection of the first one wherever an open file can be // deleted (Linux), and the writer wrote into a new file the reader never saw. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteListTests.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/Sqlite/SqliteListTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteListTests : ListTestsBase { public SqliteListTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteLockForUpdateTests.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/Sqlite/SqliteLockForUpdateTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteLockForUpdateTests : LockForUpdateTestsBase { public SqliteLockForUpdateTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteLongBaseFilterTests.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/Sqlite/SqliteLongBaseFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteLongBaseFilterTests : LongBaseFilterTestsBase { public SqliteLongBaseFilterTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteMaintenanceFreshDatabaseTests.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/Sqlite/SqliteMaintenanceFreshDatabaseTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.Sqlite; /// /// A SQLite database nobody has analysed yet - the state every quick-start image starts in. /// sqlite_stat1 does not exist until the first ANALYZE, and the maintenance facade must /// report what the engine knows (nothing) instead of failing: a dashboard page that reads storage /// health would answer 500 while the very button that would fix it sits on that page /// (redb.Tsak BR-13, 2026-09-21). /// public class SqliteMaintenanceFreshDatabaseTests { [Fact] public async Task OnADatabaseNeverAnalysed_TableStatsSayThereAreNoStatistics() { await using var provider = Build(); var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); // No ANALYZE has run on this file, so sqlite_stat1 is absent. var tables = await redb.Maintenance.GetTableStatsAsync(); tables.Should().NotBeEmpty("the redb schema creates its tables regardless of statistics"); var objects = tables.First(t => t.Table == "_objects"); objects.EstimatedRows.Should().BeNull("the engine has no estimate to give yet"); objects.HasStatistics.Should().BeFalse("that is exactly what this flag is for"); } [Fact] public async Task OnADatabaseNeverAnalysed_IndexStatsStillRead() { await using var provider = Build(); var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); var stats = await redb.Maintenance.GetIndexStatsAsync(); stats.Should().NotBeEmpty(); stats.Should().OnlyContain(s => s.Columns.Count > 0); } [Fact] public async Task AfterAnalyze_TheSameCallsCarryEstimates() { await using var provider = Build(); var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.Maintenance.AnalyzeAsync(); var tables = await redb.Maintenance.GetTableStatsAsync(); tables.Should().Contain(t => t.Table == "_objects" && t.HasStatistics == true, "ANALYZE creates sqlite_stat1, and the same query must then say so"); } private static ServiceProvider Build() { global::redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var cs = $"Data Source=redb_tests_fresh_{Guid.NewGuid():N}.db"; SqliteTestSupport.DeleteDbFiles(cs); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => { options.UseSqlite(cs); options.Configure(c => c.CacheDomain = $"fresh-{Guid.NewGuid():N}"); }); return services.BuildServiceProvider(); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteMaintenanceTests.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/Sqlite/SqliteMaintenanceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteMaintenanceTests : MaintenanceTestsBase { public SqliteMaintenanceTests(SqliteFixture fixture) : base(fixture.Redb) { } // e_sqlite3 may or may not compile dbstat in; the base falls back to the size-less form. protected override bool ReportsSizes => false; protected override bool HasSchemas => false; protected override bool ReportsUsageCounters => false; protected override bool ReportsAnalyzeTime => false; // INTEGER PRIMARY KEY is the rowid itself: SQLite creates no index object for it. protected override bool ReportsPrimaryKeyIndexes => false; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteMaterializationFidelityTests.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/Sqlite/SqliteMaterializationFidelityTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteMaterializationFidelityTests : MaterializationFidelityTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); const string cs = "Data Source=redb_tests_fidelity_free.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteNativeExtensionVersionTests.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/Sqlite/SqliteNativeExtensionVersionTests.cs ---- using redb.Core; using redb.SQLite.Sql; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteNativeExtensionVersionTests { private readonly IRedbService _redb; public SqliteNativeExtensionVersionTests(SqliteFixture fixture) => _redb = fixture.Redb; /// /// The extension the tests load reports the version the dialect requires. A stale build next to the tests is /// caught here by name, not by a query that answers in an old shape; and the dialect names the function the /// initialization gate asks, as the PostgreSQL and SQL Server dialects do. /// [Fact] public async Task TheLoadedExtension_ReportsTheRequiredVersion() { var dialect = new SqliteDialect(); dialect.Query_PvtModuleVersionFunction().Should().Be("pvt_module_version"); dialect.Query_PvtRequiredVersion().Should().NotBeNullOrEmpty(); var deployed = await _redb.Context.ExecuteScalarAsync("SELECT pvt_module_version()"); deployed.Should().Be(dialect.Query_PvtRequiredVersion()); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteNestedDictionaryFilterTests.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/Sqlite/SqliteNestedDictionaryFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteNestedDictionaryFilterTests : NestedDictionaryFilterTestsBase { public SqliteNestedDictionaryFilterTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteNullComparisonTests.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/Sqlite/SqliteNullComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteNullComparisonTests : NullComparisonTestsBase { public SqliteNullComparisonTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteNullableCollectionsTests.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/Sqlite/SqliteNullableCollectionsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteNullableCollectionsTests : NullableCollectionsTestsBase { public SqliteNullableCollectionsTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteObsoleteInitializationTests.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/Sqlite/SqliteObsoleteInitializationTests.cs ---- using System.Reflection; using System.Reflection.Emit; using System.Runtime.Loader; using redb.Core; using redb.Core.Attributes; using redb.Core.Extensions; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.Sqlite; /// /// The obsolete AutoSyncSchemesAsync extension (review INIT-1) carried its own copy of the start-up sequence: /// parallel on one instance, without the up-front validation of scheme names, and with every synchronization /// error swallowed in a bare catch. A scheme with a name that must not boot passed through it without a word. /// The scheme lives in an assembly built here, so no other test ever scans it. /// [Collection("Sqlite")] public class SqliteObsoleteInitializationTests { private readonly IRedbService _redb; public SqliteObsoleteInitializationTests(SqliteFixture fixture) => _redb = fixture.Redb; /// /// Built in its own collectible load context: an InitializeAsync() without arguments scans every assembly of /// the default context, and a bad scheme left there fails every later initialization in the process. /// private static Assembly AssemblyWithABadSchemeName(AssemblyLoadContext context) { using var _ = context.EnterContextualReflection(); var assembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("redb.Tests.BadSchemeName"), AssemblyBuilderAccess.RunAndCollect); var type = assembly.DefineDynamicModule("m").DefineType("BadSchemeNameProps", TypeAttributes.Public | TypeAttributes.Class); type.SetCustomAttribute(new CustomAttributeBuilder( typeof(RedbSchemeAttribute).GetConstructor(Type.EmptyTypes)!, [], [typeof(RedbSchemeAttribute).GetProperty(nameof(RedbSchemeAttribute.Name))!], ["bad name!"])); type.DefineDefaultConstructor(MethodAttributes.Public); type.CreateType(); return assembly; } [Fact] public async Task AutoSyncSchemesAsync_RefusesASchemeThatMustNotBoot() { var context = new AssemblyLoadContext("redb.Tests.BadSchemeName", isCollectible: true); try { var assembly = AssemblyWithABadSchemeName(context); AssemblyLoadContext.Default.Assemblies.Should().NotContain(assembly, "precondition: no other test can scan it"); #pragma warning disable CS0618 // the obsolete entry point is what this test is about var sync = async () => await RedbServiceInitializationExtensions.AutoSyncSchemesAsync(_redb, assembly); #pragma warning restore CS0618 (await sync.Should().ThrowAsync()).Which.ToString().Should().Contain("bad name!"); } finally { context.Unload(); } } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteOrderAbsentValueTests.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/Sqlite/SqliteOrderAbsentValueTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteOrderAbsentValueTests : OrderAbsentValueTestsBase { public SqliteOrderAbsentValueTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteOrderingTests.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/Sqlite/SqliteOrderingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteOrderingTests : OrderingTestsBase { public SqliteOrderingTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteOrphanTransactionTests.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/Sqlite/SqliteOrphanTransactionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteOrphanTransactionTests : OrphanTransactionTestsBase { public SqliteOrphanTransactionTests(SqliteFixture fixture) : base(fixture.ServiceProvider) { } // A root SAVEPOINT opens a transaction; the INSERT takes the write lock; the third statement fails. protected override string FailingBatchThatOpensATransaction => "SAVEPOINT redb_orphan_probe; INSERT INTO _global_identity DEFAULT VALUES; SELECT * FROM redb_no_such_table;"; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqlitePasswordHasherDefaultTests.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/Sqlite/SqlitePasswordHasherDefaultTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqlitePasswordHasherDefaultTests : PasswordHasherDefaultTestsBase { public SqlitePasswordHasherDefaultTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqlitePermissionCacheDomainTests.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/Sqlite/SqlitePermissionCacheDomainTests.cs ---- #pragma warning disable CS0618 // implements or uses the deprecated object permissions and roles (RedbDeprecation) using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Extensions; using redb.Core.Models.Entities; using redb.Core.Models.Enums; using redb.Core.Models.Users; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Sqlite; /// /// The permission cache is shared by the process, and ids are per database: two databases hand out the same /// user and object ids in the same order (the system admin is id 1 in every one of them). A permission worked /// out in one database must never answer for another (review 2026-09-24, C-1: the key was user and object /// only, the same class of defect as the structure-tree cache fixed earlier as B-10). /// public class SqlitePermissionCacheDomainTests { [Fact] public async Task APermissionOfOneDatabase_IsNotServedForAnother() { await using var providerA = Build("a"); await using var providerB = Build("b"); var a = providerA.GetRequiredService(); var b = providerB.GetRequiredService(); // The same steps in the same order on two fresh databases give the same ids. var (userA, objectA) = await SeedAsync(a); var (userB, objectB) = await SeedAsync(b); userA.Id.Should().Be(userB.Id, "precondition: the two databases gave the user the same id"); objectA.Id.Should().Be(objectB.Id, "precondition: the two databases gave the object the same id"); // Database A lets the user delete the object; database B lets them only read it. (With no permission row at // all the check throws rather than answers, so B gets a row that says no.) await a.GrantPermissionAsync(userA, objectA, PermissionAction.Delete); await b.GrantPermissionAsync(userB, objectB, PermissionAction.Select); (await b.CanUserDeleteObject(objectB.Id, userB.Id)).Should().BeFalse("database B granted reading only"); (await a.CanUserDeleteObject(objectA.Id, userA.Id)).Should().BeTrue( "database A granted delete, and the answer of database B for the same ids must not stand in for it"); (await b.CanUserDeleteObject(objectB.Id, userB.Id)).Should().BeFalse( "and the other way round: A's grant is not B's"); } private static async Task<(Core.Models.Contracts.IRedbUser User, RedbObject Object)> SeedAsync(IRedbService redb) { await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); var user = await redb.UserProvider.CreateUserAsync( new CreateUserRequest { Login = "perm-user", Name = "perm-user", Password = "perm-password-1" }); var obj = new RedbObject { name = "perm-target", Props = new SimpleProps { Title = "target" } }; await redb.SaveAsync(obj); return (user, obj); } private static ServiceProvider Build(string suffix) { global::redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var cs = $"Data Source=redb_tests_perm_{suffix}_{Guid.NewGuid():N}.db"; SqliteTestSupport.DeleteDbFiles(cs); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => { options.UseSqlite(cs); options.Configure(c => c.CacheDomain = $"perm-{suffix}-{Guid.NewGuid():N}"); }); return services.BuildServiceProvider(); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqlitePlannerStatisticsTests.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/Sqlite/SqlitePlannerStatisticsTests.cs ---- using AwesomeAssertions; using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Extensions; using redb.Core.Models.Configuration; using redb.Core.Models.Entities; using redb.SQLite.Data; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; using Xunit; namespace redb.Tests.Integration.Tests.Sqlite; /// /// Planner statistics of a SQLite file (KeepSqlitePlannerStatistics): a file an application filled has no sqlite_stat1, /// and SQLite then costs every index lookup at a few rows. Start-up analyzes a file with no statistics once it holds /// 10 000 value rows, and leaves a smaller one alone. /// public class SqlitePlannerStatisticsTests { [Fact] public async Task Start_AnalyzesAFileAboveTheThreshold_AndLeavesASmallerOneAlone() { var dbPath = Path.Combine(Path.GetTempPath(), $"redb_stats_{Guid.NewGuid():N}.db"); try { // A new file: below the threshold, no statistics after the start. await WithServiceAsync(dbPath, keep: true, async redb => { await redb.SyncSchemeAsync(); await redb.SaveAsync(new RedbObject { name = "stats-seed", Props = new EmployeeProps { FirstName = "S", Skills = Enumerable.Range(0, 12_000).Select(i => $"skill-{i}").ToArray() } }); }); StatisticsRows(dbPath).Should().Be(0, "the first start met an empty file, below the threshold"); // The next start meets 12 000 element rows and no statistics: it analyzes. await WithServiceAsync(dbPath, keep: true, _ => Task.CompletedTask); StatisticsRows(dbPath).Should().BeGreaterThan(0, "a file above the threshold without statistics is analyzed at start-up"); } finally { DeleteFile(dbPath); } } [Fact] public async Task Start_WithTheSwitchOff_GathersNothing() { var dbPath = Path.Combine(Path.GetTempPath(), $"redb_stats_off_{Guid.NewGuid():N}.db"); try { await WithServiceAsync(dbPath, keep: false, async redb => { await redb.SyncSchemeAsync(); await redb.SaveAsync(new RedbObject { name = "stats-off-seed", Props = new EmployeeProps { FirstName = "S", Skills = Enumerable.Range(0, 12_000).Select(i => $"skill-{i}").ToArray() } }); }); await WithServiceAsync(dbPath, keep: false, _ => Task.CompletedTask); StatisticsRows(dbPath).Should().Be(0, "KeepSqlitePlannerStatistics = false leaves the file as it is"); } finally { DeleteFile(dbPath); } } private static async Task WithServiceAsync(string dbPath, bool keep, Func body) { SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(o => o .UseSqlite($"Data Source={dbPath}") .Configure(c => { c.EnablePropsCache = false; c.KeepSqlitePlannerStatistics = keep; })); var sp = services.BuildServiceProvider(); try { var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await body(redb); } finally { await sp.DisposeAsync(); } } private static long StatisticsRows(string dbPath) { using var connection = new SqliteConnection($"Data Source={dbPath};Mode=ReadOnly;Pooling=False"); connection.Open(); using var exists = connection.CreateCommand(); exists.CommandText = "SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name = 'sqlite_stat1'"; if ((long)exists.ExecuteScalar()! == 0) return 0; using var rows = connection.CreateCommand(); rows.CommandText = "SELECT count(*) FROM sqlite_stat1 WHERE tbl IN ('_objects', '_values')"; return (long)rows.ExecuteScalar()!; } private static void DeleteFile(string dbPath) { // Best effort: in a full run another pool of the process may still hold the file for a moment; a temp file left // behind is not what these tests check. SqliteConnection.ClearAllPools(); foreach (var path in new[] { dbPath, dbPath + "-wal", dbPath + "-shm" }) { try { if (File.Exists(path)) File.Delete(path); } catch (IOException) { } } } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqlitePolymorphicTreeTests.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/Sqlite/SqlitePolymorphicTreeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqlitePolymorphicTreeTests : PolymorphicTreeTestsBase { public SqlitePolymorphicTreeTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteProCancellationTests.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/Sqlite/SqliteProCancellationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("SqlitePro")] public class SqliteProCancellationTests : CancellationTestsBase { public SqliteProCancellationTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteProKeygenInTransactionTests.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/Sqlite/SqliteProKeygenInTransactionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("SqlitePro")] public class SqliteProKeygenInTransactionTests : SqliteKeygenInTransactionTestsBase { public SqliteProKeygenInTransactionTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteProQueryTests.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/Sqlite/SqliteProQueryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteProQueryTests : ProQueryTestsBase { public SqliteProQueryTests(SqliteFixture fixture) : base(fixture.Redb, isPro: false) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteProjectionTests.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/Sqlite/SqliteProjectionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteProjectionTests : ProjectionTestsBase { public SqliteProjectionTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqlitePropertyRenameTests.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/Sqlite/SqlitePropertyRenameTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqlitePropertyRenameTests : PropertyRenameTestsBase { public SqlitePropertyRenameTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqlitePropsCacheHeaderTests.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/Sqlite/SqlitePropsCacheHeaderTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqlitePropsCacheHeaderTests : PropsCacheHeaderTestsBase { private const string Cs = "Data Source=redb_tests_cacheheader_free.db"; private bool _prepared; protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); // A fresh file per test, shared by both nodes of that test. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqlitePropsCacheSkipValidationTests.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/Sqlite/SqlitePropsCacheSkipValidationTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqlitePropsCacheSkipValidationTests : PropsCacheSkipValidationTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); const string cs = "Data Source=redb_tests_cacheskip_free.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqlitePropsCacheTransactionKeepTests.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/Sqlite/SqlitePropsCacheTransactionKeepTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqlitePropsCacheTransactionKeepTests : PropsCacheTransactionKeepTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); const string cs = "Data Source=redb_tests_cachekeep_free.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqlitePropsCacheTransactionTests.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/Sqlite/SqlitePropsCacheTransactionTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqlitePropsCacheTransactionTests : PropsCacheTransactionTestsBase { private const string Cs = "Data Source=redb_tests_cachetx_free.db"; private bool _prepared; protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); // A fresh file per test, shared by every provider the test builds (its own and the seeder's). Deleted per // provider, the file went away under the open connection of the first one wherever an open file can be // deleted (Linux), and the seeder wrote into a new file the test's transaction never saw. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqlitePvtOperandInjectionTests.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/Sqlite/SqlitePvtOperandInjectionTests.cs ---- using AwesomeAssertions; using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using redb.Core; using redb.Core.Data; using redb.Core.Models.Entities; using redb.Core.Query.Aggregation; using redb.Core.Serialization; using redb.SQLite.Query; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; using Xunit; namespace redb.Tests.Integration.Tests.Sqlite; /// /// The native PVT builder used to paste a JSON **string** operand into the statement unquoted /// whenever the column was not text, so caller-supplied text became live SQL /// (SQLI-PoC: operand splice, redb_pvt.c pvtAppendOperand). It now splices only a /// plain numeric literal and otherwise emits a call to pvt_refuse(), which raises when the /// statement runs. The last test asserts the connection no longer leaves the extension loader /// enabled, because that turned such a splice into load_extension(). /// [Collection("Sqlite")] public class SqlitePvtOperandInjectionTests(SqliteFixture fixture) { private const string SumAlias = "value"; private SqliteQueryProvider Provider => new( fixture.ServiceProvider.GetRequiredService(), fixture.ServiceProvider.GetRequiredService(), schemeSync: fixture.Redb); private static AggregateRequest SumAge() => new() { FieldPath = "Age", Function = AggregateFunction.Sum, Alias = SumAlias }; private async Task SchemeIdAsync() => (await fixture.Redb.LoadSchemeByTypeAsync()).Id; private Task SeedOneEmployeeAsync() => fixture.Redb.SaveAsync(new RedbObject { name = "poc-operand", Props = new EmployeeProps { FirstName = "A", LastName = "B", Age = 30 } }); [Fact] public async Task TextOperand_ForNonTextColumn_IsRefused() { await SeedOneEmployeeAsync(); var schemeId = await SchemeIdAsync(); var act = async () => await Provider.ExecuteAggregateBatchAsync( schemeId, [SumAge()], """{"Age": "0 OR 1=1"}"""); var ex = (await act.Should().ThrowAsync()).Which; ex.Message.Should().Contain("operand type mismatch", "a string against a Long column has no safe literal form and must be refused"); } [Fact] public async Task SubqueryOperand_IsRefused() { await SeedOneEmployeeAsync(); var schemeId = await SchemeIdAsync(); var act = async () => await Provider.ExecuteAggregateBatchAsync( schemeId, [SumAge()], """{"Age": "0 OR (SELECT COUNT(*) FROM _users) > 0"}"""); await act.Should().ThrowAsync(); } [Fact] public async Task NumericStringOperand_IsStillAccepted() { await SeedOneEmployeeAsync(); var schemeId = await SchemeIdAsync(); var batch = await Provider.ExecuteAggregateBatchAsync( schemeId, [SumAge()], """{"Age": "30"}"""); batch.Values.Should().ContainKey(SumAlias); batch.Values[SumAlias].Should().NotBeNull("a numeric literal is a legitimate operand for a Long column"); } [Fact] public async Task ArrayOperand_IsRefused() { await SeedOneEmployeeAsync(); var schemeId = await SchemeIdAsync(); var act = async () => await Provider.ExecuteAggregateBatchAsync( schemeId, [SumAge()], """{"Age": ["x] OR 1=1 --"]}"""); await act.Should().ThrowAsync("an array operand for a Long column must be refused"); } [Fact] public async Task LoadExtension_IsRefused_OnTheProviderConnection() { // SqliteDataSource.LoadNativeExtension turns EnableExtensions(true) back off once our // extension is loaded, so no statement on a redb connection may reach the loader. var ctx = fixture.ServiceProvider.GetRequiredService(); var act = async () => await ctx.ExecuteAsync("SELECT load_extension('redb_missing_ext')"); var ex = (await act.Should().ThrowAsync()).Which; ex.Message.Should().Contain("not authorized"); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteQueryOrderTests.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/Sqlite/SqliteQueryOrderTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteQueryOrderTests : QueryOrderTestsBase { public SqliteQueryOrderTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteQueryPlannerBlockTests.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/Sqlite/SqliteQueryPlannerBlockTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteQueryPlannerBlockTests : FreeQueryPlannerBlockTestsBase { public SqliteQueryPlannerBlockTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteQueryRowsAsJsonTests.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/Sqlite/SqliteQueryRowsAsJsonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteQueryRowsAsJsonTests : QueryRowsAsJsonTestsBase { public SqliteQueryRowsAsJsonTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteReaderConnectionTests.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/Sqlite/SqliteReaderConnectionTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteReaderConnectionTests : ReaderConnectionTestsBase { protected override string SlowScalarSql => SqliteSlowScalar.Sql; protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); const string cs = "Data Source=redb_tests_readerconn_free.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteRedbScopeSourceTests.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/Sqlite/SqliteRedbScopeSourceTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Extensions; using redb.Core.Models.Entities; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Sqlite; /// /// : a service opens scopes of its own container for code that holds one service and /// needs one per unit of work (redb.Route calls outside an exchange). The scope's service reads the same database, the /// holder owns the scope, and a service with no container - or a container whose scopes read another database - refuses. /// public class SqliteRedbScopeSourceTests { private const int Parallelism = 16; [Fact] public async Task AScopeOfTheContainer_GivesAnotherServiceOfTheSameDatabase_OwnedByTheHolder() { await using var provider = Build("same"); var redb = provider.GetRequiredService(); await BootAsync(redb); redb.CanCreateScope.Should().BeTrue("the service came from a container"); var scope = redb.CreateScope(); scope.Service.Should().NotBeSameAs(redb, "a scope has a service of its own"); scope.Service.CacheDomain.Should().Be(redb.CacheDomain, "the same database"); scope.ServiceProvider.Should().NotBeNull(); var id = await scope.Service.SaveAsync(new RedbObject { name = $"scope-{NewTag()}", Props = new SimpleProps { Title = "from the scope" } }); (await redb.LoadAsync(id))!.Props.Title.Should().Be("from the scope", "written to the database the holder reads"); await scope.DisposeAsync(); scope.Service.Context.IsDisposed.Should().BeTrue("disposing the scope ends its service"); } [Fact] public async Task ScopesOpenedAtOnce_WorkAtOnce() { await using var provider = Build("parallel"); var redb = provider.GetRequiredService(); await BootAsync(redb); var tag = NewTag(); // What one captive service could not do: sixteen units of work on the database at the same moment. var start = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var work = Enumerable.Range(0, Parallelism).Select(i => Task.Run(async () => { await start.Task; await using var scope = redb.CreateScope(); var id = await scope.Service.SaveAsync(new RedbObject { name = $"parallel-{tag}-{i}", Props = new SimpleProps { Title = $"unit-{i}" } }); return (Service: scope.Service, Id: id); })).ToArray(); start.SetResult(); var results = await Task.WhenAll(work); results.Select(r => r.Service).Distinct().Should().HaveCount(Parallelism, "one service per scope"); foreach (var (_, id) in results) (await redb.LoadAsync(id)).Should().NotBeNull(); } [Fact] public async Task AServiceBuiltWithoutAContainer_CannotOpenAScope() { await using var provider = Build("bare"); await BootAsync(provider.GetRequiredService()); // The same registrations, but no scope factory: a service assembled by hand from a provider of one's own. var bare = new global::redb.SQLite.RedbService(new WithoutScopeFactory(provider)); bare.CanCreateScope.Should().BeFalse(); var opening = () => bare.CreateScope(); opening.Should().Throw().WithMessage("*IServiceScopeFactory*"); } [Fact] public async Task AContainerWhoseScopesReadAnotherDatabase_IsRefused() { await using var other = Build("other"); await BootAsync(other.GetRequiredService()); await using var otherScope = other.CreateAsyncScope(); // A container that hands the root one database and every scope another: nothing a scope opened from the root // service may silently read. var services = Register("split"); services.AddScoped(sp => RedbServiceProviders.IsRoot(sp) ? new global::redb.SQLite.RedbService(sp) : new global::redb.SQLite.RedbService(otherScope.ServiceProvider)); await using var split = services.BuildServiceProvider(); var root = split.GetRequiredService(); await BootAsync(root); root.CanCreateScope.Should().BeTrue(); var opening = () => root.CreateScope(); opening.Should().Throw().WithMessage("*differently per resolution*", "the scope's service reads another database"); } private static ServiceProvider Build(string suffix) => Register(suffix).BuildServiceProvider(); private static ServiceCollection Register(string suffix) { global::redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var cs = $"Data Source=redb_tests_scope_source_{suffix}.db"; SqliteTestSupport.DeleteDbFiles(cs); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => { options.UseSqlite(cs); options.Configure(c => c.CacheDomain = $"scope-source-{suffix}-{Guid.NewGuid():N}"); }); return services; } private static async Task BootAsync(IRedbService redb) { await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); } private static string NewTag() => Guid.NewGuid().ToString("N")[..8]; /// The container's services, minus the scope factory. private sealed class WithoutScopeFactory(IServiceProvider inner) : IServiceProvider { public object? GetService(Type serviceType) => serviceType == typeof(IServiceScopeFactory) ? null : inner.GetService(serviceType); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteReferenceListSaveTests.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/Sqlite/SqliteReferenceListSaveTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteReferenceListSaveTests : ReferenceListSaveTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); const string cs = "Data Source=redb_tests_reflist_free.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteReferenceStubTests.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/Sqlite/SqliteReferenceStubTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteReferenceStubTests : ReferenceStubTestsBase { public SqliteReferenceStubTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteRegexQueryTests.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/Sqlite/SqliteRegexQueryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteRegexQueryTests : RegexQueryTestsBase { public SqliteRegexQueryTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteRolledBackSaveIdsTests.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/Sqlite/SqliteRolledBackSaveIdsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteRolledBackSaveIdsTests : RolledBackSaveIdsTestsBase { public SqliteRolledBackSaveIdsTests(SqliteFixture fixture) : base(fixture.ServiceProvider) { } protected override string? SequenceTopSql => "SELECT seq FROM sqlite_sequence WHERE name = '_global_identity'"; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteRowMapperTests.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/Sqlite/SqliteRowMapperTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteRowMapperTests : SqliteRowMapperTestsBase { public SqliteRowMapperTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteSaveGraphHashTests.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/Sqlite/SqliteSaveGraphHashTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteSaveGraphHashTests : SaveGraphHashTestsBase { public SqliteSaveGraphHashTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteSaveInterceptorTests.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/Sqlite/SqliteSaveInterceptorTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Data; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteSaveInterceptorTests : SaveInterceptorTestsBase { // The collection guarantees the shared db file exists and the native extension is resolved // before this suite opens its own connections to the same file. public SqliteSaveInterceptorTests(SqliteFixture _) { } protected override string ConnectionStringName => "Sqlite"; protected override void UseProvider(RedbOptionsBuilder options, string connectionString) { SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); options.UseSqlite(connectionString); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteSaveLockScopeTests.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/Sqlite/SqliteSaveLockScopeTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteSaveLockScopeTests : SaveLockScopeTestsBase { private const string Cs = "Data Source=redb_tests_savelock_free.db"; private bool _prepared; protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); // A fresh file per test class instance. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteSchemaInitTests.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/Sqlite/SqliteSchemaInitTests.cs ---- using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Extensions; using redb.Core.Models.Entities; using redb.Export.Providers; using redb.Export.Services; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Sqlite; /// /// redb init -p sqlite () leaves a file the export schema check and the SQLite /// service both take as current: stamped as the service stamps a file it creates (PRAGMA user_version, one /// _schema_compat row), and with the schema of this build, so the first service start changes nothing in it. The /// schema script alone left the file at version 0, and the documented create, init, import was refused. /// public class SqliteSchemaInitTests : IAsyncLifetime { private readonly List _databases = []; private readonly List _files = []; public Task InitializeAsync() => Task.CompletedTask; public Task DisposeAsync() { SqliteConnection.ClearAllPools(); foreach (var database in _databases) SqliteTestSupport.DeleteDbFiles(database); foreach (var file in _files) File.Delete(file); return Task.CompletedTask; } [Fact] public async Task Init_StampsTheFile_AsTheServiceDoes() { var cs = NewDatabase("init"); await SchemaInitService.InitializeAsync("sqlite", cs); (await ScalarAsync(cs, "PRAGMA user_version")).Should().Be(global::redb.SQLite.RedbService.SchemaVersion.ToString()); (await ScalarAsync(cs, "SELECT COUNT(*) FROM _schema_compat")).Should().Be("1"); } [Fact] public async Task AFileMadeByInit_IsTheCurrentSchema_TheFirstServiceStartChangesNothing() { var cs = NewDatabase("init"); await SchemaInitService.InitializeAsync("sqlite", cs); var before = await SchemaAsync(cs); before.Should().Contain(l => l.Contains("_renamed_from"), "precondition: the newest columns are in the script"); await using (var provider = Build(cs)) await provider.GetRequiredService().InitializeAsync(typeof(ExportService).Assembly); (await SchemaAsync(cs)).Should().Equal(before, "no upgrade step had anything to add, drop or restamp"); } [Fact] public async Task InitThenImport_ThePathTheCliReadmeDocuments_Passes() { var source = NewDatabase("src"); await using (var provider = Build(source)) { var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true, typeof(ExportService).Assembly); await redb.SyncSchemeAsync(); await redb.SaveAsync(new RedbObject { name = "exported", Props = new SimpleProps { Title = "t" } }); } var file = Path.Combine(Path.GetTempPath(), $"redb-init-{Guid.NewGuid():N}.redb"); _files.Add(file); await using (var provider = ProviderFactory.Create("sqlite")) { await provider.OpenAsync(source); await new ExportService(provider, verbose: false, batchSize: 1000).ExportAsync(file, null, compress: false, dryRun: false); } var target = NewDatabase("dst"); await SchemaInitService.InitializeAsync("sqlite", target); await using (var provider = ProviderFactory.Create("sqlite")) { await provider.OpenAsync(target); await new ImportService(provider, verbose: false, batchSize: 1000).ImportAsync(file, clean: true, dryRun: false); } (await ScalarAsync(target, "SELECT COUNT(*) FROM _objects WHERE _name = 'exported'")).Should().Be("1"); } [Fact] public async Task InitOnAnExistingFile_KeepsItsDataAndStamp() { var cs = NewDatabase("again"); await SchemaInitService.InitializeAsync("sqlite", cs); await using (var provider = Build(cs)) { var redb = provider.GetRequiredService(); await redb.InitializeAsync(typeof(ExportService).Assembly); await redb.SyncSchemeAsync(); await redb.SaveAsync(new RedbObject { name = "kept", Props = new SimpleProps { Title = "k" } }); } var before = await SchemaAsync(cs); await SchemaInitService.InitializeAsync("sqlite", cs); (await SchemaAsync(cs)).Should().Equal(before); (await ScalarAsync(cs, "SELECT COUNT(*) FROM _objects WHERE _name = 'kept'")).Should().Be("1"); } /// Every object of the schema with its DDL, the version stamp and the compatibility row. private static async Task> SchemaAsync(string cs) { var lines = new List(); await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using (var command = connection.CreateCommand()) { command.CommandText = "SELECT type || ' ' || name || ': ' || IFNULL(sql, '') FROM sqlite_master ORDER BY type, name"; await using var reader = await command.ExecuteReaderAsync(); while (await reader.ReadAsync()) lines.Add(reader.GetString(0)); } await using (var command = connection.CreateCommand()) { command.CommandText = "SELECT 'compat ' || _min_reader || ' ' || _package FROM _schema_compat"; await using var reader = await command.ExecuteReaderAsync(); while (await reader.ReadAsync()) lines.Add(reader.GetString(0)); } lines.Add("user_version " + await ScalarAsync(cs, "PRAGMA user_version")); return lines; } private string NewDatabase(string suffix) { global::redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var cs = $"Data Source=redb_tests_init_{suffix}_{Guid.NewGuid():N}.db"; SqliteTestSupport.DeleteDbFiles(cs); _databases.Add(cs); return cs; } private static ServiceProvider Build(string cs) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => { options.UseSqlite(cs); options.Configure(c => c.CacheDomain = $"init-{Guid.NewGuid():N}"); }); return services.BuildServiceProvider(); } private static async Task ScalarAsync(string cs, string sql) { await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = sql; return Convert.ToString(await command.ExecuteScalarAsync()); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteSchemaMissingTests.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/Sqlite/SqliteSchemaMissingTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteSchemaMissingTests : SchemaMissingTestsBase { private const string Cs = "Data Source=redb_tests_schemamissing.db"; protected override Task CreateEmptyDatabaseAsync() { // A fresh file IS the empty database: the first connection creates it without any table. redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); return Task.FromResult(Cs); } protected override Task DropDatabaseAsync(string connectionString) { Fixtures.SqliteTestSupport.DeleteDbFiles(connectionString); return Task.CompletedTask; } protected override void UseProvider(RedbOptionsBuilder options, string connectionString) => options.UseSqlite(connectionString); } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteSchemaNewerTests.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/Sqlite/SqliteSchemaNewerTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.SQLite.Data; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteSchemaNewerTests : SqliteSchemaNewerTestsBase { protected override void AddRedbServices(IServiceCollection services, string connectionString) { SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); services.AddRedb(options => options.UseSqlite(connectionString)); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteSchemeLoadValidationTests.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/Sqlite/SqliteSchemeLoadValidationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteSchemeLoadValidationTests : SchemeLoadValidationTestsBase { public SqliteSchemeLoadValidationTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteSchemeNamingTests.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/Sqlite/SqliteSchemeNamingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteSchemeNamingTests : SchemeNamingTestsBase { public SqliteSchemeNamingTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteSchemeRenameTests.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/Sqlite/SqliteSchemeRenameTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteSchemeRenameTests : SchemeRenameTestsBase { public SqliteSchemeRenameTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteSeedCorrectionTests.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/Sqlite/SqliteSeedCorrectionTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Data; using redb.Core.Extensions; using redb.Core.Utils; using redb.SQLite.Data; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.Sqlite; /// /// Upgrading a package must fix seeded metadata in a database that already exists. /// /// /// PostgreSQL and MSSQL carry such corrections in sql/v2-pvt/*.sql, which /// EnsurePvtModuleDeployedAsync reapplies whenever pvt_module_version() disagrees with /// the dialect. SQLite has no module and no version function, and redbSqlite.sql is applied only /// when the tables are absent — so it needs its own step, and that step needs its own test. /// /// /// /// This suite deliberately does NOT use : that fixture deletes the database /// file on every run, so it can only ever model a NEW database. The one case that matters here is an /// OLD one, which is why each test owns a temporary file and opens it twice. /// /// public class SqliteSeedCorrectionTests : IDisposable { private readonly string _dbPath = Path.Combine(Path.GetTempPath(), $"redb_seedfix_{Guid.NewGuid():N}.db"); private string ConnectionString => $"Data Source={_dbPath}"; private static ServiceProvider BuildServices(string connectionString) { SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => options.UseSqlite(connectionString)); return services.BuildServiceProvider(); } private async Task DateOnlyDbTypeAsync(IRedbContext ctx) => await ctx.ExecuteScalarAsync( $"SELECT _db_type FROM _types WHERE _id = {RedbTypeIds.DateOnly}"); /// /// The correction has to run when the database was created by an older build, and it has to be /// driven by opening the database — not by anything the caller remembers to do. /// [Fact] public async Task ExistingDatabase_WithStaleDateOnlySeed_IsCorrectedOnNextOpen() { // First open: creates the schema, as an older build would have. await using (var sp = BuildServices(ConnectionString)) { var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); var ctx = sp.GetRequiredService(); // Roll the seed back to the value the older build wrote. 'DateTime' is a _db_type no JSON // projection branches on, which is why every DateOnly property used to materialise as // 0001-01-01. await ctx.ExecuteAsync( $"UPDATE _types SET _db_type = 'DateTime' WHERE _id = {RedbTypeIds.DateOnly}"); (await DateOnlyDbTypeAsync(ctx)).Should().Be("DateTime", "the stale state must be staged"); } // Second open: the same file, a new service — the upgrade path. await using (var sp = BuildServices(ConnectionString)) { var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); var ctx = sp.GetRequiredService(); (await DateOnlyDbTypeAsync(ctx)).Should().Be("DateTimeOffset", "opening an existing database must correct the seed; without this SQLite has no channel " + "for such a fix at all and it would reach new databases only"); } } /// /// The correction runs on every start, so it must be a no-op the second time — and must not disturb /// a database that was already right. /// [Fact] public async Task CorrectSeed_IsLeftAloneAcrossRepeatedOpens() { for (var i = 0; i < 3; i++) { await using var sp = BuildServices(ConnectionString); var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); var ctx = sp.GetRequiredService(); (await DateOnlyDbTypeAsync(ctx)).Should().Be("DateTimeOffset", $"open #{i + 1}"); } } public void Dispose() { Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools(); foreach (var suffix in new[] { "", "-wal", "-shm" }) { try { File.Delete(_dbPath + suffix); } catch { /* best effort */ } } } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteSlowScalar.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/Sqlite/SqliteSlowScalar.cs ---- namespace redb.Tests.Integration.Tests.Sqlite; /// /// SQLite has no sleep: a recursive count that keeps one connection busy for a couple of seconds, long enough for a /// second command on the same connection to arrive while it runs. /// internal static class SqliteSlowScalar { public const string Sql = "WITH RECURSIVE c(x) AS (SELECT 1 UNION ALL SELECT x + 1 FROM c WHERE x < 30000000) SELECT count(*) FROM c"; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteStaleStructureTreeTests.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/Sqlite/SqliteStaleStructureTreeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteStaleStructureTreeTests : StaleStructureTreeTestsBase { public SqliteStaleStructureTreeTests(SqliteFixture fixture) : base(fixture.Redb) { } protected override bool HasChangeTracking => false; protected override bool ReadsAcrossTypeChange => false; protected override string GuidLiteral(Guid value) => $"x'{value:N}'"; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteSubSecondUpdateTests.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/Sqlite/SqliteSubSecondUpdateTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteSubSecondUpdateTests : SubSecondUpdateTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); const string cs = "Data Source=redb_tests_subsecond_free.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTagsFieldTests.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/Sqlite/SqliteTagsFieldTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteTagsFieldTests : TagsFieldTestsBase { public SqliteTagsFieldTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTemporalRoundTripTests.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/Sqlite/SqliteTemporalRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteTemporalRoundTripTests : TemporalRoundTripTestsBase { public SqliteTemporalRoundTripTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTimeTicksTests.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/Sqlite/SqliteTimeTicksTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteTimeTicksTests : TimeTicksTestsBase { public SqliteTimeTicksTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTimeTicksUpgradeTests.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/Sqlite/SqliteTimeTicksUpgradeTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Data; using redb.Core.Extensions; using redb.SQLite.Data; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.Sqlite; /// /// Schema step 15 of ApplySchemaUpgradesAsync: a file of schema version 14 says String for TimeOnly and TimeSpan in /// _types and in the metadata cache; reopened, both say Long, so the file writes their Ticks. Staged the way the other /// upgrade tests stage it: create a current file, put the old rows back, stamp version 14, reopen. /// public class SqliteTimeTicksUpgradeTests : IDisposable { private readonly string _dbPath = Path.Combine(Path.GetTempPath(), $"redb_timeticks_{Guid.NewGuid():N}.db"); private const string Ids = "(-9223372036854775685, -9223372036854775684)"; private ServiceProvider BuildServices() { SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => options.UseSqlite($"Data Source={_dbPath}")); return services.BuildServiceProvider(); } [Fact] public async Task Version14File_SaysLongForTimeOnlyAndTimeSpan() { await using (var sp = BuildServices()) { await sp.GetRequiredService().InitializeAsync(ensureCreated: true); await sp.GetRequiredService().SyncSchemeAsync(); var ctx = sp.GetRequiredService(); (await ctx.ExecuteScalarAsync($"SELECT COUNT(*) FROM _types WHERE _id IN {Ids} AND _db_type = 'Long'")) .Should().Be(2, "a new file is created with Long for both"); await ctx.ExecuteAsync($"UPDATE _types SET _db_type = 'String' WHERE _id IN {Ids}"); await ctx.ExecuteAsync($"UPDATE _scheme_metadata_cache SET db_type = 'String' WHERE _type_id IN {Ids}"); await ctx.ExecuteAsync("PRAGMA user_version = 14"); } await using (var sp = BuildServices()) { await sp.GetRequiredService().InitializeAsync(); var ctx = sp.GetRequiredService(); (await ctx.ExecuteScalarAsync($"SELECT COUNT(*) FROM _types WHERE _id IN {Ids} AND _db_type = 'Long'")) .Should().Be(2, "step 15 sets Long for TimeOnly and TimeSpan"); (await ctx.ExecuteScalarAsync($"SELECT COUNT(*) FROM _scheme_metadata_cache WHERE _type_id IN {Ids} AND db_type <> 'Long'")) .Should().Be(0, "and the copy in the metadata cache"); (await ctx.ExecuteScalarAsync("PRAGMA user_version")).Should().Be(global::redb.SQLite.RedbService.SchemaVersion, "the upgrade from 14 runs every later step and stamps the version of this build"); } } public void Dispose() { Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools(); foreach (var f in new[] { _dbPath, _dbPath + "-wal", _dbPath + "-shm" }) if (File.Exists(f)) File.Delete(f); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTopLevelCollectionsTests.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/Sqlite/SqliteTopLevelCollectionsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteTopLevelCollectionsTests : TopLevelCollectionsTestsBase { public SqliteTopLevelCollectionsTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTransactionIsolationTests.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/Sqlite/SqliteTransactionIsolationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteTransactionIsolationTests : TransactionIsolationTestsBase { public SqliteTransactionIsolationTests(SqliteFixture fixture) : base(fixture.Redb) { } /// SQLite has no isolation-level readout; the base asserts usability instead. protected override string? ReadLevelSql => null; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTrashBackgroundServiceTests.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/Sqlite/SqliteTrashBackgroundServiceTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteTrashBackgroundServiceTests : TrashBackgroundServiceTestsBase { private const string Cs = "Data Source=redb_tests_trashbg.db"; protected override Task CreateEmptyDatabaseAsync() { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); return Task.FromResult(Cs); } protected override Task DropDatabaseAsync(string connectionString) { Fixtures.SqliteTestSupport.DeleteDbFiles(connectionString); return Task.CompletedTask; } protected override void UseProvider(RedbOptionsBuilder options, string connectionString) => options.UseSqlite(connectionString); } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTrashPurgeTests.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/Sqlite/SqliteTrashPurgeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteTrashPurgeTests : TrashPurgeTestsBase { public SqliteTrashPurgeTests(SqliteFixture fixture) : base(fixture.ServiceProvider) { } // One writer: see the base. protected override bool ConcurrentWriters => false; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTrashedReferenceTargetTests.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/Sqlite/SqliteTrashedReferenceTargetTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteTrashedReferenceTargetTests : TrashedReferenceTargetTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); // A fresh file per host. const string cs = "Data Source=redb_tests_trashed_ref_free.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTreeDistinctTests.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/Sqlite/SqliteTreeDistinctTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteTreeDistinctTests : TreeDistinctTestsBase { public SqliteTreeDistinctTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTreeLevelAnalyticsTests.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/Sqlite/SqliteTreeLevelAnalyticsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteTreeLevelAnalyticsTests : TreeLevelAnalyticsTestsBase { public SqliteTreeLevelAnalyticsTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTreeQueryShapesTests.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/Sqlite/SqliteTreeQueryShapesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteTreeQueryShapesTests : TreeQueryShapesTestsBase { public SqliteTreeQueryShapesTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTreeSqlPreviewTests.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/Sqlite/SqliteTreeSqlPreviewTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteTreeSqlPreviewTests : TreeSqlPreviewTestsBase { public SqliteTreeSqlPreviewTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTreeTests.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/Sqlite/SqliteTreeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteTreeTests : TreeTestsBase { public SqliteTreeTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTypeMigrationSyncTests.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/Sqlite/SqliteTypeMigrationSyncTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteTypeMigrationSyncTests : TypeMigrationSyncTestsBase { public SqliteTypeMigrationSyncTests(SqliteFixture fixture) : base(fixture.Redb) { } protected override string TextTypeName => "TEXT"; protected override string BoolTrue => "1"; protected override string BoolFalse => "0"; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteTypeMigrationTests.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/Sqlite/SqliteTypeMigrationTests.cs ---- using redb.Core; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.Sqlite; /// /// GitHub #5 — SQLite has no stored functions, so the base scheme-sync path that runs /// SELECT * FROM migrate_structure_type(...) failed with /// no such table: migrate_structure_type, taking down InitializeAsync on any property /// type change. now handles the migration /// in C#. These assert the missing-function crash is gone on both Free and Pro SQLite. /// public abstract class SqliteTypeMigrationTestsBase { protected readonly IRedbService Redb; protected SqliteTypeMigrationTestsBase(IRedbService redb) => Redb = redb; [Fact] public async Task MigrateStructureType_SameColumn_ReturnsResult_NotMissingTable() { // Int and Long both store in _Long — a no-op — but the old path emitted the missing SQL function // and threw "no such table: migrate_structure_type". var res = await Redb.MigrateStructureTypeAsync(999_999_999, "Int", "Long", dryRun: false); res.Should().NotBeNull(); res.AffectedRows.Should().Be(0); } [Fact] public async Task MigrateStructureType_CrossColumnNoData_ReturnsResult_NotMissingTable() { // String -> ListItem is a cross-column change, but with no values under this (non-existent) // structure there is nothing to move — must return cleanly, never hit the missing function. var res = await Redb.MigrateStructureTypeAsync(999_999_999, "String", "ListItem", dryRun: false); res.Should().NotBeNull(); res.AffectedRows.Should().Be(0); } } [Collection("Sqlite")] public class SqliteTypeMigrationTests : SqliteTypeMigrationTestsBase { public SqliteTypeMigrationTests(SqliteFixture fixture) : base(fixture.Redb) { } } [Collection("SqlitePro")] public class SqliteProTypeMigrationTests : SqliteTypeMigrationTestsBase { public SqliteProTypeMigrationTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteUniqueKeyTests.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/Sqlite/SqliteUniqueKeyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteUniqueKeyTests : UniqueKeyTestsBase { public SqliteUniqueKeyTests(SqliteFixture fixture) : base(fixture.Redb) { } protected override string BoolTrue => "1"; // SQLite's message names only the columns ("UNIQUE constraint failed: _values._id_structure, // _values._unique"), so the exception cannot resolve the property. protected override bool ReportsKeyTuple => false; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteUniqueUpgradeTests.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/Sqlite/SqliteUniqueUpgradeTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Data; using redb.Core.Extensions; using redb.SQLite.Data; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.Sqlite; /// /// The SQLite delivery of the V4 unique-key DDL: a database file created before the columns existed /// gets them on the next open — ApplySchemaUpgradesAsync step 2, gated by /// PRAGMA user_version. Modeled the only honest way: create a current file, strip the columns /// and the index the way a pre-V4 build never had them, stamp the old schema version, reopen. /// public class SqliteUniqueUpgradeTests : IDisposable { private readonly string _dbPath = Path.Combine(Path.GetTempPath(), $"redb_uniqueup_{Guid.NewGuid():N}.db"); private string ConnectionString => $"Data Source={_dbPath}"; protected virtual ServiceProvider BuildServices(string connectionString) { SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => options.UseSqlite(connectionString)); return services.BuildServiceProvider(); } private static async Task ColumnExistsAsync(IRedbContext ctx, string table, string column) => (await ctx.ExecuteScalarAsync( $"SELECT 1 FROM pragma_table_info('{table}') WHERE name = '{column}' LIMIT 1")).HasValue; [Fact] public async Task PreV4File_GetsUniqueColumns_OnNextOpen() { await using (var sp = BuildServices(ConnectionString)) { var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await StagePreV4Async(sp.GetRequiredService()); } await using (var sp = BuildServices(ConnectionString)) { var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); var ctx = sp.GetRequiredService(); (await ColumnExistsAsync(ctx, "_values", "_unique")).Should().BeTrue(); (await ColumnExistsAsync(ctx, "_structures", "_unique")).Should().BeTrue(); (await ColumnExistsAsync(ctx, "_structures", "_unique_version")).Should().BeTrue(); (await ColumnExistsAsync(ctx, "_scheme_metadata_cache", "_unique")).Should().BeTrue(); (await ctx.ExecuteScalarAsync( "SELECT 1 FROM sqlite_master WHERE type = 'index' AND name = 'UIX__values__structure_unique'")) .Should().NotBeNull("the partial unique index rides the same step"); await AssertV4DdlAsync(ctx); (await ctx.ExecuteScalarAsync("PRAGMA user_version")).Should().BeGreaterThanOrEqualTo(2, "the pass stamps the file so the next open skips it"); } } /// /// Strips every V4 column and index the way a pre-V4 build never had them and stamps the old /// schema version: _values._unique, _structures._unique/_unique_version/_lazy, /// _scheme_metadata_cache._unique/_unique_version/_lazy, _objects._value_unique, two indexes. /// private static async Task StagePreV4Async(IRedbContext ctx) { await ctx.ExecuteAsync("DROP INDEX IF EXISTS \"UIX__values__structure_unique\""); await ctx.ExecuteAsync("DROP INDEX IF EXISTS \"UIX__objects__scheme_unique\""); foreach (var (table, column) in new[] { ("_values", "_unique"), ("_structures", "_unique"), ("_structures", "_unique_version"), ("_structures", "_lazy"), ("_scheme_metadata_cache", "_unique"), ("_scheme_metadata_cache", "_unique_version"), ("_scheme_metadata_cache", "_lazy"), ("_objects", "_value_unique"), }) { await ctx.ExecuteAsync($"ALTER TABLE {table} DROP COLUMN {column}"); } await ctx.ExecuteAsync("PRAGMA user_version = 1"); (await ColumnExistsAsync(ctx, "_values", "_unique")).Should().BeFalse("the pre-V4 state must be staged"); (await ColumnExistsAsync(ctx, "_structures", "_lazy")).Should().BeFalse(); } private static async Task AssertV4DdlAsync(IRedbContext ctx) { (await ColumnExistsAsync(ctx, "_structures", "_lazy")).Should().BeTrue("Л2 marker column"); (await ColumnExistsAsync(ctx, "_scheme_metadata_cache", "_lazy")).Should().BeTrue(); (await ColumnExistsAsync(ctx, "_scheme_metadata_cache", "_unique_version")).Should().BeTrue(); (await ColumnExistsAsync(ctx, "_objects", "_value_unique")).Should().BeTrue("Э1 key column"); (await ctx.ExecuteScalarAsync( "SELECT 1 FROM sqlite_master WHERE type = 'index' AND name = 'UIX__objects__scheme_unique'")) .Should().NotBeNull(); (await ctx.ExecuteScalarAsync("PRAGMA user_version")).Should().BeGreaterThan(1, "the pass stamps the schema version"); } [Fact] public async Task PreV4File_IsUpgraded_ByInitializeAsync_WithoutEnsureCreated() { await using (var sp = BuildServices(ConnectionString)) { await sp.GetRequiredService().InitializeAsync(ensureCreated: true); await StagePreV4Async(sp.GetRequiredService()); } // The plain start-up, the one PostgreSQL and MSSQL reach through the module block // "0. Schema upgrades": no EnsureDatabaseAsync, the upgrade pass must still run. await using (var sp = BuildServices(ConnectionString)) { await sp.GetRequiredService().InitializeAsync(); await AssertV4DdlAsync(sp.GetRequiredService()); } } public void Dispose() { Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools(); foreach (var suffix in new[] { "", "-wal", "-shm" }) { try { File.Delete(_dbPath + suffix); } catch { /* best effort */ } } } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteUnregisteredTreeTargetTests.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/Sqlite/SqliteUnregisteredTreeTargetTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteUnregisteredTreeTargetTests : UnregisteredTreeTargetTestsBase { public SqliteUnregisteredTreeTargetTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteUntypedLinkedObjectTests.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/Sqlite/SqliteUntypedLinkedObjectTests.cs ---- using redb.Core.Extensions; using redb.SQLite.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; public class SqliteUntypedLinkedObjectTests : UntypedLinkedObjectTestsBase { protected override void UseProvider(RedbOptionsBuilder options) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= Fixtures.SqliteTestSupport.ResolveNativeExtension(); // A fresh file per host. const string cs = "Data Source=redb_tests_untyped_linked_free.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteUserConfigurationServiceTests.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/Sqlite/SqliteUserConfigurationServiceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteUserConfigurationServiceTests : UserConfigurationServiceTestsBase { public SqliteUserConfigurationServiceTests(SqliteFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteValueIndexUpgradeTests.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/Sqlite/SqliteValueIndexUpgradeTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Data; using redb.Core.Extensions; using redb.SQLite.Data; using redb.SQLite.Extensions; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.Sqlite; /// /// Schema step 11 of ApplySchemaUpgradesAsync: a file of schema version 10 gets the value-leading /// indexes IX__values__structure_<value>_object and loses the object-leading *_not_null, /// ix__values__array_null_structure and the IX__values__scalar_*_object of SQLite Pro. An index of one of /// the new names with another definition is rebuilt. Staged the way the other upgrade tests stage it: /// create a current file, put the old indexes back, stamp version 10, reopen. /// public class SqliteValueIndexUpgradeTests : IDisposable { private readonly string _dbPath = Path.Combine(Path.GetTempPath(), $"redb_valueidx_{Guid.NewGuid():N}.db"); private static readonly string[] Columns = ["String", "Long", "Numeric", "Double", "DateTimeOffset", "Boolean", "Guid", "ListItem", "Object"]; private static readonly string[] Removed = [ "IX__values__String_not_null", "IX__values__Long_not_null", "IX__values__DateTimeOffset_not_null", "IX__values__Numeric_not_null", "ix__values__array_null_structure", "IX__values__scalar_String_object", "IX__values__scalar_Long_object", "IX__values__scalar_Numeric_object", "IX__values__scalar_DateTimeOffset_object", ]; private ServiceProvider BuildServices() { SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedb(options => options.UseSqlite($"Data Source={_dbPath}")); return services.BuildServiceProvider(); } private static Task IndexSqlAsync(IRedbContext ctx, string name) => ctx.ExecuteScalarAsync($"SELECT sql FROM sqlite_master WHERE type = 'index' AND name = '{name}'"); [Fact] public async Task Version10File_GetsValueLeadingIndexes_AndLosesTheOldOnes() { await using (var sp = BuildServices()) { await sp.GetRequiredService().InitializeAsync(ensureCreated: true); var ctx = sp.GetRequiredService(); foreach (var column in Columns) (await IndexSqlAsync(ctx, $"IX__values__structure_{column.ToLowerInvariant()}_object")) .Should().NotBeNull($"a new file is created with the {column} index"); // A version 10 file: the old indexes, one new name with the research definition, the stamp. await ctx.ExecuteAsync("DROP INDEX \"IX__values__structure_long_object\""); await ctx.ExecuteAsync("CREATE INDEX \"IX__values__structure_long_object\" ON _values (_id_structure, _Long, _id_object) WHERE _array_index IS NULL AND _Long IS NOT NULL"); await ctx.ExecuteAsync("DROP INDEX \"IX__values__structure_guid_object\""); await ctx.ExecuteAsync("CREATE INDEX \"IX__values__String_not_null\" ON _values (_id_structure, _id_object, _String) WHERE _String IS NOT NULL"); await ctx.ExecuteAsync("CREATE INDEX \"ix__values__array_null_structure\" ON _values (_id_structure, _id_object, _Long) WHERE _array_index IS NULL"); await ctx.ExecuteAsync("CREATE INDEX \"IX__values__scalar_Numeric_object\" ON _values (_id_structure, _Numeric, _id_object) WHERE _array_index IS NULL AND _Numeric IS NOT NULL"); await ctx.ExecuteAsync("PRAGMA user_version = 10"); } await using (var sp = BuildServices()) { await sp.GetRequiredService().InitializeAsync(); var ctx = sp.GetRequiredService(); foreach (var column in Columns) { var name = $"IX__values__structure_{column.ToLowerInvariant()}_object"; var sql = await IndexSqlAsync(ctx, name); sql.Should().NotBeNull($"step 11 builds {name}"); System.Text.RegularExpressions.Regex.Replace(sql!, @"\s+", " ") .Should().Contain($"ON _values (_id_structure, _{column}, _id_object, _array_index) WHERE _{column} IS NOT NULL", "an index of the same name with another definition is rebuilt"); } foreach (var name in Removed) (await IndexSqlAsync(ctx, name)).Should().BeNull($"step 11 drops {name}"); (await ctx.ExecuteScalarAsync("PRAGMA user_version")).Should().BeGreaterThanOrEqualTo(11); } } public void Dispose() { Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools(); foreach (var suffix in new[] { "", "-wal", "-shm" }) { try { File.Delete(_dbPath + suffix); } catch { /* best effort */ } } } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteValueOnlyObjectSaveTests.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/Sqlite/SqliteValueOnlyObjectSaveTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteValueOnlyObjectSaveTests : ValueOnlyObjectSaveTestsBase { public SqliteValueOnlyObjectSaveTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteValueUniqueTests.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/Sqlite/SqliteValueUniqueTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteValueUniqueTests : ValueUniqueTestsBase { public SqliteValueUniqueTests(SqliteFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } /// SQLite names only columns - the violated structure is not resolvable. protected override bool DriverReportsViolatedStructure => false; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteValuesFkIndexesTests.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/Sqlite/SqliteValuesFkIndexesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteValuesFkIndexesTests : ValuesFkIndexesTestsBase { public SqliteValuesFkIndexesTests(SqliteFixture fixture) : base(fixture.Redb) { } protected override async Task IndexExistsAsync(string indexName) => await Redb.Context.ExecuteScalarAsync( "SELECT COUNT(*) FROM sqlite_master WHERE type = 'index' AND name = '{0}'".Replace("{0}", indexName)) > 0; } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteWhereTests.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/Sqlite/SqliteWhereTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteWhereTests : WhereTestsBase { public SqliteWhereTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Sqlite/SqliteWindowTests.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/Sqlite/SqliteWindowTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.Sqlite; [Collection("Sqlite")] public class SqliteWindowTests : WindowTestsBase { public SqliteWindowTests(SqliteFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProAbsentFieldConsistencyTests.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/SqlitePro/SqliteProAbsentFieldConsistencyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProAbsentFieldConsistencyTests : AbsentFieldConsistencyTestsBase { public SqliteProAbsentFieldConsistencyTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProAbsentValuesTests.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/SqlitePro/SqliteProAbsentValuesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProAbsentValuesTests : AbsentValuesTestsBase { public SqliteProAbsentValuesTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProAggregatePathTests.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/SqlitePro/SqliteProAggregatePathTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProAggregatePathTests : AggregatePathTestsBase { public SqliteProAggregatePathTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProAggregatePreviewTests.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/SqlitePro/SqliteProAggregatePreviewTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProAggregatePreviewTests : ProAggregatePreviewTestsBase { public SqliteProAggregatePreviewTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProAggregationOverArrayTests.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/SqlitePro/SqliteProAggregationOverArrayTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProAggregationOverArrayTests : AggregationOverArrayTestsBase { public SqliteProAggregationOverArrayTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProAggregationTests.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/SqlitePro/SqliteProAggregationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProAggregationTests : AggregationTestsBase { public SqliteProAggregationTests(SqliteProFixture fixture) : base(fixture.Redb, isPro: true) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProAmbientTransactionTests.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/SqlitePro/SqliteProAmbientTransactionTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Data; using redb.SQLite.Data; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProAmbientTransactionTests : AmbientTransactionTestsBase { public SqliteProAmbientTransactionTests(SqliteProFixture fixture) : base(fixture.ServiceProvider) { } protected override string CreateProbeTableSql => "CREATE TABLE IF NOT EXISTS ambient_tx_rows (tag TEXT NOT NULL)"; // No sleep function in SQLite: a recursive count that runs for seconds. protected override string SlowStatementSql => "WITH RECURSIVE c(x) AS (SELECT 1 UNION ALL SELECT x + 1 FROM c WHERE x < 20000000) SELECT count(*) FROM c"; // Case folding, not lazy references: the lazy flag needs the native extension, the case folding functions do not. protected override IRedbConnection CreateStandaloneConnection(IServiceProvider services, bool differentSessionSettings) => new SqliteRedbConnection(SqliteDataSource.Create( services.GetService()?.ConnectionString ?? ConnString("Sqlite"), unicodeCaseFolding: differentSessionSettings, lazyReferences: false)); } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProAnalyticsTelemetryTests.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/SqlitePro/SqliteProAnalyticsTelemetryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProAnalyticsTelemetryTests : AnalyticsTelemetryTestsBase { public SqliteProAnalyticsTelemetryTests(SqliteProFixture fixture) : base(fixture.Redb) { } protected override int CommandsPerCall => 1; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProArrayAnyTests.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/SqlitePro/SqliteProArrayAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProArrayAnyTests : ArrayAnyTestsBase { public SqliteProArrayAnyTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProArrayGroupByDeepTests.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/SqlitePro/SqliteProArrayGroupByDeepTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProArrayGroupByDeepTests : ArrayGroupByDeepTestsBase { public SqliteProArrayGroupByDeepTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProArrayGroupMetadataCacheTests.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/SqlitePro/SqliteProArrayGroupMetadataCacheTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProArrayGroupMetadataCacheTests : ArrayGroupMetadataCacheTestsBase { public SqliteProArrayGroupMetadataCacheTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProArrayOfClassesAnyTests.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/SqlitePro/SqliteProArrayOfClassesAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProArrayOfClassesAnyTests : ArrayOfClassesAnyTestsBase { public SqliteProArrayOfClassesAnyTests(SqliteProFixture fixture) : base(fixture.Redb) { } protected override bool ReadsAnyOverClasses => true; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProArrayParentIndexTests.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/SqlitePro/SqliteProArrayParentIndexTests.cs ---- using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; namespace redb.Tests.Integration.Tests.SqlitePro; /// /// IX__values__array_parent_id is the leading column of IX__values__array_parent_index, which serves the same lookups and /// the ON DELETE CASCADE of FK__values__array_parent. A new file does not create it; schema step 17 drops it from an /// existing file only where a non-partial index led by _array_parent_id remains. The test owns its file and makes the /// steps run again by setting the stamp back, as an older file meets them. /// public class SqliteProArrayParentIndexTests { private const string Narrow = "IX__values__array_parent_id"; private const string Wide = "IX__values__array_parent_index"; private const string File = "redb_tests_array_parent_index_pro.db"; private const string Cs = "Data Source=" + File; [Fact] public async Task NarrowIndex_IsLeftOutOfANewFile_AndDroppedOnlyWhereTheWideOneExists() { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); await StartAsync(ensureCreated: true); (await IndexExistsAsync(Narrow)).Should().BeFalse("a new file does not create it"); (await IndexExistsAsync(Wide)).Should().BeTrue(); // An existing file stamped before step 17: both indexes. The step drops the narrow one. await ExecAsync($"CREATE INDEX \"{Narrow}\" ON _values (_array_parent_id)"); await ExecAsync("PRAGMA user_version = 16"); await StartAsync(ensureCreated: false); (await IndexExistsAsync(Narrow)).Should().BeFalse("the wider index serves its lookups and the cascade"); (await IndexExistsAsync(Wide)).Should().BeTrue(); // A file created by an old version without the wide index: the narrow one is the cascade's only index. await ExecAsync($"CREATE INDEX \"{Narrow}\" ON _values (_array_parent_id)"); await ExecAsync($"DROP INDEX \"{Wide}\""); await ExecAsync("PRAGMA user_version = 16"); await StartAsync(ensureCreated: false); (await IndexExistsAsync(Narrow)).Should().BeTrue("without a wider index the cascade keeps this one"); SqliteConnection.ClearAllPools(); Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); } private static async Task StartAsync(bool ensureCreated) { var services = new ServiceCollection(); services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => options.UseSqlite(Cs).Configure(c => c.EnablePropsCache = false)); await using var provider = services.BuildServiceProvider(); await provider.GetRequiredService().InitializeAsync(ensureCreated); SqliteConnection.ClearAllPools(); } private static async Task IndexExistsAsync(string name) { await using var conn = new SqliteConnection(Cs); await conn.OpenAsync(); await using var cmd = conn.CreateCommand(); cmd.CommandText = "SELECT COUNT(*) FROM sqlite_master WHERE type = 'index' AND name = $name"; cmd.Parameters.AddWithValue("$name", name); return (long)(await cmd.ExecuteScalarAsync())! > 0; } private static async Task ExecAsync(string sql) { await using var conn = new SqliteConnection(Cs); await conn.OpenAsync(); await using var cmd = conn.CreateCommand(); cmd.CommandText = sql; await cmd.ExecuteNonQueryAsync(); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProArrayTests.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/SqlitePro/SqliteProArrayTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProArrayTests : ArrayTestsBase { public SqliteProArrayTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProBareRedbObjectFieldTests.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/SqlitePro/SqliteProBareRedbObjectFieldTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProBareRedbObjectFieldTests : BareRedbObjectFieldTestsBase { public SqliteProBareRedbObjectFieldTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProBaseFieldNameCollisionTests.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/SqlitePro/SqliteProBaseFieldNameCollisionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProBaseFieldNameCollisionTests : BaseFieldNameCollisionTestsBase { public SqliteProBaseFieldNameCollisionTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProBugRegressionTests.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/SqlitePro/SqliteProBugRegressionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProBugRegressionTests : BugRegressionTestsBase { public SqliteProBugRegressionTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProBulkCreateAtomicityTests.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/SqlitePro/SqliteProBulkCreateAtomicityTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProBulkCreateAtomicityTests : BulkCreateAtomicityTestsBase { public SqliteProBulkCreateAtomicityTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProBytesRoundTripTests.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/SqlitePro/SqliteProBytesRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProBytesRoundTripTests : BytesRoundTripTestsBase { public SqliteProBytesRoundTripTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProCacheBehaviorTests.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/SqlitePro/SqliteProCacheBehaviorTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProCacheBehaviorTests : CacheBehaviorTestsBase { public SqliteProCacheBehaviorTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProCaseFoldingTests.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/SqlitePro/SqliteProCaseFoldingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; /// /// SQLite Pro, StringCollation set: the same expectations as the free SqliteCaseFoldingTests. Pro builds its SQL in C# /// but runs it on connections of the data source its registration creates. /// [Collection("SqliteProCollation")] public class SqliteProCaseFoldingTests : CaseFoldingTestsBase { public SqliteProCaseFoldingTests(SqliteProCollationFixture fixture) : base(fixture.Redb) { } // .NET ToLowerInvariant folds character by character, like ICU root. protected override bool FoldsSharpSToDoubleS => false; protected override bool FoldsTurkishDottedI => false; protected override bool PlainStartsWithIsCaseSensitive => false; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProColdSchemeLinkedObjectTests.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/SqlitePro/SqliteProColdSchemeLinkedObjectTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProColdSchemeLinkedObjectTests : ColdSchemeLinkedObjectTestsBase { private const string Cs = "Data Source=redb_tests_cold_scheme_pro.db"; private bool _prepared; protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { // A fresh file per test, shared by the writer and the reader host of that test. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProColdSchemeTreeFilterTests.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/SqlitePro/SqliteProColdSchemeTreeFilterTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProColdSchemeTreeFilterTests : ColdSchemeTreeFilterTestsBase { private const string Cs = "Data Source=redb_tests_cold_tree_pro.db"; private bool _prepared; protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { // A fresh file per test, shared by the writer and the reader host of that test. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProCollectionFilterAnalyticsTests.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/SqlitePro/SqliteProCollectionFilterAnalyticsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProCollectionFilterAnalyticsTests : CollectionFilterAnalyticsTestsBase { public SqliteProCollectionFilterAnalyticsTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProCollectionGroupKeyTests.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/SqlitePro/SqliteProCollectionGroupKeyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProCollectionGroupKeyTests : CollectionGroupKeyTestsBase { public SqliteProCollectionGroupKeyTests(SqliteProFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProCollectionKindChangeTests.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/SqlitePro/SqliteProCollectionKindChangeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProCollectionKindChangeTests : CollectionKindChangeTestsBase { public SqliteProCollectionKindChangeTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProComputedComparisonTests.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/SqlitePro/SqliteProComputedComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProComputedComparisonTests : ComputedComparisonTestsBase { public SqliteProComputedComparisonTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProConcurrentDeleteListTests.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/SqlitePro/SqliteProConcurrentDeleteListTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProConcurrentDeleteListTests : ConcurrentDeleteListTestsBase { private const string Cs = "Data Source=redb_tests_cdel_pro.db"; private bool _prepared; protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { // A fresh file per test, shared by every provider the test builds (its own and the writer's). Deleted per // provider, the file went away under the open connection of the first one wherever an open file can be // deleted (Linux), and the writer wrote into a new file the reader never saw. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProConcurrentWritersTests.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/SqlitePro/SqliteProConcurrentWritersTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProConcurrentWritersTests : ConcurrentWritersTestsBase { public SqliteProConcurrentWritersTests(SqliteProFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProConnectionLeaseTests.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/SqlitePro/SqliteProConnectionLeaseTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProConnectionLeaseTests : ConnectionLeaseTestsBase { public SqliteProConnectionLeaseTests(SqliteProFixture fixture) : base(fixture.ServiceProvider) { } protected override string CreateProbeTableSql => "CREATE TABLE IF NOT EXISTS connection_lease_rows (tag TEXT NOT NULL)"; protected override bool AmbientLeaseCarriesTransaction => true; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProConstantPredicateTests.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/SqlitePro/SqliteProConstantPredicateTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProConstantPredicateTests : ConstantPredicateTestsBase { public SqliteProConstantPredicateTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProCreateFailureTests.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/SqlitePro/SqliteProCreateFailureTests.cs ---- using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; namespace redb.Tests.Integration.Tests.SqlitePro; /// /// A creation script that fails in the middle (here on an object the file already holds under a name the script creates /// after the tables) must surface the error and leave no part of the schema behind: a file stamped as created with the /// tables before the failure and nothing after it reads as a valid redb file, and a second start took the upgrade path /// over it and reported success. Both attempts fail, and the file never holds _schemes or a schema version. /// public class SqliteProCreateFailureTests { private const string Cs = "Data Source=redb_tests_create_failure_pro.db"; // An index the creation script builds after the tables and before the seed rows. private const string NameTakenLater = "idx_metadata_cache_lookup"; [Fact] public async Task CreationFailingInTheMiddle_ThrowsAndLeavesNoSchema_OnEveryAttempt() { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); await using (var blocker = new SqliteConnection(Cs + ";Pooling=False")) { await blocker.OpenAsync(); await using var cmd = blocker.CreateCommand(); cmd.CommandText = $"CREATE TABLE {NameTakenLater}(x INTEGER)"; await cmd.ExecuteNonQueryAsync(); } for (var attempt = 1; attempt <= 2; attempt++) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => options.UseSqlite(Cs)); await using (var provider = services.BuildServiceProvider()) { var redb = provider.GetRequiredService(); var act = () => redb.InitializeAsync(ensureCreated: true); await act.Should().ThrowAsync($"attempt {attempt}: the failing statement must surface"); } SqliteConnection.ClearAllPools(); await using var check = new SqliteConnection(Cs + ";Pooling=False"); await check.OpenAsync(); await using var q = check.CreateCommand(); q.CommandText = "SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name = '_schemes'"; ((long)(await q.ExecuteScalarAsync())!).Should().Be(0, $"attempt {attempt}: no part of the schema stays"); q.CommandText = "PRAGMA user_version"; ((long)(await q.ExecuteScalarAsync())!).Should().Be(0, $"attempt {attempt}: the file is not stamped"); } } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProCrudTests.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/SqlitePro/SqliteProCrudTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProCrudTests : CrudTestsBase { public SqliteProCrudTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProCtPerfBenchmarkTests.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/SqlitePro/SqliteProCtPerfBenchmarkTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProCtPerfBenchmarkTests : CtPerfBenchmarkTestsBase { public SqliteProCtPerfBenchmarkTests(SqliteProFixture fixture) : base(fixture.Redb) { } protected override string ProviderName => "SqlitePro"; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProCtSaveInvariantsTests.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/SqlitePro/SqliteProCtSaveInvariantsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProCtSaveInvariantsTests : CtSaveInvariantsTestsBase { public SqliteProCtSaveInvariantsTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProDbInfoTests.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/SqlitePro/SqliteProDbInfoTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProDbInfoTests : DbInfoTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { const string cs = "Data Source=redb_tests_dbinfo_pro.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } protected override string VersionMarker => "3."; protected override string SizeInBytesSql => "SELECT page_count * page_size FROM pragma_page_count(), pragma_page_size()"; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProDecimalRoundTripTests.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/SqlitePro/SqliteProDecimalRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProDecimalRoundTripTests : DecimalRoundTripTestsBase { public SqliteProDecimalRoundTripTests(SqliteProFixture fixture) : base(fixture.Redb) { } protected override bool StoresDecimalAsDouble => true; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProDeleteBatchCountTests.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/SqlitePro/SqliteProDeleteBatchCountTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProDeleteBatchCountTests : DeleteBatchCountTestsBase { public SqliteProDeleteBatchCountTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProDeleteSubtreeCountTests.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/SqlitePro/SqliteProDeleteSubtreeCountTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProDeleteSubtreeCountTests : DeleteSubtreeCountTestsBase { private const string Cs = "Data Source=redb_tests_subc_pro.db"; private bool _prepared; protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { // A fresh file per test, shared by every provider the test builds (its own and the writer's). Deleted per // provider, the file went away under the open connection of the first one wherever an open file can be // deleted (Linux), and the writer wrote into a new file the reader never saw. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProDictionaryEntryKeyFilterTests.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/SqlitePro/SqliteProDictionaryEntryKeyFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProDictionaryEntryKeyFilterTests : DictionaryEntryKeyFilterTestsBase { public SqliteProDictionaryEntryKeyFilterTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProDictionaryEntryLeadsTests.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/SqlitePro/SqliteProDictionaryEntryLeadsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProDictionaryEntryLeadsTests : DictionaryEntryLeadsTestsBase { public SqliteProDictionaryEntryLeadsTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProDictionaryOrderTests.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/SqlitePro/SqliteProDictionaryOrderTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProDictionaryOrderTests : DictionaryOrderTestsBase { public SqliteProDictionaryOrderTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProDictionaryTests.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/SqlitePro/SqliteProDictionaryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProDictionaryTests : DictionaryTestsBase { public SqliteProDictionaryTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProDisposedScopeGuardTests.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/SqlitePro/SqliteProDisposedScopeGuardTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProDisposedScopeGuardTests : DisposedScopeGuardTestsBase { public SqliteProDisposedScopeGuardTests(SqliteProFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProElementFoldOrderTests.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/SqlitePro/SqliteProElementFoldOrderTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProElementFoldOrderTests : ElementFoldOrderTestsBase { public SqliteProElementFoldOrderTests(SqliteProFixture fixture) : base(fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProElementIndexFilterTests.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/SqlitePro/SqliteProElementIndexFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProElementIndexFilterTests : ElementIndexFilterTestsBase { public SqliteProElementIndexFilterTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProElementLeafProbeTests.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/SqlitePro/SqliteProElementLeafProbeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.SqlitePro; /// /// With the planner on, a page whose narrow condition is a Contains over an array of simple values reads the element rows /// of the value through the capped probe, as on PostgreSQL: fewer than the cap seed the streams, the cap reached keeps the /// form the query has without the probe. The answers are held equal to the other form by PvtPrefilterEquivalenceTestsBase. /// [Collection("SqlitePro")] public class SqliteProElementLeafProbeTests { private readonly redb.Core.IRedbService _redb; public SqliteProElementLeafProbeTests(SqliteProFixture fixture) => _redb = fixture.Redb; [Fact] public async Task Contains_IsProbedOnItsElementRows_UpToTheCap() { var restore = _redb.Configuration.EnablePvtPrefilter; try { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var sql = await _redb.Query().Where(e => e.Skills!.Contains("Azure")).Take(10).ToSqlStringAsync(); sql.Should().Contain("pvt_probe AS MATERIALIZED", "the element rows are probed:\n{0}", sql) .And.Contain("v._array_index IS NOT NULL LIMIT 5000", "up to the cap, on the element rows:\n{0}", sql); } finally { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProEnumComparisonTests.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/SqlitePro/SqliteProEnumComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProEnumComparisonTests : EnumComparisonTestsBase { public SqliteProEnumComparisonTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProEnumDictionaryKeyTests.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/SqlitePro/SqliteProEnumDictionaryKeyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProEnumDictionaryKeyTests : EnumDictionaryKeyTestsBase { public SqliteProEnumDictionaryKeyTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProExportMigrationHistoryTests.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/SqlitePro/SqliteProExportMigrationHistoryTests.cs ---- using System.Text.Json.Nodes; using AwesomeAssertions.Execution; using Microsoft.Data.Sqlite; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Attributes; using redb.Core.Data; using redb.Core.Models.Entities; using redb.Core.Pro.Extensions; using redb.Core.Pro.Migration; using redb.Core.Pro.Query; using redb.Export.Providers; using redb.Export.Services; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.SqlitePro; [RedbScheme("Export: migration history probe", Name = "export_migration_history_probe")] public class ExportMigrationHistoryProbeProps { public long Amount { get; set; } } [RedbScheme("Export: migration history second probe", Name = "export_migration_history_second_probe")] public class ExportMigrationHistorySecondProbeProps { public long Count { get; set; } } /// A migration that is not idempotent: run twice, it doubles twice. public class ExportMigrationHistoryDoubleMigration : IRedbMigration { public void Configure(IMigrationBuilder builder) { builder.Property(p => p.Amount).ComputedFrom(p => p.Amount * 2); } } /// A second migration that is not idempotent, on another scheme: run twice, it adds twice. public class ExportMigrationHistoryAddMigration : IRedbMigration { public void Configure(IMigrationBuilder builder) { builder.Property(p => p.Count).ComputedFrom(p => p.Count + 100); } } /// /// A database moved by export and import keeps the history of the data migrations applied to it. Without it, an /// application that runs its migrations at start applies every one of them again to values that already have them, /// and a migration that is not idempotent changes the data a second time. A file of an earlier version carries no /// history: it still imports, with a warning. Scratch files of its own, deleted afterwards. /// public class SqliteProExportMigrationHistoryTests : IAsyncLifetime { private const string HistorySql = "SELECT COUNT(*) FROM _migrations WHERE NOT _dry_run"; private const string HistoryMissingWarning = "does not carry the history of the data migrations"; private readonly List _databases = []; private readonly List _files = []; public Task InitializeAsync() => Task.CompletedTask; public Task DisposeAsync() { SqliteConnection.ClearAllPools(); foreach (var database in _databases) SqliteTestSupport.DeleteDbFiles(database); foreach (var file in _files) File.Delete(file); return Task.CompletedTask; } [Fact] public async Task AMigrationAppliedBeforeTheExport_IsNotAppliedAgain_AfterTheImport() { var source = NewDatabase("src"); long id; long sourceHistory; await using (var provider = Build(source)) { var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); id = await redb.SaveAsync(new RedbObject { name = "migrated", Props = new ExportMigrationHistoryProbeProps { Amount = 5 } }); var applied = await redb.MigrateAsync( provider.GetRequiredService()); applied.Should().OnlyContain(r => r.Success, "precondition: the migration ran on the source"); (await redb.LoadAsync(id))!.Props.Amount.Should().Be(10, "precondition"); sourceHistory = await redb.Context.ExecuteScalarAsync(HistorySql); sourceHistory.Should().BeGreaterThan(0, "precondition: the source holds the history of the migration"); } var file = await ExportAsync(source); var target = await ImportIntoNewDatabaseAsync(file); await using (var provider = Build(target)) { // What an application does at start: initialize, then run its migrations. var redb = provider.GetRequiredService(); await redb.InitializeAsync(); var targetHistory = await redb.Context.ExecuteScalarAsync(HistorySql); await redb.MigrateAsync( provider.GetRequiredService()); var amount = (await redb.LoadAsync(id))!.Props.Amount; using (new AssertionScope()) { targetHistory.Should().Be(sourceHistory, "the import carries the history of the applied migrations"); amount.Should().Be(10, "a migration applied before the export is not applied a second time"); } } } [Fact] public async Task TwoMigrationsOnTwoSchemes_RoundTrip_WithTheirHistory_AndNeitherRunsAgain() { var source = NewDatabase("two-src"); long first, second; List sourceRows; await using (var provider = Build(source)) { var redb = provider.GetRequiredService(); var dialect = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); await redb.SyncSchemeAsync(); first = await redb.SaveAsync(new RedbObject { name = "first", Props = new ExportMigrationHistoryProbeProps { Amount = 5 } }); second = await redb.SaveAsync(new RedbObject { name = "second", Props = new ExportMigrationHistorySecondProbeProps { Count = 1 } }); (await redb.MigrateAsync(dialect)) .Should().OnlyContain(r => r.Success, "precondition"); (await redb.MigrateAsync(dialect)) .Should().OnlyContain(r => r.Success, "precondition"); sourceRows = await HistoryRowsAsync(source); sourceRows.Should().HaveCountGreaterThanOrEqualTo(2, "precondition: one history row per scheme at least"); } var file = await ExportAsync(source); var (target, output) = await CapturedAsync(() => ImportIntoNewDatabaseAsync(file)); (await HistoryRowsAsync(target)).Should().Equal(sourceRows, "every history row arrives as it was"); output.Should().NotContain(HistoryMissingWarning, "the file carries the history"); await using (var provider = Build(target)) { var redb = provider.GetRequiredService(); var dialect = provider.GetRequiredService(); await redb.InitializeAsync(); await redb.MigrateAsync(dialect); await redb.MigrateAsync(dialect); using (new AssertionScope()) { (await redb.LoadAsync(first))!.Props.Amount.Should().Be(10); (await redb.LoadAsync(second))!.Props.Count.Should().Be(101); } } } [Fact] public async Task AFileOfAnEarlierVersion_WithoutTheHistory_Imports_AndWarnsThatTheHistoryIsMissing() { var source = NewDatabase("old-src"); await using (var provider = Build(source)) { var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); await redb.SaveAsync(new RedbObject { name = "migrated", Props = new ExportMigrationHistoryProbeProps { Amount = 5 } }); await redb.MigrateAsync( provider.GetRequiredService()); } var file = await ExportAsync(source); WriteAsEarlierVersion(file); var (target, output) = await CapturedAsync(() => ImportIntoNewDatabaseAsync(file)); using (new AssertionScope()) { output.Should().Contain("Import completed successfully").And.Contain(HistoryMissingWarning); (await ScalarAsync(target, HistorySql)).Should().Be("0", "the file had no history to carry"); (await ScalarAsync(target, "SELECT COUNT(*) FROM _objects")).Should().NotBe("0", "the data arrived"); } } [Fact] public async Task ADatabaseWithoutMigrations_ExportsNoHistory_AndImportsWithAndWithoutTheNewRecords() { var source = NewDatabase("plain-src"); await using (var provider = Build(source)) { var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); await redb.SaveAsync(new RedbObject { name = "plain", Props = new ExportMigrationHistoryProbeProps { Amount = 5 } }); } var file = await ExportAsync(source); var lines = File.ReadAllLines(file); lines.Should().NotContain(l => l.Contains("\"type\":\"migration\""), "a database that never ran a migration has no history"); JsonNode.Parse(lines[^1])!["total_migrations"]!.GetValue().Should().Be(0); var (target, output) = await CapturedAsync(() => ImportIntoNewDatabaseAsync(file)); output.Should().NotContain(HistoryMissingWarning, "the file says it carries the history, and it is empty"); (await ScalarAsync(target, "SELECT COUNT(*) FROM _objects")).Should().NotBe("0"); WriteAsEarlierVersion(file); var earlier = await ImportIntoNewDatabaseAsync(file); (await ScalarAsync(earlier, "SELECT COUNT(*) FROM _objects")).Should().NotBe("0", "a file of an earlier version imports as before"); } /// Makes the file what an earlier version wrote: no migration records, no migration total. private static void WriteAsEarlierVersion(string file) { var lines = File.ReadAllLines(file).Where(l => !l.Contains("\"type\":\"migration\"")).ToList(); var footer = JsonNode.Parse(lines[^1])!.AsObject(); footer.Remove("total_migrations"); lines[^1] = footer.ToJsonString(); File.WriteAllLines(file, lines); } private async Task ExportAsync(string source) { var file = NewFile(); await using var exporting = ProviderFactory.Create("sqlite"); await exporting.OpenAsync(source); await new ExportService(exporting, verbose: false, batchSize: 1000).ExportAsync(file, null, compress: false, dryRun: false); return file; } /// A newly created database, the file imported into it with --clean. private async Task ImportIntoNewDatabaseAsync(string file) { var target = NewDatabase("dst"); await using (var provider = Build(target)) await provider.GetRequiredService().InitializeAsync(ensureCreated: true); await using (var importing = ProviderFactory.Create("sqlite")) { await importing.OpenAsync(target); await new ImportService(importing, verbose: false, batchSize: 1000, parallelism: 1) .ImportAsync(file, clean: true, dryRun: false); } RedbKeyGeneratorBase.ClearAllCaches(); return target; } private static async Task> HistoryRowsAsync(string cs) { var rows = new List(); await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = "SELECT _id, _migration_id, _scheme_id, IFNULL(_structure_id, ''), IFNULL(_property_name, ''), " + "IFNULL(_expression_hash, ''), _migration_type, _applied_at, IFNULL(_applied_by, ''), " + "IFNULL(_affected_rows, ''), _dry_run FROM _migrations ORDER BY _id"; await using var reader = await command.ExecuteReaderAsync(); while (await reader.ReadAsync()) rows.Add(string.Join("|", Enumerable.Range(0, reader.FieldCount).Select(i => Convert.ToString(reader.GetValue(i), System.Globalization.CultureInfo.InvariantCulture)))); return rows; } private static async Task ScalarAsync(string cs, string sql) { await using var connection = new SqliteConnection(cs); await connection.OpenAsync(); await using var command = connection.CreateCommand(); command.CommandText = sql; return Convert.ToString(await command.ExecuteScalarAsync(), System.Globalization.CultureInfo.InvariantCulture); } private static async Task<(T Result, string Output)> CapturedAsync(Func> run) { var console = Console.Out; var output = new StringWriter(); Console.SetOut(output); try { return (await run(), output.ToString()); } finally { Console.SetOut(console); } } private string NewDatabase(string suffix) { global::redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var cs = $"Data Source=redb_tests_export_migrations_{suffix}_{Guid.NewGuid():N}.db"; SqliteTestSupport.DeleteDbFiles(cs); _databases.Add(cs); return cs; } private string NewFile() { var file = Path.Combine(Path.GetTempPath(), $"redb-export-migrations-{Guid.NewGuid():N}.redb"); _files.Add(file); return file; } private static ServiceProvider Build(string cs) { var license = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build()["Redb:License"]; var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => { options.UseSqlite(cs).Configure(c => c.CacheDomain = $"export-migrations-{Guid.NewGuid():N}"); if (!string.IsNullOrWhiteSpace(license)) options.WithLicense(license); }); return services.BuildServiceProvider(); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProFieldNamedLikeAFunctionTests.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/SqlitePro/SqliteProFieldNamedLikeAFunctionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProFieldNamedLikeAFunctionTests : FieldNamedLikeAFunctionTestsBase { public SqliteProFieldNamedLikeAFunctionTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProFilterFieldPathTests.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/SqlitePro/SqliteProFilterFieldPathTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProFilterFieldPathTests : FilterFieldPathTestsBase { public SqliteProFilterFieldPathTests(SqliteProFixture fixture) : base(fixture.Redb) { } protected override bool ReadsElementsByIndex => true; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProGroupByHavingTests.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/SqlitePro/SqliteProGroupByHavingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProGroupByHavingTests : GroupByHavingTestsBase { public SqliteProGroupByHavingTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProGroupBySelectShapesTests.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/SqlitePro/SqliteProGroupBySelectShapesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProGroupBySelectShapesTests : GroupBySelectShapesTestsBase { public SqliteProGroupBySelectShapesTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProGroupByTests.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/SqlitePro/SqliteProGroupByTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProGroupByTests : GroupByTestsBase { public SqliteProGroupByTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProHashCanonCollisionTests.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/SqlitePro/SqliteProHashCanonCollisionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProHashCanonCollisionTests : HashCanonCollisionTestsBase { public SqliteProHashCanonCollisionTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProHashCanonHeaderCacheTests.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/SqlitePro/SqliteProHashCanonHeaderCacheTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Models.Entities; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.SqlitePro; /// /// The props cache serves an entry while its hash equals the stored one, and the hash covers the object header. Two /// nodes (two cache domains on one database): node B changes the header so that the joined header canon stays the same /// string ('|' inside a name); node A must not keep serving the old header from its cache. /// public class SqliteProHashCanonHeaderCacheTests { private const string Cs = "Data Source=redb_tests_hashcanon_header_pro.db"; private static ServiceProvider Build(string domain) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => { options.UseSqlite(Cs); options.Configure(c => { c.EnablePropsCache = true; c.SkipHashValidationOnCacheCheck = false; c.CacheDomain = $"hash-canon-header-{domain}"; }); }); return services.BuildServiceProvider(); } [Fact] public async Task HeaderChangeWithTheSameJoinedCanon_IsSeenByAnotherNode() { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); await using var nodeA = Build("a"); await using var nodeB = Build("b"); var a = nodeA.GetRequiredService(); var b = nodeB.GetRequiredService(); await a.InitializeAsync(ensureCreated: true); await b.InitializeAsync(); await a.SyncSchemeAsync(); await b.SyncSchemeAsync(); var id = await a.SaveAsync(new RedbObject { name = "x|y", note = "", Props = new SimpleProps { Title = "p" } }); (await a.LoadAsync(id))!.name.Should().Be("x|y", "precondition: node A has the object in its cache"); var onB = (await b.LoadAsync(id))!; onB.name = "x"; onB.note = "y|"; await b.SaveAsync(onB); var onA = (await a.LoadAsync(id))!; onA.name.Should().Be("x"); onA.note.Should().Be("y|"); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProIgnoredPropertyWalkTests.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/SqlitePro/SqliteProIgnoredPropertyWalkTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProIgnoredPropertyWalkTests : IgnoredPropertyWalkTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { // A fresh file per host. const string cs = "Data Source=redb_tests_ignored_walk_pro.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProIndexCatalogTests.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/SqlitePro/SqliteProIndexCatalogTests.cs ---- using Microsoft.Data.Sqlite; using Microsoft.Extensions.DependencyInjection; using redb.Core.Data; using redb.Core.Extensions; using redb.Core.Models; using redb.Core.Models.Configuration; using redb.SQLite.Data; using redb.SQLite.Extensions; using redb.SQLite.Sql; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; /// SqliteProIndexCatalog.Pro (the Pro module indexes) against a fresh SQLite Pro file of this build (see ). public class SqliteProIndexCatalogTests : IndexCatalogTestsBase { private readonly Dictionary _files = new(); protected override Task CreateDatabaseAsync(string name) { SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var path = Path.Combine(Path.GetTempPath(), name + ".db"); _files[name] = path; return Task.FromResult($"Data Source={path}"); } protected override Task DropDatabaseAsync(string name) { SqliteConnection.ClearAllPools(); if (_files.TryGetValue(name, out var path)) foreach (var file in new[] { path, path + "-wal", path + "-shm" }) { try { if (File.Exists(file)) File.Delete(file); } catch (IOException) { } } return Task.CompletedTask; } protected override void AddRedb(IServiceCollection services, string connectionString, Action configure) => redb.Core.Pro.Extensions.RedbProServiceCollectionExtensions.AddRedbPro(services, o => redb.SQLite.Pro.Extensions.SqliteProOptionsExtensions.UseSqlite(o, connectionString).Configure(configure)); protected override async Task> ReadCreateStatementsAsync(IRedbContext context) { var rows = await context.QueryAsync("SELECT name AS \"Name\", sql AS \"Sql\" FROM sqlite_master WHERE type = 'index' AND sql IS NOT NULL"); return rows.ToDictionary(r => r.Name!, r => r.Sql!, StringComparer.OrdinalIgnoreCase); } protected override IReadOnlyList Catalog => redb.SQLite.Pro.Sql.SqliteProIndexCatalog.Pro; protected override IReadOnlyList CoveredElsewhere => SqliteIndexCatalog.Base; protected override (string File, string Namespace, string Class, string Member, RedbIndexOrigin Origin) Target => ("redb.SQLite.Pro/Sql/SqliteProIndexCatalog.g.cs", "redb.SQLite.Pro.Sql", "SqliteProIndexCatalog", "Pro", RedbIndexOrigin.ProModule); private sealed class SqlRow { public string? Name { get; set; } public string? Sql { get; set; } } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProIndexRepairTests.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/SqlitePro/SqliteProIndexRepairTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Models.Configuration; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Sqlite; namespace redb.Tests.Integration.Tests.SqlitePro; /// /// The index check and its repair on a SQLite file with Pro: the base indexes and the module indexes in use, see /// . /// public class SqliteProIndexRepairTests : SqliteIndexRepairTests { protected override void AddRedb(IServiceCollection services, string connectionString, Action configure) => services.AddRedbPro(o => o.UseSqlite(connectionString).Configure(configure)); } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProIndexerPropsTests.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/SqlitePro/SqliteProIndexerPropsTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Attributes; using redb.Core.Models.Entities; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; namespace redb.Tests.Integration.Tests.SqlitePro; /// A class with an indexer, used as a nested Props class. public class IndexedPart { private readonly Dictionary _extra = new(); public string? Code { get; set; } public string this[string key] { get => _extra.TryGetValue(key, out var v) ? v : ""; set => _extra[key] = value; } } [RedbScheme("Save: props with an indexer", Name = "props_indexer_probe")] public class PropsWithIndexer { private readonly Dictionary _extra = new(); public string? Title { get; set; } public IndexedPart? Part { get; set; } public string this[string key] { get => _extra.TryGetValue(key, out var v) ? v : ""; set => _extra[key] = value; } } /// /// An indexer is not a field: the scheme sync and the value writer skip it. The object hash called its getter without /// an index and the save failed with , so a Props class /// with an indexer (at the top or in a nested class) could not be saved at all. It saves its properties; the indexer /// is not stored. /// public class SqliteProIndexerPropsTests { private const string Cs = "Data Source=redb_tests_props_indexer_pro.db"; [Fact] public async Task PropsClassWithAnIndexer_SavesItsProperties_AndTheIndexerIsNotStored() { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => options.UseSqlite(Cs)); await using var provider = services.BuildServiceProvider(); var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); var props = new PropsWithIndexer { Title = "t", Part = new IndexedPart { Code = "c" } }; props["a"] = "x"; props.Part["b"] = "y"; var id = await redb.SaveAsync(new RedbObject { name = "i", Props = props }); var loaded = await redb.LoadAsync(id); loaded.Should().NotBeNull(); loaded!.Props.Title.Should().Be("t"); loaded.Props.Part!.Code.Should().Be("c"); loaded.Props["a"].Should().BeEmpty("an indexer is not a field and is not stored"); loaded.Props.Part["b"].Should().BeEmpty(); loaded.Props.Title = "t2"; (await redb.SaveAsync(loaded)).Should().Be(id); (await redb.LoadAsync(id))!.Props.Title.Should().Be("t2"); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProIntegerAverageTests.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/SqlitePro/SqliteProIntegerAverageTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProIntegerAverageTests : IntegerAverageTestsBase { public SqliteProIntegerAverageTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProInterfaceCollectionsTests.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/SqlitePro/SqliteProInterfaceCollectionsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProInterfaceCollectionsTests : InterfaceCollectionsTestsBase { public SqliteProInterfaceCollectionsTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProKeyDrawTests.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/SqlitePro/SqliteProKeyDrawTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProKeyDrawTests : KeyDrawTestsBase { public SqliteProKeyDrawTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProKeywordNamesTests.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/SqlitePro/SqliteProKeywordNamesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProKeywordNamesTests : KeywordNamesTestsBase { public SqliteProKeywordNamesTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProLazyHostTests.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/SqlitePro/SqliteProLazyHostTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProLazyHostTests : LazyHostTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { const string cs = "Data Source=redb_tests_lazyhost_pro.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } protected override string ReadFlagSql => "SELECT redb_lazy_refs()"; /// The Pro materializer reads the global option live; its registrations do not arm the session flag. protected override bool SessionFlagIsTheChannel => false; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProLazyReferenceTests.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/SqlitePro/SqliteProLazyReferenceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProLazyReferenceTests : LazyReferenceTestsBase { public SqliteProLazyReferenceTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProLazyReferencesOptionTests.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/SqlitePro/SqliteProLazyReferencesOptionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProLazyReferencesOptionTests : LazyReferencesOptionTestsBase { public SqliteProLazyReferencesOptionTests(SqliteProFixture fixture) : base(fixture.Redb) { } // Л2 boundary: the Pro materializer reads the global option, not the session flag. protected override bool PerQueryOverrideWorks => false; protected override bool GlobalMutationAffects => true; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProLikeEscapingTests.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/SqlitePro/SqliteProLikeEscapingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProLikeEscapingTests : LikeEscapingTestsBase { public SqliteProLikeEscapingTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProListItemArrayAnyTests.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/SqlitePro/SqliteProListItemArrayAnyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProListItemArrayAnyTests : ListItemArrayAnyTestsBase { public SqliteProListItemArrayAnyTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProListItemObjectWalkTests.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/SqlitePro/SqliteProListItemObjectWalkTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProListItemObjectWalkTests : ListItemObjectWalkTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { // A fresh file per host; Pro SQLite runs without the Free native extension. const string cs = "Data Source=redb_tests_listitem_walk_pro.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProListReadPropsOnceTests.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/SqlitePro/SqliteProListReadPropsOnceTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProListReadPropsOnceTests : ListReadPropsOnceTestsBase { private const string Cs = "Data Source=redb_tests_once_pro.db"; private bool _prepared; protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { // A fresh file per test, shared by every provider the test builds (its own and the writer's). Deleted per // provider, the file went away under the open connection of the first one wherever an open file can be // deleted (Linux), and the writer wrote into a new file the reader never saw. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProListRoundTripsTests.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/SqlitePro/SqliteProListRoundTripsTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; /// /// SQLite is in-process: its list keeps the separate read of the scheme hash (no network round trip to save), so a list /// call is the list, the values and the hash; the scheme change made by another process is seen all the same. /// public class SqliteProListRoundTripsTests : ListRoundTripsTestsBase { private const string Cs = "Data Source=redb_tests_list_round_trips_pro.db"; private bool _prepared; protected override int ListCommands => 3; protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { // A fresh file per test, shared by the writer and the reader host of that test. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProListTests.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/SqlitePro/SqliteProListTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProListTests : ListTestsBase { public SqliteProListTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProLiteralStructureIdsTests.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/SqlitePro/SqliteProLiteralStructureIdsTests.cs ---- using redb.Core.Query; using redb.Core.Query.Aggregation; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProLiteralStructureIdsTests : LiteralStructureIdsTestsBase { public SqliteProLiteralStructureIdsTests(SqliteProFixture fixture) : base(fixture.Redb) { } /// /// An aggregate over value rows lists its structures as a row list, IN (VALUES (id), ...): with a bare literal list /// SQLite drove the non-covering IX__values__structures and read every row of the structures with a table lookup each /// (Sum and Average of the first element of an array over 100 000 objects: 255 ms -> 420 ms); with the row list the /// objects of the scheme drive. The ids stay in the text. /// [Fact] public async Task AggregateOverValueRows_ListsItsStructuresAsRows() { await Redb.SyncSchemeAsync(); var sql = await Redb.Query() .ToAggregateSqlStringAsync(x => new { Sum = Agg.Sum(x.Props.SkillLevels![0]), Avg = Agg.Average(x.Props.SkillLevels![0]) }); sql.Should().MatchRegex(@"WHERE v\._id_structure IN \(VALUES \(\d+\)(, \(\d+\))*\)", "the structures go in as a row list"); sql.Should().NotMatchRegex(@"WHERE v\._id_structure IN \(\d", "a bare literal list lets SQLite drive the structures index"); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProLongBaseFilterTests.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/SqlitePro/SqliteProLongBaseFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProLongBaseFilterTests : LongBaseFilterTestsBase { public SqliteProLongBaseFilterTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProMaintenanceTests.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/SqlitePro/SqliteProMaintenanceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProMaintenanceTests : MaintenanceTestsBase { public SqliteProMaintenanceTests(SqliteProFixture fixture) : base(fixture.Redb) { } // e_sqlite3 may or may not compile dbstat in; the base falls back to the size-less form. protected override bool ReportsSizes => false; protected override bool HasSchemas => false; protected override bool ReportsUsageCounters => false; protected override bool ReportsAnalyzeTime => false; // INTEGER PRIMARY KEY is the rowid itself: SQLite creates no index object for it. protected override bool ReportsPrimaryKeyIndexes => false; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProMaterializationFidelityTests.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/SqlitePro/SqliteProMaterializationFidelityTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProMaterializationFidelityTests : MaterializationFidelityTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { const string cs = "Data Source=redb_tests_fidelity_pro.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProMaterializerConversionTests.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/SqlitePro/SqliteProMaterializerConversionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProMaterializerConversionTests : ProMaterializerConversionTestsBase { public SqliteProMaterializerConversionTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProMigrationAtomicityTests.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/SqlitePro/SqliteProMigrationAtomicityTests.cs ---- using AwesomeAssertions.Execution; using Microsoft.Extensions.DependencyInjection; using redb.Core; using redb.Core.Attributes; using redb.Core.Models.Entities; using redb.Core.Pro.Migration; using redb.Core.Pro.Query; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.SqlitePro; [RedbScheme("Migrations: atomicity probe", Name = "migration_atomicity_probe")] public class MigrationAtomicityProbeProps { public long Amount { get; set; } } /// A migration that is not idempotent: run twice, it doubles twice. public class MigrationDoubleAmountMigration : IRedbMigration { public void Configure(IMigrationBuilder builder) { builder.Property(p => p.Amount).ComputedFrom(p => p.Amount * 2); } } /// /// A migration's UPDATE of the values and its row in _migrations are one unit, and a failure comes back as /// Success = false. When the history insert fails after the UPDATE, the values must stay as they were, or the /// next run applies a non-idempotent computation a second time. The failure between the two is a trigger on /// _migrations for the probe scheme only. /// [Collection("SqlitePro")] public class SqliteProMigrationAtomicityTests { private readonly IRedbService _redb; private readonly ISqlDialectPro _dialect; public SqliteProMigrationAtomicityTests(SqliteProFixture fixture) { _redb = fixture.Redb; _dialect = fixture.ServiceProvider.GetRequiredService(); } private const string Trigger = "tr_test_migration_history_fails"; [Fact] public async Task HistoryInsertFails_AfterTheUpdate_TheRerunDoesNotApplyTheTransformTwice() { var (schemeId, id) = await SeedAsync("migration-atomicity"); await CreateFailingTriggerAsync(schemeId); List first; try { first = await _redb.MigrateAsync(_dialect); } finally { await _redb.Context.ExecuteAsync($"DROP TRIGGER IF EXISTS {Trigger}"); } first.Should().ContainSingle(r => !r.Success && r.Error!.Contains("injected"), "precondition: the run failed at the history insert"); var afterFailure = (await _redb.LoadAsync(id))!.Props.Amount; var second = await _redb.MigrateAsync(_dialect); second.Should().OnlyContain(r => r.Success); var afterRerun = (await _redb.LoadAsync(id))!.Props.Amount; using (new AssertionScope()) { afterFailure.Should().Be(5, "a migration that failed changed nothing"); afterRerun.Should().Be(10, "the transform is applied once, by the run that succeeded"); } } [Fact] public async Task HistoryInsertFails_InACallerTransaction_TheTransactionStaysUsableAndNothingIsApplied() { var (schemeId, id) = await SeedAsync("migration-atomicity-caller"); await CreateFailingTriggerAsync(schemeId); List first; try { await using var tx = await _redb.Context.BeginTransactionAsync(); first = await _redb.MigrateAsync(_dialect); await _redb.Context.ExecuteAsync($"UPDATE _objects SET _name = 'written-after-the-failure' WHERE _id = {id}"); await tx.CommitAsync(); } finally { await _redb.Context.ExecuteAsync($"DROP TRIGGER IF EXISTS {Trigger}"); } first.Should().ContainSingle(r => !r.Success && r.Error!.Contains("injected"), "precondition: the run failed at the history insert"); var loaded = (await _redb.LoadAsync(id))!; var history = await _redb.Context.ExecuteScalarAsync($"SELECT COUNT(*) FROM _migrations WHERE _scheme_id = {schemeId}"); using (new AssertionScope()) { loaded.name.Should().Be("written-after-the-failure", "the caller's transaction stayed usable and committed"); loaded.Props.Amount.Should().Be(5, "the failed migration changed nothing inside the caller's transaction"); history.Should().Be(0, "the failed migration left no history row"); } } private async Task<(long SchemeId, long Id)> SeedAsync(string name) { var scheme = await _redb.SyncSchemeAsync(); await _redb.Context.ExecuteAsync($"DELETE FROM _migrations WHERE _scheme_id = {scheme.Id}"); await _redb.Context.ExecuteAsync($"DELETE FROM _objects WHERE _id_scheme = {scheme.Id}"); var id = await _redb.SaveAsync(new RedbObject { name = name, Props = new MigrationAtomicityProbeProps { Amount = 5 } }); return (scheme.Id, id); } private Task CreateFailingTriggerAsync(long schemeId) => _redb.Context.ExecuteAsync( $"CREATE TRIGGER {Trigger} BEFORE INSERT ON _migrations WHEN NEW._scheme_id = {schemeId} " + "BEGIN SELECT RAISE(ABORT, 'injected: history insert fails'); END"); } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProMigrationPropsCacheTests.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/SqlitePro/SqliteProMigrationPropsCacheTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Models.Entities; using redb.Core.Pro.Extensions; using redb.Core.Pro.Migration; using redb.Core.Pro.Query; using redb.SQLite.Pro.Extensions; namespace redb.Tests.Integration.Tests.SqlitePro; /// /// A Pro migration changes values in the database and leaves the object row as it was. The props cache serves an /// entry while the stored object hash equals the cached one, so a process that cached the object before the migration /// must not keep serving the values from before it. /// public class SqliteProMigrationPropsCacheTests { private const string Cs = "Data Source=redb_tests_migration_props_cache_pro.db"; private static ServiceProvider Build(string node = "a") { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => { options.UseSqlite(Cs); options.Configure(c => { c.EnablePropsCache = true; c.SkipHashValidationOnCacheCheck = false; c.CacheDomain = $"migration-props-cache-{node}"; }); }); return services.BuildServiceProvider(); } [Fact] public async Task ObjectCachedBeforeAMigration_IsLoadedWithTheMigratedValues() { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); await using var provider = Build(); var redb = provider.GetRequiredService(); var dialect = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); var id = await redb.SaveAsync(new RedbObject { name = "cached-before-migration", Props = new MigrationAtomicityProbeProps { Amount = 5 } }); (await redb.LoadAsync(id))!.Props.Amount .Should().Be(5, "precondition: the object is loaded, so it is in the props cache"); var results = await redb.MigrateAsync(dialect); results.Should().OnlyContain(r => r.Success, "precondition: the migration applied"); var stored = await redb.Context.ExecuteScalarAsync( $"SELECT v._Long FROM _values v JOIN _structures s ON s._id = v._id_structure " + $"WHERE v._id_object = {id} AND s._name = 'Amount'"); stored.Should().Be(10, "precondition: the database holds the migrated value"); (await redb.LoadAsync(id))!.Props.Amount .Should().Be(10, "the database holds 10 after the migration; the cache must not serve the value from before it"); } [Fact] public async Task ObjectCachedByAnotherProcessBeforeAMigration_IsLoadedThereWithTheMigratedValues() { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); await using var migrating = Build("migrating"); await using var other = Build("other"); var redb = migrating.GetRequiredService(); var otherRedb = other.GetRequiredService(); var dialect = migrating.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await otherRedb.InitializeAsync(); await redb.SyncSchemeAsync(); await otherRedb.SyncSchemeAsync(); var id = await redb.SaveAsync(new RedbObject { name = "cached-elsewhere", Props = new MigrationAtomicityProbeProps { Amount = 5 } }); (await otherRedb.LoadAsync(id))!.Props.Amount .Should().Be(5, "precondition: the other process has the object in its props cache"); var results = await redb.MigrateAsync(dialect); results.Should().OnlyContain(r => r.Success, "precondition: the migration applied"); (await otherRedb.LoadAsync(id))!.Props.Amount .Should().Be(10, "the other process validates its cache by the stored object hash, which the migration cleared"); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProMigrationTargetAddressingTests.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/SqlitePro/SqliteProMigrationTargetAddressingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProMigrationTargetAddressingTests : MigrationTargetAddressingTestsBase { public SqliteProMigrationTargetAddressingTests(SqliteProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProMigrationTests.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/SqlitePro/SqliteProMigrationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProMigrationTests : MigrationTestsBase { public SqliteProMigrationTests(SqliteProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProMigrationTransformArithmeticTests.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/SqlitePro/SqliteProMigrationTransformArithmeticTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProMigrationTransformArithmeticTests : MigrationTransformArithmeticTestsBase { public SqliteProMigrationTransformArithmeticTests(SqliteProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProModuleUnloadTests.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/SqlitePro/SqliteProModuleUnloadTests.cs ---- using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Loader; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Interception; using redb.Core.Models.Configuration; using redb.Core.Models.Contracts; using redb.Core.Models.Entities; using redb.Core.Pro.Extensions; using redb.SQLite.Data; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.SqlitePro; /// /// A module of Tsak, end to end: its Props type and its save interceptor come from a collectible AssemblyLoadContext, /// it syncs its scheme, saves, loads through the props cache, subscribes to the interceptor registry, deletes and /// unsubscribes; then the context unloads while the host's redb service lives on. Nothing of redb may keep the /// context alive. /// [Collection("SqlitePro")] public class SqliteProModuleUnloadTests { public SqliteProModuleUnloadTests(SqliteProFixture _) { } // A database of its own, created by the test: the "Sqlite" connection string it used is the file of the Free // collection, which had a schema only when that collection, or a previous run, made it. private const string Cs = "Data Source=redb_tests_module_unload.db"; private static ServiceProvider BuildHost() { var cs = Cs; SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => { options.UseSqlite(cs); options.Configure(c => { c.PropsSaveStrategy = PropsSaveStrategy.ChangeTracking; c.EnablePropsCache = true; c.CacheDomain = "module-unload"; }); }); return services.BuildServiceProvider(); } private static MethodInfo ServiceMethod(string name, int genericArity, params Type[] parameters) => new[] { typeof(IRedbService) }.Concat(typeof(IRedbService).GetInterfaces()) .SelectMany(i => i.GetMethods()) .First(m => m.Name == name && (m.IsGenericMethodDefinition ? m.GetGenericArguments().Length : 0) == genericArity && m.GetParameters().Select(p => p.ParameterType.IsGenericParameter ? typeof(object) : p.ParameterType) .SequenceEqual(parameters)); private static async Task Await(object task) { await (Task)task; return task.GetType().GetProperty("Result")?.GetValue(task); } // Everything that touches a type of the module runs here, so no local of the test method keeps it. [MethodImpl(MethodImplOptions.NoInlining)] private static async Task<(WeakReference Context, int Saved, int Deleted)> RunModuleAndUnload(IServiceProvider host) { var context = new AssemblyLoadContext("module-unload", isCollectible: true); var assembly = context.LoadFromAssemblyPath(typeof(ModuleUnloadProps).Assembly.Location); var propsType = assembly.GetType(typeof(ModuleUnloadProps).FullName!)!; var interceptorType = assembly.GetType(typeof(ModuleUnloadInterceptor).FullName!)!; var redb = host.GetRequiredService(); var registry = host.GetRequiredService(); var interceptor = (IRedbSaveInterceptor)Activator.CreateInstance(interceptorType)!; await Await(ServiceMethod("SyncSchemeAsync", 1, typeof(CancellationToken)) .MakeGenericMethod(propsType).Invoke(redb, [CancellationToken.None])!); int saved, deleted; using (registry.Add(interceptor)) { var obj = (RedbObject)Activator.CreateInstance(typeof(RedbObject<>).MakeGenericType(propsType))!; obj.name = "module-unload-probe"; var id = (long)(await Await(ServiceMethod("SaveAsync", 0, typeof(IRedbObject), typeof(CancellationToken)) .Invoke(redb, [obj, CancellationToken.None])!))!; var load = ServiceMethod("LoadAsync", 1, typeof(long), typeof(int), typeof(CancellationToken)).MakeGenericMethod(propsType); var loaded = (IRedbObject)(await Await(load.Invoke(redb, [id, 10, CancellationToken.None])!))!; loaded.Should().NotBeNull(); (await Await(load.Invoke(redb, [id, 10, CancellationToken.None])!)).Should().NotBeNull("the second load is served by the props cache"); await Await(ServiceMethod("DeleteAsync", 0, typeof(IRedbObject), typeof(CancellationToken)) .Invoke(redb, [loaded, CancellationToken.None])!); saved = (int)interceptorType.GetField(nameof(ModuleUnloadInterceptor.Saved))!.GetValue(interceptor)!; deleted = (int)interceptorType.GetField(nameof(ModuleUnloadInterceptor.Deleted))!.GetValue(interceptor)!; } var weak = new WeakReference(context); context.Unload(); return (weak, saved, deleted); } [Fact] public async Task ModuleWithASchemeAndAnInterceptor_Unloads() { SqliteTestSupport.DeleteDbFiles(Cs); await using var host = BuildHost(); var redb = host.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); var (weak, saved, deleted) = await RunModuleAndUnload(host); saved.Should().Be(1, "the module's interceptor saw its save"); deleted.Should().Be(1, "and its delete"); for (var i = 0; i < 20 && weak.IsAlive; i++) { GC.Collect(); GC.WaitForPendingFinalizers(); await Task.Yield(); } weak.IsAlive.Should().BeFalse("the host's redb service lives on, and nothing of it may keep the unloaded module alive"); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProNativeExtensionTests.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/SqlitePro/SqliteProNativeExtensionTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Models.Entities; using redb.Core.Pro.Extensions; using redb.SQLite.Data; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.SqlitePro; /// /// The JSON of an object (LoadJsonAsync, and the load of a linked object whose scheme has no class in the /// process) is read by the function get_object_json of the native extension, on Pro too. The open registration /// finds the extension shipped with the package; the Pro registration did not, so a consumer who sets no path got /// "no such function: get_object_json". Every other test sets the path itself; this one starts without it. /// public class SqliteProNativeExtensionTests { private const string Cs = "Data Source=redb_tests_native_extension_pro.db"; [Fact] public async Task ProRegistrationWithoutAPath_LoadsTheExtension_AndReadsObjectJson() { // Test collections run one after another (xunit.runner.json), so the process-wide path can be taken away here // and put back after. var previous = SqliteDataSource.NativeExtensionPath; SqliteDataSource.NativeExtensionPath = null; try { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => options.UseSqlite(Cs)); await using var provider = services.BuildServiceProvider(); var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); var id = await redb.SaveAsync(new RedbObject { name = "json", Props = new SimpleProps { Title = "t" } }); var json = await redb.LoadJsonAsync(id); json.Should().NotBeNullOrEmpty().And.Contain("\"t\""); } finally { SqliteDataSource.NativeExtensionPath = previous; } } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProNestedCollectionsRefusalTests.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/SqlitePro/SqliteProNestedCollectionsRefusalTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProNestedCollectionsRefusalTests : NestedCollectionsRefusalTestsBase { public SqliteProNestedCollectionsRefusalTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProNestedDictionaryFilterTests.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/SqlitePro/SqliteProNestedDictionaryFilterTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProNestedDictionaryFilterTests : NestedDictionaryFilterTestsBase { public SqliteProNestedDictionaryFilterTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProNullComparisonTests.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/SqlitePro/SqliteProNullComparisonTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProNullComparisonTests : NullComparisonTestsBase { public SqliteProNullComparisonTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProNullableCollectionsTests.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/SqlitePro/SqliteProNullableCollectionsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProNullableCollectionsTests : NullableCollectionsTestsBase { public SqliteProNullableCollectionsTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProOlderModelTests.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/SqlitePro/SqliteProOlderModelTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProOlderModelTests : OlderModelTestsBase { public SqliteProOlderModelTests(SqliteProFixture fixture) : base(fixture.Redb) { } protected override string GuidLiteral(Guid value) => $"x'{value:N}'"; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProOrderAbsentValueTests.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/SqlitePro/SqliteProOrderAbsentValueTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProOrderAbsentValueTests : OrderAbsentValueTestsBase { public SqliteProOrderAbsentValueTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProOrderingTests.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/SqlitePro/SqliteProOrderingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProOrderingTests : OrderingTestsBase { public SqliteProOrderingTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProPageValuesGraphTests.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/SqlitePro/SqliteProPageValuesGraphTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProPageValuesGraphTests : PageValuesGraphTestsBase { public SqliteProPageValuesGraphTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProPolymorphicTreeTests.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/SqlitePro/SqliteProPolymorphicTreeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProPolymorphicTreeTests : PolymorphicTreeTestsBase { public SqliteProPolymorphicTreeTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProProQueryTests.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/SqlitePro/SqliteProProQueryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProProQueryTests : ProQueryTestsBase { public SqliteProProQueryTests(SqliteProFixture fixture) : base(fixture.Redb, isPro: true) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProProjectionTests.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/SqlitePro/SqliteProProjectionTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProProjectionTests : ProjectionTestsBase { public SqliteProProjectionTests(SqliteProFixture fixture) : base(fixture.Redb) { } protected override bool ReadsOnlyProjectedRows => true; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProPropertyRenameTests.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/SqlitePro/SqliteProPropertyRenameTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProPropertyRenameTests : PropertyRenameTestsBase { public SqliteProPropertyRenameTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProPropsCacheHeaderTests.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/SqlitePro/SqliteProPropsCacheHeaderTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProPropsCacheHeaderTests : PropsCacheHeaderTestsBase { private const string Cs = "Data Source=redb_tests_cacheheader_pro.db"; private bool _prepared; protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { // A fresh file per test, shared by both nodes of that test. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProPropsCacheSkipValidationTests.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/SqlitePro/SqliteProPropsCacheSkipValidationTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProPropsCacheSkipValidationTests : PropsCacheSkipValidationTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { const string cs = "Data Source=redb_tests_cacheskip_pro.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProPropsCacheTransactionKeepTests.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/SqlitePro/SqliteProPropsCacheTransactionKeepTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProPropsCacheTransactionKeepTests : PropsCacheTransactionKeepTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { const string cs = "Data Source=redb_tests_cachekeep_pro.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProPropsCacheTransactionTests.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/SqlitePro/SqliteProPropsCacheTransactionTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProPropsCacheTransactionTests : PropsCacheTransactionTestsBase { private const string Cs = "Data Source=redb_tests_cachetx_pro.db"; private bool _prepared; protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { // A fresh file per test, shared by every provider the test builds (its own and the seeder's). Deleted per // provider, the file went away under the open connection of the first one wherever an open file can be // deleted (Linux), and the seeder wrote into a new file the test's transaction never saw. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProPropsDepthBoundaryTests.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/SqlitePro/SqliteProPropsDepthBoundaryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProPropsDepthBoundaryTests : PropsDepthBoundaryTestsBase { public SqliteProPropsDepthBoundaryTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProPvtPrefilterEquivalenceTests.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/SqlitePro/SqliteProPvtPrefilterEquivalenceTests.cs ---- using redb.Core.Models.Contracts; using redb.Core.Models.Entities; using redb.Core.Query; using redb.Core.Query.Aggregation; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Helpers; using redb.Tests.Integration.Models; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProPvtPrefilterEquivalenceTests : PvtPrefilterEquivalenceTestsBase { private readonly SqliteProFixture _fixture; public SqliteProPvtPrefilterEquivalenceTests(SqliteProFixture fixture) : base(fixture.Redb) => _fixture = fixture; /// See . [Fact] public Task UnfilteredExtremes_FirstEntryOfTheIndex_SameAnswers() => UnfilteredExtremes_FirstEntryOfTheIndex_SameAnswersAsync(); /// See . [Fact] public Task AllWithoutFilter_ProbeThenCounts_SameAnswers() => AllWithoutFilter_ProbeThenCounts_SameAnswersAsync(); /// /// A narrow OR the row prefilter does not read is probed: its branches are read from the index of values up to the cap, /// and the objects found seed the streams. That holds for a grouping, an aggregate, a page without an ordering and a /// page sorted by a Props field (the walk of the sort field gives way to the probe). A page sorted by base fields only /// and a count keep the row prefilter. One object matching a branch is in the trash. Every answer must equal the one /// with the prefilter off. /// [Fact] public async Task NarrowOr_ProbedWhereTheRowPrefilterDoesNotRead_SameAnswers() { var ids = await TestDataFactory.SeedEmployees(Redb, 40); var restore = Redb.Configuration.EnablePvtPrefilter; try { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var victim = (await Redb.Query().WhereRedb(o => o.Id == ids[3]).ToListAsync()).Single().Props; var age = victim.Age; var salary = victim.Salary; await Redb.SoftDeleteAsync(new[] { ids[3] }); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); IRedbQueryable Or() => Redb.Query().Where(e => e.Age == age || e.Salary == salary); IRedbQueryable TextOr() => Redb.Query().Where(e => e.Department == "Engineering" || e.Position == "Developer"); const string probe = "pvt_probe"; (await Or().GroupBy(e => e.Department).ToSqlStringAsync(g => new { g.Key, C = Agg.Count(g) })) .Should().Contain(probe, "a grouping reads the OR from the index of values first"); (await Or().ToAggregateSqlStringAsync(x => new { S = Agg.Sum(x.Props.Salary) })) .Should().Contain(probe, "so does an aggregate"); (await Or().Take(10).ToSqlStringAsync()).Should().Contain(probe, "so does a page without an ordering"); (await Or().OrderBy(e => e.Salary).ThenByRedb(o => o.Id).Take(10).ToSqlStringAsync()) .Should().Contain(probe).And.NotContain("PVT leading form", "a page sorted by a Props field is probed, not walked"); (await Or().OrderByRedb(o => o.Id).Take(10).ToSqlStringAsync()) .Should().Contain("Streams not applied, the filter is an OR of narrow branches", "a page sorted by base fields keeps the row prefilter"); static string Ids(IEnumerable> rows) => string.Join(",", rows.Select(r => r.Id)); static string Groups(IEnumerable rows) => string.Join(",", rows.Select(r => r!.ToString()).OrderBy(s => s, StringComparer.Ordinal)); async Task AnswersAsync() => string.Join("; ", new[] { $"group {Groups(await Or().GroupBy(e => e.Department).SelectAsync(g => new { g.Key, C = Agg.Count(g) }))}", $"text group {Groups(await TextOr().GroupBy(e => e.Age).SelectAsync(g => new { g.Key, C = Agg.Count(g) }))}", $"sum {(await Or().AggregateAsync(x => new { S = Agg.Sum(x.Props.Salary), C = Agg.Count() })).S}", $"count {await Or().CountAsync()}", $"page {(await Or().Take(100).ToListAsync()).Count}", $"by salary {Ids(await Or().OrderBy(e => e.Salary).ThenByRedb(o => o.Id).Take(10).ToListAsync())}", $"text by age {Ids(await TextOr().OrderByDescending(e => e.Age).ThenByRedb(o => o.Id).Take(10).ToListAsync())}", $"by id {Ids(await Or().OrderByRedb(o => o.Id).Take(10).ToListAsync())}", }); var on = await AnswersAsync(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = await AnswersAsync(); on.Should().Be(off, "probing the OR changes the plan, not the answer"); on.Should().NotContain("count 0;", "live employees match the OR"); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// SQLite only, and a performance rule rather than a correctness one, so it is asserted on the /// generated SQL instead of on results. /// /// A multi-branch prefilter under a limit with no ordering makes SQLite abandon /// IX__values__object_structure_lookup for MULTI-INDEX OR. Rows stop arriving in _id_object /// order, GROUP BY needs a temp B-tree, and the limit no longer stops anything: measured on /// 100 000 objects the same query went from 6 ms to 355 ms. Add any ordering and materialisation /// happens regardless, so the prefilter wins again (1150 ms against 311 ms) and must stay. /// /// See SqlitePrefilterGuards.StreamingLimitBeatsPrefilter. /// [Fact] public async Task UnorderedLimit_DropsMultiBranchPrefilter_ButOrderedKeepsIt() { var restore = Redb.Configuration.EnablePvtPrefilter; try { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var unordered = await Unordered().ToSqlStringAsync(); var ordered = await Ordered().ToSqlStringAsync(); // Asserted on the planner trace rather than on the whole SQL text: the trace names the // decision, while a text comparison would also fail on any unrelated formatting change. unordered.Should().Contain("-- PVT form: Streams", "an unordered limit goes to the streams form, which stops after the first matches; " + "a multi-branch prefilter over the aggregate would take that away for a 40x loss"); unordered.Should().NotContain("AND ((v._id_structure", "and no prefilter must be rendered into a value scan"); ordered.Should().Contain("-- PVT prefilter: Row form", "with an ORDER BY the aggregate is materialised either way, so the prefilter is pure " + "gain and must still be emitted"); ordered.Should().Contain("AND ((v._id_structure", "and it must actually reach the value scan"); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } IRedbQueryable Unordered() => Redb.Query() .Where(e => e.Position.Contains("Developer") || e.Department.Contains("Engineering")) .Take(100); // An expression over Id: a plain OrderByRedb(o => o.Id) goes inside the streams form now, and // the prefilter under test lives in the aggregate form. IRedbQueryable Ordered() => Redb.Query() .Where(e => e.Position.Contains("Developer") || e.Department.Contains("Engineering")) .OrderByRedb(o => o.Id + 0) .Take(100); } /// /// A page sorted by a Props field and then by others (ThenBy) is led by the first field; the walk is /// materialized and read on through the run of the value it stopped at (pvt_bound, pvt_run); a longer /// run leaves the page to the streams (weight descending then number in route, 689 thousand points: /// 1.7 s -> 41 ms). Compared by the sequence of all keys. /// [Fact] public async Task LeadingForm_ThenBy_SameKeysAsAggregateForm() { await TestDataFactory.SeedEmployees(Redb, 40); var restore = Redb.Configuration.EnablePvtPrefilter; try { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); IRedbQueryable Page(int skip) => Redb.Query() .Where(e => e.Salary > 0m && e.Age >= 20) .OrderByDescending(e => e.Salary).ThenBy(e => e.Age).ThenBy(e => e.LastName) .Skip(skip).Take(10); var sql = await Page(0).ToSqlStringAsync(); sql.Should().Contain("-- PVT leading form:"); sql.Should().Contain("pvt_bound", "with ThenBy the walk must know where it stopped"); foreach (var skip in new[] { 0, 5 }) { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var on = (await Page(skip).ToListAsync()).Select(r => (r.Props.Salary, r.Props.Age, r.Props.LastName)).ToList(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = (await Page(skip).ToListAsync()).Select(r => (r.Props.Salary, r.Props.Age, r.Props.LastName)).ToList(); on.Should().Equal(off, $"the leading form changes the plan, not the order (Skip {skip})"); } } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// With ThenBy the walk of the leading form reads on through the run of equal sort values it stops in /// (pvt_run). Take 10 walks 1 000 entries: 5 objects at the top value, then a run of 1 200 equal values /// whose smallest titles sit past the first thousand entries. A run longer than the walk (2 100 objects) /// leaves the page to the streams. Both pages are compared with the prefilter off by both keys. /// [Fact] public async Task LeadingForm_ThenBy_RunOfEqualValuesAtTheBound() { const long top = 9_000_100, run = 9_000_090, longRun = 9_000_080; var objects = new List>(); void Add(long value, int count) { // Titles fall as the objects are created, so the first titles of a run are its last entries. for (var i = 0; i < count; i++) objects.Add(new RedbObject { name = $"run-{value}-{i}", Props = new SimpleProps { Title = $"t{value}-{count - i:D5}", OptionalNumber = value } }); } Add(top, 5); Add(run, 1200); Add(longRun, 2100); await Redb.SaveAsync(objects); var restore = Redb.Configuration.EnablePvtPrefilter; try { IRedbQueryable Run() => Redb.Query() .Where(p => p.OptionalNumber >= run) .OrderByDescending(p => p.OptionalNumber).ThenBy(p => p.Title) .Take(10); IRedbQueryable LongRun() => Redb.Query() .Where(p => p.OptionalNumber >= longRun) .OrderBy(p => p.OptionalNumber).ThenBy(p => p.Title) .Take(10); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var sql = await Run().ToSqlStringAsync(); sql.Should().Contain("-- PVT leading form:"); sql.Should().Contain("pvt_run", "with ThenBy the walk reads the run it stops in to the end"); foreach (var (name, page) in new[] { ("run", (Func>)Run), ("long run", LongRun) }) { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var on = (await page().ToListAsync()).Select(r => (r.Props.OptionalNumber, r.Props.Title)).ToList(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = (await page().ToListAsync()).Select(r => (r.Props.OptionalNumber, r.Props.Title)).ToList(); on.Should().HaveCount(10); on.Should().Equal(off, $"the leading form changes the plan, not the order ({name})"); } } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// An aggregate, a grouping and a window over an open range read the range from the index of values /// first (weight over 7 500, 410 points of 689 thousand: 1.3 s -> 36-47 ms). Asserted on the SQL of /// the grouping; every answer must not change. /// [Fact] public async Task OpenRange_ProbedInAggregateGroupingAndWindow() { await TestDataFactory.SeedEmployees(Redb, 40); var restore = Redb.Configuration.EnablePvtPrefilter; try { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); IRedbQueryable Q() => Redb.Query().Where(e => e.Salary > 70000m && e.Age >= 30); (await Q().GroupBy(x => x.Department) .ToSqlStringAsync(g => new { g.Key, Count = Agg.Count(g) })) .Should().Contain("pvt_probe", "the open range is probed"); async Task Answers() { var agg = await Q().AggregateAsync(x => new { Sum = Agg.Sum(x.Props.Salary), Count = Agg.Count() }); var groups = (await Q().GroupBy(x => x.Department) .SelectAsync(g => new { g.Key, Count = Agg.Count(g), Sum = Agg.Sum(g, x => x.Salary) })) .OrderBy(g => g.Key).ToList(); var ranked = (await Q().Take(20) .WithWindow(w => w.PartitionBy(x => x.Department).OrderByDesc(x => x.Salary)) .SelectAsync(x => new { x.Props.Salary, Rank = Win.RowNumber() })) .Select(x => x.Salary).OrderByDescending(s => s).ToList(); return System.Text.Json.JsonSerializer.Serialize(new { agg, groups, ranked }); } var on = await Answers(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = await Answers(); on.Should().Be(off, "the probe changes the plan, not the answer"); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// A page sorted by one Props field whose NULLs the filter rejects is led by that field's index of /// values (weight over 0, by weight descending, 689 thousand points: 1.3 s -> 35 ms); under a /// WhereRedb it is not. The answer must not change: a page the walk fills, and a page nothing passes, /// where only the streams branch answers. Compared by the sequence of sort keys, ties may swap ids. /// [Fact] public async Task LeadingForm_PageSortedByField_SameKeysAsAggregateForm() { await TestDataFactory.SeedEmployees(Redb, 40); var restore = Redb.Configuration.EnablePvtPrefilter; try { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); IRedbQueryable Page(int minAge) => Redb.Query() .Where(e => e.Salary > 0m && e.Age >= minAge) .OrderByDescending(e => e.Salary).Take(10); (await Page(30).ToSqlStringAsync()).Should().Contain("-- PVT leading form:"); (await Redb.Query() .WhereRedb(o => o.Id > 0) .Where(e => e.Salary > 0m && e.Age >= 30) .OrderByDescending(e => e.Salary).Take(10) .ToSqlStringAsync()).Should().NotContain("-- PVT leading form:", "under a base filter the objects it keeps may be anywhere in the order of the field"); foreach (var minAge in new[] { 30, 1000 }) { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var on = (await Page(minAge).ToListAsync()).Select(r => r.Props.Salary).ToList(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = (await Page(minAge).ToListAsync()).Select(r => r.Props.Salary).ToList(); on.Should().Equal(off, $"the leading form changes the plan, not the answer (Age >= {minAge})"); } } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// An open range is probed from the index of values on a page not sorted by a Props field: fewer /// rows than the cap, and the streams start from them (weight over 7 500 among 689 thousand points, /// by id: 1.2 s -> 35 ms). A page sorted by that field walks its index instead and gets no probe. /// Asserted on the SQL; the answer must not change, with the probe narrow and with it wide. /// [Fact] public async Task OpenRange_ProbedOnPageById_NotOnPageSortedByTheField() { await TestDataFactory.SeedEmployees(Redb, 40); var restore = Redb.Configuration.EnablePvtPrefilter; try { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); IRedbQueryable ById(decimal salary) => Redb.Query() .Where(e => e.Salary > salary && e.Age >= 30) .OrderByRedb(o => o.Id).Take(100); (await ById(70000m).ToSqlStringAsync()).Should().Contain("-- PVT probe:"); (await Redb.Query() .Where(e => e.Salary > 70000m && e.Age >= 30) .OrderByDescending(e => e.Salary).Take(100) .ToSqlStringAsync()).Should().NotContain("-- PVT probe:", "a page sorted by the field walks its index of values"); foreach (var salary in new[] { 70000m, 0m }) { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var on = (await ById(salary).ToListAsync()).Select(r => r.id).ToList(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = (await ById(salary).ToListAsync()).Select(r => r.id).ToList(); on.Should().Equal(off, $"the probe changes the plan, not the answer (Salary > {salary})"); } } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } /// /// An OR of narrow branches on an ordered page stays on the aggregate form, where the row /// prefilter reads every branch from the index of values; as streams it was checked above every /// object of the scheme (examples, three branches: 1.3 s against 26 ms). A narrow leaf in the /// top-level AND keeps the streams. Asserted on the SQL, and the answer must not change. /// [Fact] public async Task Streams_NarrowOrGoesToRowPrefilter_NarrowAndKeepsStreams() { await TestDataFactory.SeedEmployees(Redb, 40); var restore = Redb.Configuration.EnablePvtPrefilter; try { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); IRedbQueryable NarrowOr() => Redb.Query() .Where(e => e.Department == "Engineering" || e.Position == "Developer" || e.LastName == "Smith") .OrderByRedb(o => o.Id).Take(100); var narrowOr = await NarrowOr().ToSqlStringAsync(); narrowOr.Should().Contain("Streams not applied, the filter is an OR of narrow branches"); narrowOr.Should().Contain("-- PVT prefilter: Row form, 3 branch(es)"); var narrowAnd = await Redb.Query() .Where(e => e.Department == "Engineering" && (e.Age > 30 || e.Position == "Developer")) .OrderByRedb(o => o.Id).Take(100) .ToSqlStringAsync(); narrowAnd.Should().Contain("-- PVT form: Streams,", "an equality in the top-level AND is pushed into its stream"); var on = (await NarrowOr().ToListAsync()).Select(r => r.id).ToList(); Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = false); var off = (await NarrowOr().ToListAsync()).Select(r => r.id).ToList(); on.Should().Equal(off, "the form changes the plan, not the answer"); } finally { Redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProPvtPrefilterListItemTests.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/SqlitePro/SqliteProPvtPrefilterListItemTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProPvtPrefilterListItemTests : PvtPrefilterListItemTestsBase { public SqliteProPvtPrefilterListItemTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProQueryOrderTests.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/SqlitePro/SqliteProQueryOrderTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProQueryOrderTests : QueryOrderTestsBase { public SqliteProQueryOrderTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProQueryPlannerBlockTests.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/SqlitePro/SqliteProQueryPlannerBlockTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProQueryPlannerBlockTests : QueryPlannerBlockTestsBase { public SqliteProQueryPlannerBlockTests(SqliteProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProReaderConnectionTests.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/SqlitePro/SqliteProReaderConnectionTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProReaderConnectionTests : ReaderConnectionTestsBase { protected override string SlowScalarSql => Sqlite.SqliteSlowScalar.Sql; protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { const string cs = "Data Source=redb_tests_readerconn_pro.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProRedundantArrayGuardTests.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/SqlitePro/SqliteProRedundantArrayGuardTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProRedundantArrayGuardTests : RedundantArrayGuardTestsBase { public SqliteProRedundantArrayGuardTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProReferenceCycleNoHashTests.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/SqlitePro/SqliteProReferenceCycleNoHashTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Models.Entities; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; namespace redb.Tests.Integration.Tests.SqlitePro; /// /// With AutoRecomputeHash = false the save computes no object hash, so the walk that refuses a reference cycle /// there does not run: the walk that builds the value rows meets the cycle first. It must refuse it too and write /// nothing, not overflow the stack. /// public class SqliteProReferenceCycleNoHashTests { private const string Cs = "Data Source=redb_tests_reference_cycle_nohash_pro.db"; [Fact] public async Task SaveOfAGraphWithABackReference_WithoutHashRecompute_IsRefusedAndWritesNothing() { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => { options.UseSqlite(Cs); options.Configure(c => c.AutoRecomputeHash = false); }); await using var provider = services.BuildServiceProvider(); var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); var first = new ReferenceCycleNode { Name = "first" }; first.Next = new ReferenceCycleNode { Name = "second", Next = first }; var act = () => redb.SaveAsync(new RedbObject { name = "cycle", Props = new ReferenceCycleProps { Title = "t", Head = first } }); await act.Should().ThrowAsync() .WithMessage($"*reference cycle*{nameof(ReferenceCycleNode)}*"); (await redb.Query().CountAsync()).Should().Be(0, "nothing of the refused save is written"); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProReferenceCycleSaveTests.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/SqlitePro/SqliteProReferenceCycleSaveTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Attributes; using redb.Core.Models.Entities; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; namespace redb.Tests.Integration.Tests.SqlitePro; public class ReferenceCycleNode { public string? Name { get; set; } public ReferenceCycleNode? Next { get; set; } } [RedbScheme("Save: reference cycle probe", Name = "reference_cycle_probe")] public class ReferenceCycleProps { public string? Title { get; set; } public ReferenceCycleNode? Head { get; set; } } /// /// A Props graph with a back-reference through plain class properties: the save refuses it with an error naming the /// cycle and writes nothing, instead of overflowing the stack in the object hash and killing the process. /// public class SqliteProReferenceCycleSaveTests { private const string Cs = "Data Source=redb_tests_reference_cycle_pro.db"; [Fact] public async Task SaveOfAGraphWithABackReference_IsRefusedAndWritesNothing() { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => options.UseSqlite(Cs)); await using var provider = services.BuildServiceProvider(); var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); var first = new ReferenceCycleNode { Name = "first" }; first.Next = new ReferenceCycleNode { Name = "second", Next = first }; var act = () => redb.SaveAsync(new RedbObject { name = "cycle", Props = new ReferenceCycleProps { Title = "t", Head = first } }); await act.Should().ThrowAsync() .WithMessage($"*reference cycle*{nameof(ReferenceCycleNode)}*"); (await redb.Query().CountAsync()).Should().Be(0, "nothing of the refused save is written"); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProReferenceListSaveTests.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/SqlitePro/SqliteProReferenceListSaveTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProReferenceListSaveTests : ReferenceListSaveTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { const string cs = "Data Source=redb_tests_reflist_pro.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProRegexQueryTests.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/SqlitePro/SqliteProRegexQueryTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProRegexQueryTests : RegexQueryTestsBase { public SqliteProRegexQueryTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProRolledBackSaveIdsTests.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/SqlitePro/SqliteProRolledBackSaveIdsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProRolledBackSaveIdsTests : RolledBackSaveIdsTestsBase { public SqliteProRolledBackSaveIdsTests(SqliteProFixture fixture) : base(fixture.ServiceProvider) { } protected override string? SequenceTopSql => "SELECT seq FROM sqlite_sequence WHERE name = '_global_identity'"; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProRowMapperKindsTests.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/SqlitePro/SqliteProRowMapperKindsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProRowMapperKindsTests : RowMapperKindsTestsBase { public SqliteProRowMapperKindsTests(SqliteProFixture fixture) : base(fixture.Redb) { } // Datetimes are Julian days (REAL), guids text, booleans integers: the SQLite mapper reads them as such. protected override string KindsSql => @"SELECT 1 AS _id, 7 AS count, NULL AS maybe_long, 12.50 AS amount, 1.5 AS from_double, 0.25 AS ratio, 1 AS flag, '6f1d0c3e-2b4a-4c8e-9a51-3d2f7e8b9c01' AS key_value, julianday('2026-01-02 03:04:05') AS when_at, NULL AS day, X'0102' AS bytes, 'abc' AS NAME, 'shown' AS display_name, julianday('2026-03-04 00:00:00') AS first_seen, 'x' AS zzz"; protected override string EnumSql => "SELECT 2 AS kind"; /// SQLite refuses a value it cannot convert (SL-57): an integer is not an enum to Convert.ChangeType. protected override async Task AssertEnumAsync() { var read = async () => await Redb.Context.QueryAsync(EnumSql); await read.Should().ThrowAsync().WithMessage("*kind*"); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProRowMapperTests.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/SqlitePro/SqliteProRowMapperTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProRowMapperTests : SqliteRowMapperTestsBase { public SqliteProRowMapperTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProSaveGraphHashTests.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/SqlitePro/SqliteProSaveGraphHashTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProSaveGraphHashTests : SaveGraphHashTestsBase { public SqliteProSaveGraphHashTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProSaveInterceptorTests.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/SqlitePro/SqliteProSaveInterceptorTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Models.Configuration; using redb.Core.Pro.Extensions; using redb.SQLite.Data; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProSaveInterceptorTests : SaveInterceptorTestsBase { private readonly SqliteProFixture _fixture; public SqliteProSaveInterceptorTests(SqliteProFixture fixture) => _fixture = fixture; protected override string ConnectionStringName => "Sqlite"; protected override PropsSaveStrategy Strategy => PropsSaveStrategy.ChangeTracking; protected override void AddRedbServices(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options, string connectionString) { // The database of the collection's fixture, which has the schema. The "Sqlite" connection string is the // file of the Free collection: it had a schema only when that collection, or a previous run, made it. SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); options.UseSqlite(_fixture.ConnectionString); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProSaveIntoOtherSchemeTests.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/SqlitePro/SqliteProSaveIntoOtherSchemeTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Attributes; using redb.Core.Exceptions; using redb.Core.Models.Entities; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; namespace redb.Tests.Integration.Tests.SqlitePro; [RedbScheme("Save: other scheme probe A", Name = "save_other_scheme_probe_a")] public class SaveOtherSchemeAProps { public string? Title { get; set; } } [RedbScheme("Save: other scheme probe B", Name = "save_other_scheme_probe_b")] public class SaveOtherSchemeBProps { public string? Label { get; set; } public long Amount { get; set; } } /// /// A save of RedbObject<A> under the id of an existing object of scheme B kept the object in scheme B, /// deleted its values and wrote the values of A's fields into it: B's values were gone and nothing reported it. The /// save is refused before anything is written, and so is a save over an object in the trash. /// public class SqliteProSaveIntoOtherSchemeTests { private const string Cs = "Data Source=redb_tests_save_other_scheme_pro.db"; private static async Task<(ServiceProvider Provider, IRedbService Redb)> StartAsync() { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => options.UseSqlite(Cs)); var provider = services.BuildServiceProvider(); var redb = provider.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); await redb.SyncSchemeAsync(); await redb.SyncSchemeAsync(); return (provider, redb); } [Fact] public async Task SaveUnderTheIdOfAnObjectOfAnotherScheme_IsRefused_AndKeepsItsValues() { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); var (provider, redb) = await StartAsync(); await using var _ = provider; var id = await redb.SaveAsync(new RedbObject { name = "b", Props = new SaveOtherSchemeBProps { Label = "kept", Amount = 42 } }); var act = () => redb.SaveAsync(new RedbObject { id = id, name = "a", Props = new SaveOtherSchemeAProps { Title = "intruder" } }); await act.Should().ThrowAsync(); var b = await redb.LoadAsync(id); b.Should().NotBeNull(); b!.name.Should().Be("b"); b.Props.Label.Should().Be("kept"); b.Props.Amount.Should().Be(42); } [Fact] public async Task SaveUnderTheIdOfATrashedObject_IsRefused() { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); var (provider, redb) = await StartAsync(); await using var _ = provider; var id = await redb.SaveAsync(new RedbObject { name = "a", Props = new SaveOtherSchemeAProps { Title = "trashed" } }); await redb.SoftDeleteAsync(new[] { id }); // marks the object for deletion: its scheme becomes the trash scheme var act = () => redb.SaveAsync(new RedbObject { id = id, name = "a", Props = new SaveOtherSchemeAProps { Title = "back" } }); await act.Should().ThrowAsync(); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProSaveLockScopeTests.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/SqlitePro/SqliteProSaveLockScopeTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProSaveLockScopeTests : SaveLockScopeTestsBase { private const string Cs = "Data Source=redb_tests_savelock_pro.db"; private bool _prepared; protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { // A fresh file per test class instance. if (!_prepared) { Fixtures.SqliteTestSupport.DeleteDbFiles(Cs); _prepared = true; } options.UseSqlite(Cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProSchemaConcurrencyTests.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/SqlitePro/SqliteProSchemaConcurrencyTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Data; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.SqlitePro; /// /// Services opening one SQLite file at once, as a panel and a worker of one host do: the schema upgrades of an old file /// and the creation of a new one run under the schema lock (an immediate transaction of the service's own connection), /// the version or the tables asked again under it. Without it a step that checks and then acts (an index rebuilt under /// its name, a column added) failed in the second service. Each service has a connection and a cache domain of its own. /// public class SqliteProSchemaConcurrencyTests : IDisposable { private readonly List _files = []; private string NewFile() { var path = Path.Combine(Path.GetTempPath(), $"redb_schemalock_{Guid.NewGuid():N}.db"); _files.Add(path); return path; } private static ServiceProvider Build(string path, ILoggerProvider? logs = null, Action? more = null) { redb.SQLite.Data.SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var services = new ServiceCollection(); services.AddLogging(b => { b.SetMinimumLevel(LogLevel.Warning); if (logs != null) b.AddProvider(logs); }); services.AddRedbPro(options => options.UseSqlite($"Data Source={path}") .Configure(c => { c.EnablePropsCache = false; c.CacheDomain = $"schema-lock-{Guid.NewGuid():N}"; })); more?.Invoke(services); return services.BuildServiceProvider(); } private static async Task> StartTogetherAsync(string path, int nodes, bool ensureCreated) { var providers = Enumerable.Range(0, nodes).Select(_ => Build(path)).ToList(); try { var starts = providers.Select(sp => Task.Run(async () => { try { await sp.GetRequiredService().InitializeAsync(ensureCreated); return null; } catch (Exception ex) { return ex; } })); return (await Task.WhenAll(starts)).Where(e => e != null).Select(e => e!).ToList(); } finally { foreach (var sp in providers) await sp.DisposeAsync(); } } [Fact] public async Task OldFile_ServicesOpeningItTogether_AllStart_AndTheFileIsUpgraded() { var path = NewFile(); await using (var sp = Build(path)) await sp.GetRequiredService().InitializeAsync(ensureCreated: true); for (var round = 0; round < 10; round++) { // A file of schema version 10: the indexes of steps 11 and 12 missing, the stamp behind. await using (var sp = Build(path)) { var ctx = sp.GetRequiredService(); await ctx.ExecuteAsync("DROP INDEX IF EXISTS \"IX__values__structure_object_string\""); await ctx.ExecuteAsync("DROP INDEX IF EXISTS \"IX__values__structure_long_object\""); await ctx.ExecuteAsync("PRAGMA user_version = 10"); } var failures = await StartTogetherAsync(path, nodes: 6, ensureCreated: true); failures.Should().BeEmpty($"every service starts (round {round})"); await using (var sp = Build(path)) { var ctx = sp.GetRequiredService(); (await ctx.ExecuteScalarAsync("PRAGMA user_version")).Should().BeGreaterThanOrEqualTo(12); (await ctx.ExecuteScalarAsync( "SELECT 1 FROM sqlite_master WHERE type = 'index' AND name = 'IX__values__structure_object_string'")) .Should().Be(1, "step 12 built the index once"); } } } [Fact] public async Task NewFile_ServicesCreatingTheSchemaTogether_AllStart() { for (var round = 0; round < 5; round++) { var failures = await StartTogetherAsync(NewFile(), nodes: 4, ensureCreated: true); failures.Should().BeEmpty($"every service starts (round {round})"); } } [Fact] public async Task Scheme_ServicesSyncingItTogether_AllSucceed() { var path = NewFile(); var providers = Enumerable.Range(0, 4).Select(_ => Build(path)).ToList(); try { var nodes = new List(); foreach (var sp in providers) { var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); nodes.Add(redb); } var failures = await redb.Tests.Integration.Tests.Base.SchemeSyncRace.RunAsync( nodes, providers[0].GetRequiredService(), rounds: 8); failures.Should().BeEmpty(); } finally { foreach (var sp in providers) await sp.DisposeAsync(); } } [Fact] public async Task RootDuplicates_EmptyOnesRemoved_OneWithValuesWaitsForTheHandFix() { // As on PostgreSQL, but the file tries again at every start, not at a module upgrade. var path = NewFile(); await using var owner = Build(path); var redbService = owner.GetRequiredService(); await redbService.InitializeAsync(ensureCreated: true); var context = owner.GetRequiredService(); var scenario = await redb.Tests.Integration.Tests.Base.RootDuplicatesScenario.PlantAsync(redbService, context); for (var start = 0; start < 2; start++) { // Every start: the error again, the same list. var logs = new redb.Tests.Integration.Tests.Base.CollectingLoggerProvider(); await using var sp = Build(path, logs); var started = sp.GetRequiredService(); await started.InitializeAsync(ensureCreated: true); scenario.ShouldReportCountOnly(started, logs); } async Task Exists(long id) => await redb.Tests.Integration.Tests.Base.RootDuplicatesScenario.StructureExistsAsync(context, id); async Task KeyExists() => await context.ExecuteScalarAsync( $"SELECT 1 FROM sqlite_master WHERE type = 'index' AND name = '{RootStructureKey.IndexName}'") != null; (await Exists(scenario.TitleDuplicate)).Should().BeFalse(); (await Exists(scenario.PartDuplicate)).Should().BeFalse(); (await Exists(scenario.PartDuplicateChild)).Should().BeFalse(); (await Exists(scenario.CountDuplicate)).Should().BeTrue("it holds a value"); (await KeyExists()).Should().BeFalse(); // A copy written after the start (a node of the previous version) is met by the next sync of the scheme. var syncLogs = new redb.Tests.Integration.Tests.Base.CollectingLoggerProvider(); await using (var sp = Build(path, syncLogs)) { var running = sp.GetRequiredService(); await running.InitializeAsync(ensureCreated: true); var titleCopy = await scenario.CopyRootAsync(context, "Title"); await running.SyncSchemeAsync(); running.SchemaProblems.Should().Contain(p => p.Field == "Title" && p.StructureIds.Contains(titleCopy)); syncLogs.Errors.Should().ContainSingle(e => e.Contains("'Title'")); (await Exists(titleCopy)).Should().BeTrue("a sync never removes a copy of a field"); await context.ExecuteAsync($"DELETE FROM _structures WHERE _id = {titleCopy}"); } await scenario.ResolveByHandAsync(context); await using (var sp = Build(path)) { var started = sp.GetRequiredService(); await started.InitializeAsync(ensureCreated: true); started.SchemaProblems.Should().BeEmpty(); } (await KeyExists()).Should().BeTrue(); } /// The health check of the README, registered with AddCheck: IRedbService injected from a scope of its own. private sealed class SchemaHealthCheck(IRedbService redb) : Microsoft.Extensions.Diagnostics.HealthChecks.IHealthCheck { public Task CheckHealthAsync( Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckContext context, CancellationToken cancellationToken = default) { var problems = redb.SchemaProblems; return Task.FromResult(problems.Count > 0 ? Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult.Degraded(string.Join("; ", problems.Select(p => p.Message))) : Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult.Healthy()); } } [Fact] public async Task SchemaProblems_FoundByTheStartInItsScope_SeenFromAnotherScope() { // IRedbService is scoped and the host starts it in a scope of its own (RedbInitHostedService): what the start // found must reach the instance a health check gets in a later scope, without a database read or a second log. var path = NewFile(); await using (var owner = Build(path)) { var redbService = owner.GetRequiredService(); await redbService.InitializeAsync(ensureCreated: true); await redb.Tests.Integration.Tests.Base.RootDuplicatesScenario.PlantAsync(redbService, owner.GetRequiredService()); } var logs = new redb.Tests.Integration.Tests.Base.CollectingLoggerProvider(); await using var host = Build(path, logs, services => services.AddHealthChecks().AddCheck("redb-schema")); await using (var startScope = host.CreateAsyncScope()) await startScope.ServiceProvider.GetRequiredService().InitializeAsync(ensureCreated: true); logs.Errors.Should().ContainSingle(e => e.Contains("'Count'")); // The health service of the host, as /health runs it: a scope per check run. var report = await host.GetRequiredService().CheckHealthAsync(); report.Status.Should().Be(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Degraded); report.Entries["redb-schema"].Description.Should().Contain("'Count'"); await using (var healthScope = host.CreateAsyncScope()) { var redbService = healthScope.ServiceProvider.GetRequiredService(); redbService.SchemaProblems.Should().ContainSingle(p => p.Field == "Count"); // Asked again from the new instance: the same list, no second error. (await redbService.CheckSchemaAsync()).Should().ContainSingle(p => p.Field == "Count"); logs.Errors.Should().ContainSingle(e => e.Contains("'Count'")); } } [Fact] public async Task OldFile_LockHeldByAnotherProcess_StartUpStopsAtTheTimeOut() { var path = NewFile(); await using (var sp = Build(path)) { await sp.GetRequiredService().InitializeAsync(ensureCreated: true); await sp.GetRequiredService().ExecuteAsync("PRAGMA user_version = 10"); } // Another process holds the write lock of the file and does not let go. await using var holder = new Microsoft.Data.Sqlite.SqliteConnection($"Data Source={path}"); await holder.OpenAsync(); await using var held = holder.BeginTransaction(deferred: false); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); // A short command time-out: Microsoft.Data.Sqlite retries a busy BEGIN until it, so each attempt lasts that long. services.AddRedbPro(options => options.UseSqlite($"Data Source={path};Default Timeout=1") .Configure(c => { c.EnablePropsCache = false; c.CacheDomain = $"schema-lock-{Guid.NewGuid():N}"; c.SchemaLockTimeout = TimeSpan.FromSeconds(3); })); await using var sp2 = services.BuildServiceProvider(); var start = () => sp2.GetRequiredService().InitializeAsync(); (await start.Should().ThrowAsync()) .Which.Waited.Should().BeGreaterThanOrEqualTo(TimeSpan.FromSeconds(3)); } public void Dispose() { Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools(); foreach (var file in _files) foreach (var suffix in new[] { "", "-wal", "-shm" }) try { File.Delete(file + suffix); } catch (IOException) { } } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProSchemaNewerTests.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/SqlitePro/SqliteProSchemaNewerTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProSchemaNewerTests : SqliteSchemaNewerTestsBase { protected override void AddRedbServices(IServiceCollection services, string connectionString) => services.AddRedbPro(options => options.UseSqlite(connectionString)); } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProSchemeLoadValidationTests.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/SqlitePro/SqliteProSchemeLoadValidationTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProSchemeLoadValidationTests : SchemeLoadValidationTestsBase { public SqliteProSchemeLoadValidationTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProSchemeNamingTests.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/SqlitePro/SqliteProSchemeNamingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProSchemeNamingTests : SchemeNamingTestsBase { public SqliteProSchemeNamingTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProSchemeRenameTests.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/SqlitePro/SqliteProSchemeRenameTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProSchemeRenameTests : SchemeRenameTestsBase { public SqliteProSchemeRenameTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProStaleStructureTreeTests.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/SqlitePro/SqliteProStaleStructureTreeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProStaleStructureTreeTests : StaleStructureTreeTestsBase { public SqliteProStaleStructureTreeTests(SqliteProFixture fixture) : base(fixture.Redb) { } protected override string GuidLiteral(Guid value) => $"x'{value:N}'"; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProStreamsPageJoinTests.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/SqlitePro/SqliteProStreamsPageJoinTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.SqlitePro; /// /// The page of the streams form reads the page the CTE cut first and its objects by primary key after it: the CTE is /// joined to _objects by CROSS JOIN, whose order SQLite keeps. With a plain JOIN and no planner statistics SQLite /// put _objects of the scheme on the outer loop and ran the CTE again for each of its rows, so a page of a /// Contains over 122 000 objects did not finish in 900 s while the count of the same filter took 3 ms. /// [Collection("SqlitePro")] public class SqliteProStreamsPageJoinTests { private readonly redb.Core.IRedbService _redb; public SqliteProStreamsPageJoinTests(SqliteProFixture fixture) => _redb = fixture.Redb; [Fact] public async Task StreamsPage_JoinsItsObjects_AfterTheCte() { var restore = _redb.Configuration.EnablePvtPrefilter; try { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var sql = await _redb.Query() .Where(e => e.Skills!.Contains("Azure")) .OrderByRedb(o => o.Id) .Take(100) .ToSqlStringAsync(); sql.Should().Contain("FROM pvt_cte\nCROSS JOIN _objects o ON pvt_cte._id_object = o._id", "the page cut by the CTE drives and its objects are read by primary key:\n{0}", sql); } finally { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } [Fact] public async Task LeadingForm_KeepsTheWalkOnTheOuterLoop() { var restore = _redb.Configuration.EnablePvtPrefilter; try { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); // Age >= 30 rejects NULL: its LEFT JOIN becomes an inner join SQLite could lead with, ahead of the walk. var sql = await _redb.Query() .Where(e => e.Position != "" && e.Age >= 30 && e.Salary > 70000m) .OrderByDescending(e => e.Salary).ThenByRedb(o => o.Id) .Take(100) .ToSqlStringAsync(); sql.Should().Contain("pvt_walk", "the page sorted by Salary is led by the walk of its index of values:\n{0}", sql) .And.Contain("CROSS JOIN _objects o_src ON o_src._id = d._id_object", "the walked entries stay the outer loop:\n{0}", sql); } finally { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProSubSecondUpdateTests.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/SqlitePro/SqliteProSubSecondUpdateTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Models.Configuration; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProSubSecondUpdateTests : SubSecondUpdateTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override PropsSaveStrategy SaveStrategy => PropsSaveStrategy.ChangeTracking; protected override void UseProvider(RedbOptionsBuilder options) { const string cs = "Data Source=redb_tests_subsecond_pro.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProSyncLoadTests.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/SqlitePro/SqliteProSyncLoadTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProSyncLoadTests : ProSyncLoadTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override void UseProvider(RedbOptionsBuilder options) { // A fresh file per host. The verdict does not depend on the Free native extension another suite may have // loaded process-wide: the detector is the recorded SQL. const string cs = "Data Source=redb_tests_prosync_pro.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProTagsFieldTests.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/SqlitePro/SqliteProTagsFieldTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProTagsFieldTests : TagsFieldTestsBase { public SqliteProTagsFieldTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProTemporalRoundTripTests.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/SqlitePro/SqliteProTemporalRoundTripTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProTemporalRoundTripTests : TemporalRoundTripTestsBase { public SqliteProTemporalRoundTripTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProTimeTicksTests.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/SqlitePro/SqliteProTimeTicksTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProTimeTicksTests : TimeTicksTestsBase { public SqliteProTimeTicksTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProTopLevelCollectionsTests.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/SqlitePro/SqliteProTopLevelCollectionsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProTopLevelCollectionsTests : TopLevelCollectionsTestsBase { public SqliteProTopLevelCollectionsTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProTrashPurgeTests.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/SqlitePro/SqliteProTrashPurgeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProTrashPurgeTests : TrashPurgeTestsBase { public SqliteProTrashPurgeTests(SqliteProFixture fixture) : base(fixture.ServiceProvider) { } // One writer: see the base. protected override bool ConcurrentWriters => false; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProTrashedReferenceTargetTests.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/SqlitePro/SqliteProTrashedReferenceTargetTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; public class SqliteProTrashedReferenceTargetTests : TrashedReferenceTargetTestsBase { protected override void Register(IServiceCollection services, Action configure) => services.AddRedbPro(configure); protected override bool ProPropsCache => true; protected override void UseProvider(RedbOptionsBuilder options) { // A fresh file per host. const string cs = "Data Source=redb_tests_trashed_ref_pro.db"; Fixtures.SqliteTestSupport.DeleteDbFiles(cs); options.UseSqlite(cs); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProTreeAggregateTests.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/SqlitePro/SqliteProTreeAggregateTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProTreeAggregateTests : TreeAggregateTestsBase { public SqliteProTreeAggregateTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProTreeDistinctTests.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/SqlitePro/SqliteProTreeDistinctTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProTreeDistinctTests : TreeDistinctTestsBase { public SqliteProTreeDistinctTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProTreeLevelAnalyticsTests.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/SqlitePro/SqliteProTreeLevelAnalyticsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProTreeLevelAnalyticsTests : TreeLevelAnalyticsTestsBase { public SqliteProTreeLevelAnalyticsTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProTreeOrderAndPreviewTests.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/SqlitePro/SqliteProTreeOrderAndPreviewTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProTreeOrderAndPreviewTests : TreeOrderAndPreviewTestsBase { public SqliteProTreeOrderAndPreviewTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProTreeQueryShapesTests.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/SqlitePro/SqliteProTreeQueryShapesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProTreeQueryShapesTests : TreeQueryShapesTestsBase { public SqliteProTreeQueryShapesTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProTreeTests.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/SqlitePro/SqliteProTreeTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProTreeTests : ProTreeTestsBase { public SqliteProTreeTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProTypeChangeTicksAndKeysTests.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/SqlitePro/SqliteProTypeChangeTicksAndKeysTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProTypeChangeTicksAndKeysTests : TypeChangeTicksAndKeysTestsBase { public SqliteProTypeChangeTicksAndKeysTests(SqliteProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } protected override string TextType => "TEXT"; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProUniqueKeyTests.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/SqlitePro/SqliteProUniqueKeyTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProUniqueKeyTests : UniqueKeyTestsBase { public SqliteProUniqueKeyTests(SqliteProFixture fixture) : base(fixture.Redb) { } protected override string BoolTrue => "1"; // See SqliteUniqueKeyTests: the driver message carries no key tuple. protected override bool ReportsKeyTuple => false; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProUniqueUpgradeTests.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/SqlitePro/SqliteProUniqueUpgradeTests.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core.Pro.Extensions; using redb.SQLite.Data; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Fixtures; namespace redb.Tests.Integration.Tests.SqlitePro; /// /// The same pre-V4 file, opened by a Pro build. Pro used to skip the whole deployment pass on the /// grounds that its queries are generated in C# - true of the module's functions, but the pass also /// carries the schema upgrades, so a pre-V4 file stayed without _values._unique and every start /// died on the first read of a scheme. Each test gets its own file (the base class owns the path), /// so this runs beside the Free suite. /// public class SqliteProUniqueUpgradeTests : redb.Tests.Integration.Tests.Sqlite.SqliteUniqueUpgradeTests { protected override ServiceProvider BuildServices(string connectionString) { SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); // UseSqlite resolves to the Pro overload through this file's using of redb.SQLite.Pro.Extensions. services.AddRedbPro(options => options.UseSqlite(connectionString)); return services.BuildServiceProvider(); } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProUnregisteredTreeTargetTests.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/SqlitePro/SqliteProUnregisteredTreeTargetTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProUnregisteredTreeTargetTests : UnregisteredTreeTargetTestsBase { public SqliteProUnregisteredTreeTargetTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProUserConfigurationServiceTests.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/SqlitePro/SqliteProUserConfigurationServiceTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProUserConfigurationServiceTests : UserConfigurationServiceTestsBase { public SqliteProUserConfigurationServiceTests(SqliteProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProValueOnlyObjectSaveTests.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/SqlitePro/SqliteProValueOnlyObjectSaveTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProValueOnlyObjectSaveTests : ValueOnlyObjectSaveTestsBase { public SqliteProValueOnlyObjectSaveTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProValueUniqueTests.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/SqlitePro/SqliteProValueUniqueTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProValueUniqueTests : ValueUniqueTestsBase { public SqliteProValueUniqueTests(SqliteProFixture fixture) : base(fixture.Redb, fixture.ServiceProvider) { } /// SQLite names only columns - the violated structure is not resolvable. protected override bool DriverReportsViolatedStructure => false; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProValuesFkIndexesTests.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/SqlitePro/SqliteProValuesFkIndexesTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProValuesFkIndexesTests : ValuesFkIndexesTestsBase { public SqliteProValuesFkIndexesTests(SqliteProFixture fixture) : base(fixture.Redb) { } protected override async Task IndexExistsAsync(string indexName) => await Redb.Context.ExecuteScalarAsync( "SELECT COUNT(*) FROM sqlite_master WHERE type = 'index' AND name = '{0}'".Replace("{0}", indexName)) > 0; } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProWhereTests.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/SqlitePro/SqliteProWhereTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProWhereTests : WhereTestsBase { public SqliteProWhereTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProWideEqualityLeadsTests.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/SqlitePro/SqliteProWideEqualityLeadsTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProWideEqualityLeadsTests : WideEqualityLeadsTestsBase { public SqliteProWideEqualityLeadsTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProWindowTests.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/SqlitePro/SqliteProWindowTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; namespace redb.Tests.Integration.Tests.SqlitePro; [Collection("SqlitePro")] public class SqliteProWindowTests : ProWindowTestsBase { public SqliteProWindowTests(SqliteProFixture fixture) : base(fixture.Redb) { } } Path: redb/redb.Tests.Integration/Tests/Unit/AmbientConnectionRegistryTests.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/Unit/AmbientConnectionRegistryTests.cs ---- using System.Data.Common; using System.Transactions; using Microsoft.Data.Sqlite; using redb.Core.Data; namespace redb.Tests.Integration.Tests.Unit; /// /// The registry opens one connection per ambient transaction and database (review after 4.0.0, finding 5). The open ran /// under one process-wide lock, and on SQLite the open includes BEGIN IMMEDIATE - a wait for the database write /// lock up to the busy timeout - so one transaction waiting for one SQLite file held the first open of every other /// transaction on every database. The lock is per transaction and database now. /// public class AmbientConnectionRegistryTests { [Fact] public async Task OpeningForOneTransaction_DoesNotWaitBehindAnotherTransactionsOpen() { using var slowTx = new CommittableTransaction(); using var fastTx = new CommittableTransaction(); var tag = Guid.NewGuid().ToString("N"); var slowStarted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var release = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var slow = AmbientConnectionRegistry.GetOrOpenAsync(slowTx, $"unit-slow-{tag}", "sig", async _ => { slowStarted.SetResult(); await release.Task; return (DbConnection)new SqliteConnection("Data Source=:memory:"); }, beginOwnTransaction: null); await slowStarted.Task; var fast = AmbientConnectionRegistry.GetOrOpenAsync(fastTx, $"unit-fast-{tag}", "sig", _ => Task.FromResult((DbConnection)new SqliteConnection("Data Source=:memory:")), beginOwnTransaction: null); var first = await Task.WhenAny(fast, Task.Delay(TimeSpan.FromSeconds(2))); release.SetResult(); await slow; first.Should().BeSameAs(fast, "the open of one transaction's connection (SQLite waiting for its write lock) must not hold the first open " + "of every other transaction"); await fast; slowTx.Rollback(); fastTx.Rollback(); } } Path: redb/redb.Tests.Integration/Tests/Unit/ArrayGroupingTests.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/Unit/ArrayGroupingTests.cs ---- using System.Linq.Expressions; using System.Text.Json; using redb.Core.Pro.Models; using redb.Core.Pro.Query; using redb.Core.Query.Aggregation; using redb.Core.Query.Grouping; using redb.Postgres.Sql; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Unit; /// /// GroupByArray without a database: the condition of a conditional count, the strict /// reading of aggregates, the array path, the shared Pro builder, the strict reading of the result. /// public class ArrayGroupingTests { // ---- condition of Agg.Count --------------------------------------------------------------------------------- private static string Condition(Expression> predicate, GroupItemKind kind = GroupItemKind.ArrayClassElement) => ItemPredicateParser.ToJson(predicate, kind, "test"); [Fact] public void Condition_BooleanField_IsEqualToTrue() => Condition(c => c.IsVerified).Should().Be("{\"$eq\":[{\"$field\":\"IsVerified\"},{\"$const\":true}]}"); [Fact] public void Condition_NullTests_AreIsNullAndNotNull() { Condition(c => c.Value == null).Should().Be("{\"$isnull\":{\"$field\":\"Value\"}}"); Condition(c => null != c.Value).Should().Be("{\"$notnull\":{\"$field\":\"Value\"}}"); } [Fact] public void Condition_LogicAndCapturedConstants() { var type = "email"; Condition(c => !c.IsVerified || c.Type == type).Should().Be( "{\"$or\":[{\"$not\":{\"$eq\":[{\"$field\":\"IsVerified\"},{\"$const\":true}]}},{\"$eq\":[{\"$field\":\"Type\"},{\"$const\":\"email\"}]}]}"); } [Fact] public void Condition_NestedField_And_ElementOfASimpleArray() { Condition(i => i.Place!.City == "Riga").Should().Be("{\"$eq\":[{\"$field\":\"Place.City\"},{\"$const\":\"Riga\"}]}"); Condition(x => x > 5, GroupItemKind.ArrayValueElement).Should().Be("{\"$gt\":[{\"$field\":\"$element\"},{\"$const\":5}]}"); } [Fact] public void Condition_StringMethod_IsRefusedWithWhatIsSupported() { var act = () => Condition(c => c.Value.Contains("x")); act.Should().Throw().WithMessage("*condition of Agg.Count may compare a field*"); } [Fact] public void Condition_OrderingAgainstNull_IsRefused() { var act = () => Condition(i => i.Size > (int?)null); act.Should().Throw(); } // ---- HAVING and strict aggregates --------------------------------------------------------------------------- [Fact] public void Having_ConditionalCount_CarriesItsFilter() { Expression, bool>> having = g => Agg.Count(g, c => c.IsVerified) > 1; HavingPredicateParser.ToJson(having, GroupItemKind.ArrayClassElement).Should().Be( "{\"$gt\":[{\"$count\":\"*\",\"filter\":{\"$eq\":[{\"$field\":\"IsVerified\"},{\"$const\":true}]}},{\"$const\":1}]}"); } [Fact] public void Having_ComputedAggregate_IsRefused() { Expression, bool>> having = g => Agg.Sum(g, e => e.Salary * 2) > 1; var act = () => HavingPredicateParser.ToJson(having); act.Should().Throw().WithMessage("*computation*"); } [Fact] public void Aggregate_TheWholeObject_IsRefused() { Expression, bool>> having = g => Agg.Count(g) > 0 && Agg.Max(g, e => e) != null; var act = () => HavingPredicateParser.ToJson(having); act.Should().Throw(); } // ---- array path ----------------------------------------------------------------------------------------------- private static RedbArrayGroupedQueryable Grouping( Expression>> array, Expression> key) where TProps : class, new() => new(null!, 1, null, null, array, key); [Fact] public void ArrayPath_SelectManyWithAResultSelector_IsRefused() { var act = () => Grouping(e => e.Contacts!.SelectMany(c => c.Metadata!, (c, m) => m), m => m.Label); act.Should().Throw().WithMessage("*result selector*"); } [Fact] public void ArrayPath_ComputedCollection_IsRefused() { var act = () => Grouping(e => e.Contacts!.Where(c => c.IsVerified), c => c.Type); act.Should().Throw().WithMessage("*SelectMany over an inner array*"); } [Fact] public void ElementKey_OnAnArrayOfClasses_IsRefused() { var act = () => Grouping(e => e.Contacts!, c => c); act.Should().Throw(); } // ---- shared Pro builder ---------------------------------------------------------------------------------------- private static readonly Dictionary<(long? Parent, string Name), SchemeMetadataCacheRow> Meta = new() { [(null, "Contacts")] = Row(10, "Guid", "Class", "Array"), [(10, "Type")] = Row(11, "String", "String", null), [(10, "IsVerified")] = Row(12, "Boolean", "Boolean", null), [(10, "Metadata")] = Row(13, "Guid", "Class", "Array"), [(13, "Label")] = Row(14, "String", "String", null), [(null, "Skills")] = Row(20, "String", "String", "Array"), [(null, "Items")] = Row(30, "Guid", "Class", "Array"), [(30, "Place")] = Row(31, "Guid", "Class", null), [(31, "City")] = Row(32, "String", "String", null), [(null, "Directory")] = Row(40, "String", "String", "Dictionary"), }; private static SchemeMetadataCacheRow Row(long sid, string dbType, string typeName, string? collection) => new() { StructureId = sid, DbType = dbType, TypeName = typeName, CollectionTypeName = collection }; private static Task BuildAsync(string arrayPath, string[] keys, IReadOnlyList? aggregations = null, ArrayGroupSqlBuilder.IdSource? ids = null, string? havingJson = null) { var builder = new ArrayGroupSqlBuilder(new PostgreSqlDialect(), (scheme, name, parent, ct) => Task.FromResult(Meta.GetValueOrDefault((parent, name))), "test"); var query = new ArrayGroupQuery { SchemeId = 7, ArrayPath = arrayPath, GroupFields = keys.Select((k, i) => new GroupFieldRequest { FieldPath = k, Alias = "k" + i }).ToList(), Aggregations = aggregations ?? [new AggregateRequest { FieldPath = "*", Function = AggregateFunction.Count, Alias = "c" }], HavingJson = havingJson }; query.EnsureValid(); var collector = new SqlParameterCollector(new PostgreSqlDialect()); return builder.BuildAsync(query, collector, _ => Task.FromResult(ids), rankingNeedsOrder: false, CancellationToken.None) .ContinueWith(t => t.Result.Select); } [Fact] public async Task Builder_InnerArray_ReadsTheLastArrayByItsStructure() { var sql = await BuildAsync("Contacts.Metadata", ["Label"]); sql.Should().Contain("arr._id_structure = 13").And.Contain("_id_structure = 14") .And.Contain("._array_parent_id = arr._id").And.Contain("._array_parent_id IS NOT NULL") .And.NotContain("= 10"); } [Fact] public async Task Builder_FieldOfAClassInsideTheElement_JoinsThroughTheClass() { var sql = await BuildAsync("Items", ["Place.City"]); sql.Should().Contain("e1._array_parent_id = arr._id AND e1._id_structure = 31") .And.Contain("e2._array_parent_id = e1._id AND e2._id_structure = 32") .And.Contain("e2._string"); } [Fact] public async Task Builder_ElementOfASimpleArray_ReadsTheElementRow() => (await BuildAsync("Skills", [GroupFieldRequest.ElementPath])).Should().Contain("arr._string").And.NotContain("LEFT JOIN"); [Fact] public async Task Builder_ConditionalCount_IsACaseInsideCount() { var sql = await BuildAsync("Contacts", ["Type"], [new AggregateRequest { FieldPath = "*", Function = AggregateFunction.Count, Alias = "v", ConditionJson = "{\"$eq\":[{\"$field\":\"IsVerified\"},{\"$const\":true}]}" }]); sql.Should().Contain("COUNT(CASE WHEN (e").And.Contain("_boolean = "); } [Fact] public async Task Builder_WithIds_StartsFromThem() { var sql = await BuildAsync("Contacts", ["Type"], ids: new ArrayGroupSqlBuilder.IdSource("SELECT 1 AS _id")); sql.Should().Contain("FROM (SELECT 1 AS _id) f").And.Contain("arr._id_object = f._id"); } [Theory] [InlineData("Contacts", "$element", "*names the element itself*")] [InlineData("Contacts", "$foo", "*is not a field of the elements*")] [InlineData("Skills", "Name", "*simple values*")] [InlineData("Contacts", "Metadata", "*collection inside the element*")] [InlineData("Items", "Place", "*is a class*")] [InlineData("Directory", "$element", "*dictionary*")] public async Task Builder_WhatItCannotAnswer_IsRefused(string arrayPath, string key, string message) { var act = () => BuildAsync(arrayPath, [key]); await act.Should().ThrowAsync().WithMessage(message); } [Fact] public async Task Builder_UnknownField_Throws() { var act = () => BuildAsync("Contacts", ["Missing"]); await act.Should().ThrowAsync().WithMessage("*is not a field of the elements*"); } // ---- request and result ---------------------------------------------------------------------------------------- [Fact] public void Request_WithoutKeys_IsRefused() { var query = new ArrayGroupQuery { SchemeId = 1, ArrayPath = "Contacts", GroupFields = [], Aggregations = [] }; var act = () => query.EnsureValid(); act.Should().Throw(); } [Fact] public void Result_NotAnArray_OrWithoutAColumn_IsAnError() { Expression, object>> selector = g => new { Type = g.Key, C = Agg.Count(g) }; var keys = new List { new() { FieldPath = "Type", Alias = "Type" } }; var notArray = () => ArrayGroupMaterializer.Materialize(JsonDocument.Parse("{}"), selector, keys, "p", "test"); notArray.Should().Throw(); var missing = () => ArrayGroupMaterializer.Materialize(JsonDocument.Parse("[{\"Type\":\"a\"}]"), selector, keys, "p", "test"); missing.Should().Throw().WithMessage("*without the column 'C'*"); var nullKey = ArrayGroupMaterializer.Materialize(JsonDocument.Parse("[{\"Type\":null,\"C\":2}]"), selector, keys, "p", "test"); nullKey.Should().ContainSingle(); } } Path: redb/redb.Tests.Integration/Tests/Unit/BulkInsertTimeoutTests.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/Unit/BulkInsertTimeoutTests.cs ---- using System; using AwesomeAssertions; using Microsoft.Data.SqlClient; using Microsoft.Extensions.DependencyInjection; using redb.Core.Data; using redb.Core.Extensions; using redb.Core.Models.Configuration; using redb.Core.Pro.Extensions; using redb.MSSql.Data; using redb.Postgres.Data; using Xunit; namespace redb.Tests.Integration.Tests.Unit; /// /// The timeout of the bulk load of a save. SqlBulkCopy has its own timeout of 30 seconds, which the connection string's /// Command Timeout does not reach, so a large AddNewObjectsAsync on a busy SQL Server failed with no setting to turn. /// goes from the configuration through the context that the /// provider registers to the bulk operations and onto SqlBulkCopy (and the PostgreSQL binary importer). Shown on the /// configured objects; no server is opened. /// public class BulkInsertTimeoutTests { private const string MsSqlConnectionString = "Server=unused;Database=unused;User Id=u;Password=p;TrustServerCertificate=true"; private const string PostgresConnectionString = "Host=unused;Database=unused;Username=u;Password=p"; [Fact] public void Default_keeps_the_driver_value() => new RedbServiceConfiguration().BulkInsertTimeout.Should().BeNull(); [Fact] public void Negative_timeout_is_refused_and_zero_is_no_limit() { var config = new RedbServiceConfiguration(); config.Invoking(c => c.BulkInsertTimeout = TimeSpan.FromSeconds(-1)) .Should().Throw().WithParameterName(nameof(RedbServiceConfiguration.BulkInsertTimeout)); config.BulkInsertTimeout = TimeSpan.Zero; config.BulkInsertTimeout.Should().Be(TimeSpan.Zero); } [Theory] [InlineData(null, 30)] // the driver's own default stays [InlineData(0.0, 0)] // no limit [InlineData(1.2, 2)] // rounded up, never shorter than asked [InlineData(300.0, 300)] public void SqlBulkCopy_takes_the_timeout(double? seconds, int expected) { using var connection = new SqlConnection(MsSqlConnectionString); using var bulkCopy = new SqlBulkCopy(connection); SqlBulkOperations.ApplyTimeout(bulkCopy, seconds is { } s ? TimeSpan.FromSeconds(s) : null); bulkCopy.BulkCopyTimeout.Should().Be(expected); } [Fact] public void MsSql_free_registration_hands_the_timeout_to_the_bulk_operations() { var services = new ServiceCollection(); services.AddRedb(o => redb.MSSql.Extensions.MsSqlOptionsExtensions.UseMsSql(o, MsSqlConnectionString) .Configure(c => c.BulkInsertTimeout = TimeSpan.FromMinutes(5))); BulkTimeoutOf(services, b => b.TimeoutSource()).Should().Be(TimeSpan.FromMinutes(5)); } [Fact] public void MsSql_pro_registration_hands_the_timeout_to_the_bulk_operations() { var services = new ServiceCollection(); services.AddRedbPro(o => redb.MSSql.Pro.Extensions.MsSqlProOptionsExtensions.UseMsSql(o, MsSqlConnectionString) .Configure(c => c.BulkInsertTimeout = TimeSpan.FromMinutes(5))); BulkTimeoutOf(services, b => b.TimeoutSource()).Should().Be(TimeSpan.FromMinutes(5)); } [Fact] public void Postgres_free_registration_hands_the_timeout_to_the_bulk_operations() { var services = new ServiceCollection(); services.AddRedb(o => redb.Postgres.Extensions.PostgresOptionsExtensions.UsePostgres(o, PostgresConnectionString) .Configure(c => c.BulkInsertTimeout = TimeSpan.FromMinutes(5))); BulkTimeoutOf(services, b => b.TimeoutSource()).Should().Be(TimeSpan.FromMinutes(5)); } [Fact] public void Postgres_pro_registration_hands_the_timeout_to_the_bulk_operations() { var services = new ServiceCollection(); services.AddRedbPro(o => redb.Postgres.Pro.Extensions.PostgresProOptionsExtensions.UsePostgres(o, PostgresConnectionString) .Configure(c => c.BulkInsertTimeout = TimeSpan.FromMinutes(5))); BulkTimeoutOf(services, b => b.TimeoutSource()).Should().Be(TimeSpan.FromMinutes(5)); } [Fact] public void Without_the_setting_the_bulk_operations_keep_the_driver_value() { var services = new ServiceCollection(); services.AddRedbPro(o => redb.MSSql.Pro.Extensions.MsSqlProOptionsExtensions.UseMsSql(o, MsSqlConnectionString)); BulkTimeoutOf(services, b => b.TimeoutSource()).Should().BeNull(); } private static TimeSpan? BulkTimeoutOf(IServiceCollection services, Func read) where TBulk : class, IBulkOperations { using var sp = services.BuildServiceProvider(); using var scope = sp.CreateScope(); var context = scope.ServiceProvider.GetRequiredService(); context.Bulk.Should().BeOfType(); return read((TBulk)context.Bulk); } } Path: redb/redb.Tests.Integration/Tests/Unit/ClrSchemeTypeIndexAlcTests.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/Unit/ClrSchemeTypeIndexAlcTests.cs ---- using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Loader; using redb.Core.Caching; using redb.Core.Exceptions; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Unit; /// /// C1 — collectible-ALC safety of the process-global . /// The index must (a) never pin a hot-reloaded plugin's (weak references, so the ALC /// can unload) and (b) treat the same logical type reloaded into a new ALC as a reload, not a name /// conflict. /// /// Runs in its own collection: the index is process-global static, so these tests must not race the /// scheme-naming suite that also drives it. /// /// [Collection("ClrSchemeTypeIndex")] public class ClrSchemeTypeIndexAlcTests { // Loading is factored into a no-inline method so no JIT-local keeps the ALC/type alive past Unload(). [MethodImpl(MethodImplOptions.NoInlining)] private static WeakReference RegisterTypeFromCollectibleAlc(string schemeName) { var alc = new AssemblyLoadContext("c1-leak-probe", isCollectible: true); var asm = alc.LoadFromAssemblyPath(typeof(NamingPinnedProps).Assembly.Location); var type = asm.GetType(typeof(NamingPinnedProps).FullName!)!; // The index stores only a WeakReference, so this registration must not keep the ALC alive. ClrSchemeTypeIndex.Register(schemeName, type); var weak = new WeakReference(alc); alc.Unload(); return weak; } [Fact] public void UnloadedAlc_IsCollected_IndexDoesNotPinIt() { ClrSchemeTypeIndex.Clear(); try { var weakAlc = RegisterTypeFromCollectibleAlc("c1.leak"); for (var i = 0; i < 15 && weakAlc.IsAlive; i++) { GC.Collect(); GC.WaitForPendingFinalizers(); } weakAlc.IsAlive.Should().BeFalse( "a strong Type reference in the static index would pin the collectible ALC forever (memory leak on every hot-reload)"); // The dead entry must resolve to null (pruned lazily), not throw. ClrSchemeTypeIndex.Resolve("c1.leak").Should().BeNull(); } finally { ClrSchemeTypeIndex.Clear(); } } // The whole assembly of the host's types loaded again into a collectible ALC (SqliteProModuleUnloadTests does // exactly this), scanned while it lives, then unloaded. [MethodImpl(MethodImplOptions.NoInlining)] private static WeakReference ScanHostAssemblyFromCollectibleAlc() { var alc = new AssemblyLoadContext("c1-host-copy", isCollectible: true); var copy = alc.LoadFromAssemblyPath(typeof(NamingByTypeProps).Assembly.Location).GetType(typeof(NamingByTypeProps).FullName!)!; copy.Should().NotBeSameAs(typeof(NamingByTypeProps)); // Scanned last, right before the unload: an assembly loaded after the scan would bring a rescan of its own, // and that one would no longer see the copy. In a long run every assembly is long loaded and none comes. var weak = new WeakReference(alc); ClrSchemeTypeIndex.EnsureFresh(); alc.Unload(); return weak; } [Fact] public void CopyInAnUnloadedAlc_LeavesTheNamesToTheLiveType() { // The scan let the copy overwrite the entries of the host's own type (same names, last write wins); once the // copy was collected they resolved to null, though the host's type was alive. The order of the integration // run decided whether ClrSchemeTypeIndex_ResolvesAliasToo came after such a module test and failed. ClrSchemeTypeIndex.Clear(); try { // Everything the assertions load is loaded now, before the scan. typeof(NamingByTypeProps).Should().Be(typeof(NamingByTypeProps)); false.Should().BeFalse(); ClrSchemeTypeIndex.EnsureFresh(); var weakAlc = ScanHostAssemblyFromCollectibleAlc(); var alive = true; for (var i = 0; i < 15 && (alive = weakAlc.IsAlive); i++) { GC.Collect(); GC.WaitForPendingFinalizers(); } // As in a long run, where no assembly loads any more: whatever the runner loaded meanwhile on its own // threads is taken as scanned, so the lookups below get no rescan from a load. var index = typeof(ClrSchemeTypeIndex); var generation = (long)index.GetField("_assemblyGeneration", BindingFlags.NonPublic | BindingFlags.Static)!.GetValue(null)!; index.GetField("_scannedGeneration", BindingFlags.NonPublic | BindingFlags.Static)!.SetValue(null, generation); var alias = ClrSchemeTypeIndex.Resolve("Именование: по типу"); var pinned = ClrSchemeTypeIndex.Resolve("naming.pinned"); alive.Should().BeFalse("precondition: the copy is gone"); alias.Should().Be(typeof(NamingByTypeProps), "the alias of the host's type"); pinned.Should().Be(typeof(NamingPinnedProps), "an explicit scheme name of the host's type"); } finally { ClrSchemeTypeIndex.Clear(); } } [Fact] public void SameTypeReloadedInNewAlc_IsNotReportedAsConflict() { ClrSchemeTypeIndex.Clear(); AssemblyLoadContext? alc = null; try { var loc = typeof(NamingPinnedProps).Assembly.Location; var fullName = typeof(NamingPinnedProps).FullName!; // Same logical type (identical FullName, same explicit Name "naming.pinned") loaded into a // separate ALC — exactly what a Tsak module hot-reload produces. The old code compared only // (owner != type && same Name) and would flag this as a false conflict; the reload guard // (same FullName across ALCs = reload) must suppress it. alc = new AssemblyLoadContext("c1-reload-probe", isCollectible: true); var reloaded = alc.LoadFromAssemblyPath(loc).GetType(fullName)!; reloaded.Should().NotBeSameAs(typeof(NamingPinnedProps), "must be a distinct Type instance from another ALC"); reloaded.FullName.Should().Be(fullName); // A rescan now sees both the default-ALC type and the reloaded one under "naming.pinned". ClrSchemeTypeIndex.EnsureFresh(); // Must NOT throw — this is a reload, not a genuine two-distinct-types clash. var act = () => ClrSchemeTypeIndex.ThrowIfNameConflict("naming.pinned", reloaded); act.Should().NotThrow(); // And the name still resolves to a live type. ClrSchemeTypeIndex.Resolve("naming.pinned").Should().NotBeNull(); } finally { ClrSchemeTypeIndex.Clear(); alc?.Unload(); } } } Path: redb/redb.Tests.Integration/Tests/Unit/CollationNameValidatorTests.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/Unit/CollationNameValidatorTests.cs ---- using redb.Core.Models.Configuration; using redb.Core.Query; namespace redb.Tests.Integration.Tests.Unit; /// /// The collation name reaches generated SQL as an identifier, which cannot be a bound /// parameter, so it is concatenated into SQL text. That makes it an injection point reachable from /// application configuration, and it is defended twice: rejected at assignment, quoted at emission. /// Both defences are tested separately, because a test that only exercised one would let the other /// rot unnoticed. /// public class CollationNameValidatorTests { [Theory] [InlineData("und-x-icu")] [InlineData("ru-x-icu")] [InlineData("en_US.utf8")] [InlineData("C")] [InlineData("POSIX")] [InlineData("de-DE-x-icu")] public void Accepts_RealCollationNames(string name) { CollationNameValidator.IsValid(name).Should().BeTrue(); var act = () => CollationNameValidator.Validate(name); act.Should().NotThrow(); } [Theory] [InlineData("x\" OR 1=1--")] // the injection this exists to stop [InlineData("und-x-icu; DROP TABLE _objects")] [InlineData("und x icu")] // space [InlineData("und'x'icu")] // single quote [InlineData("-leading-dash")] [InlineData("")] [InlineData(" ")] public void Rejects_AnythingThatIsNotAPlainIdentifier(string name) { CollationNameValidator.IsValid(name).Should().BeFalse(); var act = () => CollationNameValidator.Validate(name); act.Should().Throw(); } [Fact] public void Rejects_OverlongName() { var name = new string('a', CollationNameValidator.MaxLength + 1); var act = () => CollationNameValidator.Validate(name); act.Should().Throw(); } /// /// Quoting is asserted on input the validator would already reject. The escaping has to be /// correct on its own rather than because something upstream promised the case cannot arise: /// two independent defences, not one defence and one assumption. /// [Fact] public void Quote_DoublesEmbeddedQuotes_EvenThoughValidateWouldReject() { CollationNameValidator.Quote("und-x-icu").Should().Be("\"und-x-icu\""); CollationNameValidator.Quote("x\" OR 1=1--").Should().Be("\"x\"\" OR 1=1--\""); } /// /// The setting validates on assignment, so a typo fails at startup naming the setting, instead /// of surfacing later as a driver syntax error on the first search query. /// [Fact] public void Configuration_RejectsBadNameAtAssignment() { var config = new RedbServiceConfiguration(); var act = () => config.StringCollation = "x\" OR 1=1--"; act.Should().Throw(); } [Fact] public void Configuration_AcceptsGoodNameAndTrims() { var config = new RedbServiceConfiguration(); config.StringCollation = " und-x-icu "; config.StringCollation.Should().Be("und-x-icu"); } /// Empty and whitespace normalise to null, which is the "feature off" state. [Theory] [InlineData(null)] [InlineData("")] [InlineData(" ")] public void Configuration_BlankMeansOff(string? value) { var config = new RedbServiceConfiguration { StringCollation = value }; config.StringCollation.Should().BeNull(); } [Fact] public void Configuration_DefaultsToOff() { new RedbServiceConfiguration().StringCollation.Should().BeNull(); } } Path: redb/redb.Tests.Integration/Tests/Unit/CollectibleAlcCacheTests.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/Unit/CollectibleAlcCacheTests.cs ---- using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Loader; using System.Text.Json; using redb.Core.Caching; using redb.Core.Models.Entities; using redb.Core.Pro.Materialization; using redb.Core.Providers.Base; using redb.Core.Serialization; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Unit; /// /// A module of Tsak lives in a collectible AssemblyLoadContext and must unload: no process-wide redb cache may keep a /// type of it, a member of such a type or an instance of one alive once the context unloads. Each test touches one /// cache with a type loaded into a fresh collectible context, unloads it and checks the context is collected. The /// test assembly itself is loaded into the context, so its types are distinct from the ones of the default context /// while redb.Core and redb.Core.Pro resolve from the default context, as for a real module. /// [Collection("ClrSchemeTypeIndex")] public class CollectibleAlcCacheTests { // A running redb service starts the watch; these tests use the caches without one. public CollectibleAlcCacheTests() => CollectibleContextCleanup.EnsureWatching(); private static Type LoadPropsType(AssemblyLoadContext alc) => alc.LoadFromAssemblyPath(typeof(NamingPinnedProps).Assembly.Location).GetType(typeof(NamingPinnedProps).FullName!)!; private static void AssertCollected(WeakReference weakAlc, string cache) { for (var i = 0; i < 20 && weakAlc.IsAlive; i++) { GC.Collect(); GC.WaitForPendingFinalizers(); } weakAlc.IsAlive.Should().BeFalse($"{cache} must not keep the unloaded module's context alive"); } [MethodImpl(MethodImplOptions.NoInlining)] private static WeakReference TouchAndUnload(string name, Action touch) { var alc = new AssemblyLoadContext(name, isCollectible: true); touch(LoadPropsType(alc)); var weak = new WeakReference(alc); alc.Unload(); return weak; } private static object NewRedbObject(Type propsType, long id) { var obj = (RedbObject)Activator.CreateInstance(typeof(RedbObject<>).MakeGenericType(propsType))!; obj.id = id; obj.hash = Guid.NewGuid(); return obj; } [Fact] public void MetadataCache_SchemeIdToType_DoesNotPinTheModule() { var cache = new GlobalMetadataCache("alc-probe-metadata"); var weak = TouchAndUnload("alc-metadata", type => { cache.RegisterClrType("alc.probe.metadata", 9_100_001, type); cache.GetClrType(9_100_001).Should().BeSameAs(type); cache.GetSchemeIdByClrType(type).Should().Be(9_100_001); }); AssertCollected(weak, "GlobalMetadataCache (scheme_id <-> Type)"); cache.GetClrType(9_100_001).Should().BeNull("the type is gone with its context"); } [Fact] public void SavePipeline_TypePredicates_DoNotPinTheModule() { var predicates = new[] { "IsRedbObjectType", "IsRedbObjectArrayType", "IsDictionaryWithRedbObjectValue", "IsBusinessClassType" } .Select(n => typeof(ObjectStorageProviderBase).GetMethod(n, BindingFlags.NonPublic | BindingFlags.Static) ?? throw new InvalidOperationException($"{n} not found")) .ToArray(); var weak = TouchAndUnload("alc-save-predicates", type => { var redbObjectType = typeof(RedbObject<>).MakeGenericType(type); foreach (var probe in new[] { type, redbObjectType, typeof(List<>).MakeGenericType(redbObjectType), typeof(Dictionary<,>).MakeGenericType(typeof(string), redbObjectType) }) foreach (var predicate in predicates) predicate.Invoke(null, [probe]); }); AssertCollected(weak, "the type predicates of the save pipeline"); } [Fact] public void ProMaterializer_TypeCaches_DoNotPinTheModule() { // Every per-type cache of the materializer: the open-instance delegates of the class recursion and of GetObjectProps, // the list, stub and dictionary factories, and a property slot with its compiled setter, each filled with a type // of the module and used once. static MethodInfo Member(string name) => typeof(ProPropsMaterializer).GetMethod(name, BindingFlags.NonPublic | BindingFlags.Static) ?? throw new InvalidOperationException($"{name} not found"); var getBuildFn = Member("GetBuildFn"); var getObjectPropsFor = Member("GetObjectPropsFor"); var newList = Member("NewList"); var newStub = Member("NewStub"); var getDictionaryPlan = Member("GetDictionaryPlan"); var findSlot = Member("FindSlot"); var weak = TouchAndUnload("alc-materializer", type => { ((Delegate)getBuildFn.Invoke(null, [type])!).Method.GetGenericArguments().Should().Equal(type); ((Delegate)getObjectPropsFor.Invoke(null, [type])!).Method.GetGenericArguments().Should().Equal(type); newList.Invoke(null, [type]).Should().BeAssignableTo(typeof(List<>).MakeGenericType(type)); var redbObjectType = typeof(RedbObject<>).MakeGenericType(type); ((RedbObject)newStub.Invoke(null, [redbObjectType, 7L])!).id.Should().Be(7); getDictionaryPlan.Invoke(null, [typeof(Dictionary<,>).MakeGenericType(typeof(string), type)]).Should().NotBeNull(); var slot = findSlot.Invoke(null, [type, "Title"])!; var instance = Activator.CreateInstance(type)!; slot.GetType().GetMethod("Assign")!.Invoke(slot, [instance, "set through the compiled setter"]); type.GetProperty("Title")!.GetValue(instance).Should().Be("set through the compiled setter"); }); AssertCollected(weak, "the per-type caches of ProPropsMaterializer"); } [Fact] public void SerializerOptions_DoNotPinTheModule() { var weak = TouchAndUnload("alc-serializer", type => { var redbObjectType = typeof(RedbObject<>).MakeGenericType(type); var json = JsonSerializer.Serialize(NewRedbObject(type, 1), redbObjectType, SystemTextJsonRedbSerializer.Options); JsonSerializer.Deserialize(json, redbObjectType, SystemTextJsonRedbSerializer.Options).Should().NotBeNull(); }); AssertCollected(weak, "the static JsonSerializerOptions of the serializer"); } [Fact] public void SystemTextJsonOwnCaches_DoNotPinTheModule() { // System.Text.Json caches outside any options instance too (contexts shared by equal options, emitted member // accessors): a module serializing its Props with options of its own must unload as well. var weak = TouchAndUnload("alc-stj", type => { var json = JsonSerializer.Serialize(Activator.CreateInstance(type), type, new JsonSerializerOptions()); JsonSerializer.Deserialize(json, type, new JsonSerializerOptions()).Should().NotBeNull(); }); AssertCollected(weak, "the process-wide caches of System.Text.Json"); } [Fact] public void PropsCache_DropsTheModulesObjects_OnUnload() { var props = new GlobalPropsCache("alc-probe-props"); props.Initialize(new MemoryRedbObjectCache()); var set = typeof(GlobalPropsCache).GetMethod(nameof(GlobalPropsCache.Set))!; const long id = 9_200_001; var weak = TouchAndUnload("alc-props-cache", type => { set.MakeGenericMethod(type).Invoke(props, [NewRedbObject(type, id)]); props.Instance!.GetStats().TotalEntries.Should().Be(1); }); AssertCollected(weak, "the props cache"); props.Instance!.GetStats().TotalEntries.Should().Be(0, "the objects of an unloading context leave the cache"); props.Clear(); } } Path: redb/redb.Tests.Integration/Tests/Unit/CommandGateBudgetTests.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/Unit/CommandGateBudgetTests.cs ---- using redb.Core.Data; namespace redb.Tests.Integration.Tests.Unit; /// /// The teardown wait budget follows the connection's own command timeout (owner decision, /// 2026-09-11: "30 seconds is sometimes just not enough - take it from the connection /// parameter, default otherwise"): a command may legally run right up to its timeout, so /// teardown waits that long plus slack; an infinite command timeout still gets a finite, /// generous budget - disposal must end. /// public class CommandGateBudgetTests { [Theory] [InlineData(600, 605)] [InlineData(30, 35)] [InlineData(1, 6)] public void Budget_FollowsTheCommandTimeout_PlusSlack(int timeoutSeconds, int expectedSeconds) => CommandGate.BudgetFrom(timeoutSeconds).Should().Be(TimeSpan.FromSeconds(expectedSeconds)); [Theory] [InlineData(0)] [InlineData(-1)] public void InfiniteCommandTimeout_StillGetsAFiniteBudget(int timeoutSeconds) => CommandGate.BudgetFrom(timeoutSeconds).Should().Be(TimeSpan.FromMinutes(10)); } Path: redb/redb.Tests.Integration/Tests/Unit/DeadlockRetryHelperAmbientTests.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/Unit/DeadlockRetryHelperAmbientTests.cs ---- using System.Reflection; using System.Transactions; using Npgsql; using redb.Core.Data; namespace redb.Tests.Integration.Tests.Unit; /// /// Inside an /// ambient transaction the deadlock victim's transaction is already rolled back by the server (SQL Server 1205, /// PostgreSQL 40P01). Retrying the command inside it fails with a second error (25P02, aborted transaction) that /// replaces the deadlock the unit of work needs to see. The helper retries only outside an ambient transaction. /// public class DeadlockRetryHelperAmbientTests { private static PostgresException Deadlock() => new("deadlock detected", "ERROR", "ERROR", "40P01"); [Fact] public async Task InsideAmbientTransaction_DeadlockIsNotRetried_TheOriginalLeaves() { var calls = 0; var deadlock = Deadlock(); using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); var act = () => DeadlockRetryHelper.ExecuteWithRetryAsync(() => { calls++; return Task.FromException(deadlock); }, maxRetries: 3, baseDelayMs: 1); (await act.Should().ThrowAsync()).Which.Should().BeSameAs(deadlock); calls.Should().Be(1, "the transaction is already rolled back on the server; a retry inside it cannot succeed"); } [Fact] public async Task InsideAmbientTransaction_TypedOverload_DeadlockIsNotRetried() { var calls = 0; var deadlock = Deadlock(); using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); var act = () => DeadlockRetryHelper.ExecuteWithRetryAsync(() => { calls++; return Task.FromException(deadlock); }, maxRetries: 3, baseDelayMs: 1); (await act.Should().ThrowAsync()).Which.Should().BeSameAs(deadlock); calls.Should().Be(1); } [Fact] public async Task WithoutAmbientTransaction_DeadlockIsRetried() { var calls = 0; var result = await DeadlockRetryHelper.ExecuteWithRetryAsync(() => { calls++; return calls == 1 ? Task.FromException(Deadlock()) : Task.FromResult(42); }, maxRetries: 3, baseDelayMs: 1); result.Should().Be(42); calls.Should().Be(2, "a top-level operation owns its transaction and may run it again"); } [Fact] public async Task UnderSuppressedScope_DeadlockIsRetried() { var calls = 0; using var outer = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); using var suppressed = new TransactionScope(TransactionScopeOption.Suppress, TransactionScopeAsyncFlowOption.Enabled); await DeadlockRetryHelper.ExecuteWithRetryAsync(() => { calls++; return calls == 1 ? Task.FromException(Deadlock()) : Task.CompletedTask; }, maxRetries: 3, baseDelayMs: 1); calls.Should().Be(2, "a suppressed scope has no ambient transaction: the operation owns its own"); } /// A context that answers only; the helper reads nothing else. public class TransactionStateContext : DispatchProxy { public bool InTransaction { get; set; } protected override object? Invoke(MethodInfo? targetMethod, object?[]? args) => targetMethod?.Name == "get_IsInTransaction" ? InTransaction : throw new NotSupportedException(targetMethod?.Name); public static IRedbContext Create(bool inTransaction) { var context = DispatchProxy.Create(); ((TransactionStateContext)(object)context).InTransaction = inTransaction; return context; } } [Fact] public async Task ContextInATransaction_DeadlockIsNotRetried_TheOriginalLeaves() { var calls = 0; var deadlock = Deadlock(); var act = () => DeadlockRetryHelper.ExecuteWithRetryAsync(TransactionStateContext.Create(inTransaction: true), () => { calls++; return Task.FromException(deadlock); }, maxRetries: 3, baseDelayMs: 1); (await act.Should().ThrowAsync()).Which.Should().BeSameAs(deadlock); calls.Should().Be(1, "the transaction belongs to the caller; only the caller can run its unit again"); } [Fact] public async Task ContextInATransaction_TypedOverload_DeadlockIsNotRetried() { var calls = 0; var deadlock = Deadlock(); var act = () => DeadlockRetryHelper.ExecuteWithRetryAsync(TransactionStateContext.Create(inTransaction: true), () => { calls++; return Task.FromException(deadlock); }, maxRetries: 3, baseDelayMs: 1); (await act.Should().ThrowAsync()).Which.Should().BeSameAs(deadlock); calls.Should().Be(1); } [Fact] public async Task ContextWithoutATransaction_DeadlockIsRetried() { var calls = 0; var result = await DeadlockRetryHelper.ExecuteWithRetryAsync(TransactionStateContext.Create(inTransaction: false), () => { calls++; return calls == 1 ? Task.FromException(Deadlock()) : Task.FromResult(7); }, maxRetries: 3, baseDelayMs: 1); result.Should().Be(7); calls.Should().Be(2, "the operation opens and owns its transaction, so it may run again"); } [Fact] public async Task ContextWithoutATransaction_AfterTheLastAttempt_TheDeadlockLeaves() { var calls = 0; var deadlock = Deadlock(); var act = () => DeadlockRetryHelper.ExecuteWithRetryAsync(TransactionStateContext.Create(inTransaction: false), () => { calls++; return Task.FromException(deadlock); }, maxRetries: 2, baseDelayMs: 1); (await act.Should().ThrowAsync()).Which.Should().BeSameAs(deadlock); calls.Should().Be(3, "the first attempt and two retries"); } } Path: redb/redb.Tests.Integration/Tests/Unit/FlatDdlGeneratorTests.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/Unit/FlatDdlGeneratorTests.cs ---- using redb.Core.Attributes; using redb.Core.Models.Entities; using redb.Export.Flat; using redb.Export.Flat.Model; namespace redb.Tests.Integration.Tests.Unit; /// /// DDL of the flat export per provider, without a database: the shared key sequence, the key defaults, the delete /// rules that mirror redb, SQL Server's refusal of a cascade from a table to itself, and the foreign key indexes. /// The model is built from the classes below without structure ids, which the DDL does not need. /// public class FlatDdlGeneratorTests { [RedbScheme("FlatDdlTarget")] public class FlatDdlTargetProps { public string Name { get; set; } = ""; } [RedbScheme("FlatDdlOwner")] public class FlatDdlOwnerProps { public string Title { get; set; } = ""; public FlatDdlAddress? Address { get; set; } public string[]? Tags { get; set; } public RedbObject? Target { get; set; } public RedbListItem? Status { get; set; } } public class FlatDdlAddress { public string City { get; set; } = ""; } private static readonly FlatDatabaseModel Model = new FlatModelBuilder().Build([typeof(FlatDdlOwnerProps), typeof(FlatDdlTargetProps)]); private static FlatTable Table(string name) => Model.Tables.Single(t => t.Name == name); private static string Fks(FlatDdlGenerator ddl, string table) => string.Join("\n", ddl.AddForeignKeys(Table(table))); private static string Indexes(FlatDdlGenerator ddl) => string.Join("\n", Model.Tables.SelectMany(t => ddl.CreateIndexes(t))); [Fact] public void Postgres_SequenceKeyDefaultsDeleteRulesAndIndexes() { var ddl = new FlatDdlGenerator("postgres"); Assert.Equal("CREATE SEQUENCE \"flat_identity\" AS bigint START WITH 1", ddl.CreateSequence()); Assert.Equal("ALTER SEQUENCE \"flat_identity\" RESTART WITH 42", ddl.RestartSequence(42)); // Keys a writer may leave out take the sequence; the scheme table takes the id of its header row. const string keyDefault = "DEFAULT nextval('\"flat_identity\"')"; Assert.Contains(keyDefault, ddl.CreateTable(Table("objects"))); Assert.Contains(keyDefault, ddl.CreateTable(Table("FlatDdlOwnerProps.Tags"))); Assert.DoesNotContain(keyDefault, ddl.CreateTable(Table("FlatDdlOwnerProps"))); Assert.Contains("FOREIGN KEY (\"_id_parent\") REFERENCES \"objects\" (\"_id\") ON DELETE CASCADE", Fks(ddl, "objects")); Assert.Contains("FOREIGN KEY (\"_id\") REFERENCES \"objects\" (\"_id\") ON DELETE CASCADE", Fks(ddl, "FlatDdlOwnerProps")); Assert.Contains("FOREIGN KEY (\"_owner_id\") REFERENCES \"FlatDdlOwnerProps\" (\"_id\") ON DELETE CASCADE", Fks(ddl, "FlatDdlOwnerProps.Address")); Assert.Contains("FOREIGN KEY (\"_owner_id\") REFERENCES \"FlatDdlOwnerProps\" (\"_id\") ON DELETE CASCADE", Fks(ddl, "FlatDdlOwnerProps.Tags")); Assert.Contains("FOREIGN KEY (\"_id_object\") REFERENCES \"objects\" (\"_id\") ON DELETE SET NULL", Fks(ddl, "list_items")); // A reference to another object keeps the referenced row: no delete rule. var target = ddl.AddForeignKeys(Table("FlatDdlOwnerProps")).Single(s => s.Contains("(\"Target\")")); Assert.EndsWith("REFERENCES \"FlatDdlTargetProps\" (\"_id\")", target); var indexes = Indexes(ddl); Assert.Contains("ON \"objects\" (\"_id_parent\")", indexes); Assert.Contains("ON \"FlatDdlOwnerProps\" (\"Target\")", indexes); Assert.Contains("ON \"FlatDdlOwnerProps\" (\"Status\")", indexes); Assert.Contains("ON \"list_items\" (\"_id_list\")", indexes); Assert.Contains("ON \"list_items\" (\"_id_object\")", indexes); } [Fact] public void MsSql_SequenceKeyDefaultsAndNoSelfCascade() { var ddl = new FlatDdlGenerator("mssql"); Assert.Equal("CREATE SEQUENCE [flat_identity] AS bigint START WITH 1", ddl.CreateSequence()); Assert.Equal("ALTER SEQUENCE [flat_identity] RESTART WITH 42", ddl.RestartSequence(42)); const string keyDefault = "DEFAULT (NEXT VALUE FOR [flat_identity])"; Assert.Contains(keyDefault, ddl.CreateTable(Table("objects"))); Assert.DoesNotContain(keyDefault, ddl.CreateTable(Table("FlatDdlOwnerProps"))); // SQL Server refuses a cascade from a table to itself: the parent key goes without it. var parent = ddl.AddForeignKeys(Table("objects")).Single(s => s.Contains("([_id_parent])")); Assert.EndsWith("REFERENCES [objects] ([_id])", parent); // Cascades between different tables stay. Assert.Contains("FOREIGN KEY ([_id]) REFERENCES [objects] ([_id]) ON DELETE CASCADE", Fks(ddl, "FlatDdlOwnerProps")); Assert.Contains("FOREIGN KEY ([_owner_id]) REFERENCES [FlatDdlOwnerProps] ([_id]) ON DELETE CASCADE", Fks(ddl, "FlatDdlOwnerProps.Tags")); Assert.Contains("FOREIGN KEY ([_id_object]) REFERENCES [objects] ([_id]) ON DELETE SET NULL", Fks(ddl, "list_items")); var indexes = Indexes(ddl); Assert.Contains("ON [objects] ([_id_parent])", indexes); Assert.Contains("ON [FlatDdlOwnerProps] ([Target])", indexes); Assert.Contains("ON [FlatDdlOwnerProps] ([Status])", indexes); } [Fact] public void Sqlite_NoSequenceInlineForeignKeysAndIndexes() { var ddl = new FlatDdlGenerator("sqlite"); // SQLite hands out keys per table: no sequence, no default on the key. Assert.Null(ddl.CreateSequence()); Assert.Null(ddl.RestartSequence(42)); Assert.DoesNotContain("DEFAULT", ddl.CreateTable(Table("objects"))); // Foreign keys are part of CREATE TABLE; there is nothing to add after the load. Assert.Empty(Model.Tables.SelectMany(t => ddl.AddForeignKeys(t))); Assert.Contains("FOREIGN KEY (\"_id_parent\") REFERENCES \"objects\" (\"_id\") ON DELETE CASCADE", ddl.CreateTable(Table("objects"))); Assert.Contains("FOREIGN KEY (\"_owner_id\") REFERENCES \"FlatDdlOwnerProps\" (\"_id\") ON DELETE CASCADE", ddl.CreateTable(Table("FlatDdlOwnerProps.Tags"))); Assert.Contains("FOREIGN KEY (\"_id_object\") REFERENCES \"objects\" (\"_id\") ON DELETE SET NULL", ddl.CreateTable(Table("list_items"))); var indexes = Indexes(ddl); Assert.Contains("ON \"objects\" (\"_id_parent\")", indexes); Assert.Contains("ON \"FlatDdlOwnerProps\" (\"Target\")", indexes); } [Theory] [InlineData("postgres")] [InlineData("mssql")] [InlineData("sqlite")] public void Script_CountsTablesForeignKeysAndIndexes(string provider) { var script = new FlatDdlGenerator(provider).Script(Model); var foreignKeys = Model.Tables.Sum(t => t.ForeignKeys.Count); var indexes = Model.Tables.Sum(t => t.Indexes.Count); Assert.StartsWith($"-- redb flat schema: {Model.Tables.Count} tables, {foreignKeys} foreign keys, {indexes} indexes.", script); Assert.Equal(indexes, script.Split("CREATE INDEX ").Length - 1); } } Path: redb/redb.Tests.Integration/Tests/Unit/GlobalMetadataCacheClrTypeTests.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/Unit/GlobalMetadataCacheClrTypeTests.cs ---- using redb.Core.Caching; using redb.Core.Models.Entities; namespace redb.Tests.Integration.Tests.Unit; public class GlobalMetadataCacheClrTypeTests { /// /// A scheme this domain already holds and no loaded type answers to is a scheme without a CLR type. Asking the /// provider for it again loaded the same scheme on every call: a list of 200 items of such a scheme was 200 scheme /// queries. No provider is given here - a call into it is the failure. /// [Fact] public async Task AKnownSchemeWithoutAClrType_IsAnsweredFromTheCache() { var cache = new GlobalMetadataCache($"unit-clr-{Guid.NewGuid():N}"); var scheme = new RedbScheme { Id = 424242, Name = $"unit.no.such.type.{Guid.NewGuid():N}" }; cache.CacheScheme(scheme); (await cache.ResolveClrTypeAsync(scheme.Id, schemeProvider: null!)).Should().BeNull(); cache.ResolveClrType(scheme.Id, schemeProvider: null!).Should().BeNull(); } } Path: redb/redb.Tests.Integration/Tests/Unit/GlobalMetadataCacheTypesTests.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/Unit/GlobalMetadataCacheTypesTests.cs ---- using redb.Core.Caching; namespace redb.Tests.Integration.Tests.Unit; /// /// The _types table kept by the metadata cache of a domain: the materializer reads it from here instead of the /// database on every call. No database. /// public class GlobalMetadataCacheTypesTests { private static GlobalMetadataCache NewCache() => new("types-test-" + Guid.NewGuid().ToString("N")); private static readonly RedbTypeInfo[] Types = [ new() { Id = -9223372036854775700, Name = "String", DbType = "String", Type1 = "string" }, new() { Id = -9223372036854775704, Name = "Long", DbType = "Long", Type1 = "long" }, ]; [Fact] public void NothingCached_GivesNoTable() { NewCache().GetTypesById().Should().BeNull(); } [Fact] public void CachedTable_IsReturnedById() { var cache = NewCache(); cache.CacheTypesById(Types); var byId = cache.GetTypesById(); byId.Should().NotBeNull(); byId!.Should().HaveCount(2); byId[-9223372036854775704].Name.Should().Be("Long"); } [Fact] public void Clear_DropsTheTable() { var cache = NewCache(); cache.CacheTypesById(Types); cache.Clear(); cache.GetTypesById().Should().BeNull(); } [Fact] public void DisabledCache_GivesNoTable() { var cache = NewCache(); cache.CacheTypesById(Types); cache.SetEnabled(false); cache.GetTypesById().Should().BeNull(); } } Path: redb/redb.Tests.Integration/Tests/Unit/HashCalculatorDiagTests.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/Unit/HashCalculatorDiagTests.cs ---- using redb.Core.Utils; namespace redb.Tests.Integration.Tests.Unit; /// /// DIAGNOSTIC — does RedbHash.ComputeFor actually distinguish a token whose only difference is Status? /// If Valid and Redeemed hash to the SAME value, the cache's hash-validation can never see the redeem, /// and LoadAsync returns a stale snapshot — matching the DIAG report (hit=True, dbHash stable). /// No DB — pure calculator check. Mirrors redb.Identity TokenProps shape. /// public sealed class HashCalculatorDiagTests { // Same shape as redb.Identity.Core TokenProps. private sealed class TokenLikeProps { public long ApplicationObjectId { get; set; } public long AuthorizationObjectId { get; set; } public string? Status { get; set; } public string? Type { get; set; } public string? ReferenceId { get; set; } public string? Payload { get; set; } public Dictionary? Properties { get; set; } public string? ActorSubject { get; set; } } private static TokenLikeProps Token(string status) => new() { ApplicationObjectId = 111, AuthorizationObjectId = 222, Status = status, Type = "access_token", ReferenceId = "ref-abc", Payload = "{\"jwt\":\"x\"}", Properties = new Dictionary { ["scope"] = "openid", ["k"] = "v" }, ActorSubject = "sub-1", }; [Fact] public void Status_ChangesHash() { var valid = RedbHash.ComputeForProps(Token("valid")); var redeemed = RedbHash.ComputeForProps(Token("redeemed")); (valid != redeemed).Should().BeTrue( "changing only Status MUST change the hash — otherwise the cache can never see a redeem"); } [Fact] public void SameState_SameHash_Deterministic() { // Two identical tokens (incl. same Dictionary) must hash equal across repeated computes — // otherwise Dictionary enumeration order makes the hash unstable (false cache misses / chaos). var a = RedbHash.ComputeForProps(Token("valid")); var b = RedbHash.ComputeForProps(Token("valid")); (a == b).Should().BeTrue( "identical props (including Dictionary) must hash identically every time"); } [Fact] public void DictionaryOrder_DoesNotAffectHash() { var t1 = Token("valid"); t1.Properties = new Dictionary { ["a"] = "1", ["b"] = "2" }; var t2 = Token("valid"); t2.Properties = new Dictionary { ["b"] = "2", ["a"] = "1" }; // reversed insert order (RedbHash.ComputeForProps(t1) == RedbHash.ComputeForProps(t2)).Should().BeTrue( "Dictionary content, not insertion order, must define the hash"); } } Path: redb/redb.Tests.Integration/Tests/Unit/HavingSqlTranslatorTests.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/Unit/HavingSqlTranslatorTests.cs ---- using System.Text.Json; using redb.Core.Pro.Query; using redb.Postgres.Sql; namespace redb.Tests.Integration.Tests.Unit; /// /// The Pro HAVING translator (review PR-16). A constant that is not a scalar was bound as its raw JSON text, so /// COUNT(*) > [1,2] compared a count with the string "[1,2]" instead of being refused. /// No database required. /// public class HavingSqlTranslatorTests { private static string Translate(string havingJson) { using var doc = JsonDocument.Parse(havingJson); var collector = new SqlParameterCollector(new PostgreSqlDialect()); return HavingSqlTranslator.Translate(doc.RootElement, collector, field => $"pvt.\"{field}\""); } [Theory] [InlineData("[1,2]")] [InlineData("{\"a\":1}")] public void AConstantThatIsNotAScalar_IsRefused(string constant) { var translate = () => Translate($"{{\"$gt\":[{{\"$count\":\"*\"}},{{\"$const\":{constant}}}]}}"); translate.Should().Throw().WithMessage("*$const*"); } [Fact] public void AScalarConstant_IsBound() { Translate("{\"$gt\":[{\"$count\":\"*\"},{\"$const\":5}]}").Should().StartWith("(COUNT(*) > "); } } Path: redb/redb.Tests.Integration/Tests/Unit/LazyStubSerializationRepro.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/Unit/LazyStubSerializationRepro.cs ---- using System.Text.Json; using redb.Core.Models.Entities; using redb.Core.Serialization; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Unit; /// /// In-memory guard for stub serialization (V4 Л1, L.4) — no database. Born as the bisection that /// caught an StJ stack overflow (a [JsonIgnore]+private-bridge variant); kept because it pins the /// converter contract at the unit level: a stub with and without a graph, with redb Options and /// with default options. /// public class LazyStubSerializationRepro { private static RedbObject RootWithStub() { var stub = new RedbObject { id = 5, scheme_id = 100, hash = Guid.NewGuid() }; return new RedbObject { id = 1, scheme_id = 100, Props = new LazyNodeProps { Label = "root", Next = stub } }; } [Fact] public void A_RootWithStub_RedbOptions() { var json = JsonSerializer.Serialize(RootWithStub(), SystemTextJsonRedbSerializer.Options); json.Should().Contain("\"id\":5"); } [Fact] public void B_RootWithStub_DefaultOptions() { var json = JsonSerializer.Serialize(RootWithStub()); json.Should().Contain("root"); } [Fact] public void C_StubAlone_RedbOptions() { var stub = new RedbObject { id = 5, scheme_id = 100 }; var json = JsonSerializer.Serialize(stub, SystemTextJsonRedbSerializer.Options); json.Should().Contain("\"id\":5"); } [Fact] public void D_RootWithoutRefs_RedbOptions() { var root = new RedbObject { id = 1, Props = new LazyNodeProps { Label = "solo" } }; var json = JsonSerializer.Serialize(root, SystemTextJsonRedbSerializer.Options); json.Should().Contain("solo"); } } Path: redb/redb.Tests.Integration/Tests/Unit/LazyWalkersListItemLeafTests.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/Unit/LazyWalkersListItemLeafTests.cs ---- using redb.Core.Models.Entities; using redb.Core.Providers; using redb.Core.Utils; namespace redb.Tests.Integration.Tests.Unit; /// /// Reflective walkers must treat RedbListItem as a LEAF (production stand, 2026-09-09): the /// item's lazy Object getter LOADS on read, and the loader-install walk read every property of /// every business object - including Object - so materializing anything with list-item fields /// fired a synchronous phantom load per item (~150/s on the stand, with not a single explicit /// .Object anywhere in the application code). /// /// No redb scope is live in these tests: a walk that read Object would load nothing and throw instead (a lazy load runs /// on the reader's scope, owner decision 2026-09-15), and would leave the item marked loaded under a configured fresh /// scope - both are caught below. /// /// public class LazyWalkersListItemLeafTests { private sealed class PropsWithItem { public string Label { get; set; } = ""; public RedbListItem? Status { get; set; } } private static (RedbObject root, RedbListItem item) Make() { var item = new RedbListItem { Id = 5, IdList = 1, Value = "status", IdObject = 42 }; var root = new RedbObject { id = 1, scheme_id = 100, Props = new PropsWithItem { Label = "root", Status = item }, }; return (root, item); } [Fact] public void LoaderInstall_DoesNotWakeTheItemsObject() { var (root, item) = Make(); var install = () => LazyReferenceInstaller.Install(root, new NoopLoader()); install.Should().NotThrow("installing lazy loaders is a wiring walk - it must never read Object"); item.IsObjectLoaded.Should().BeFalse(); } [Fact] public void MarkUnloaded_DoesNotWakeTheItemsObject() { var (root, item) = Make(); var mark = () => LazyReferenceInstaller.MarkUnloadedWherePropsAreNull(root); mark.Should().NotThrow(); item.IsObjectLoaded.Should().BeFalse(); } [Fact] public void MarkShared_DoesNotWakeTheItemsObject() { var (root, item) = Make(); var mark = () => LazyReferenceInstaller.MarkShared(root); mark.Should().NotThrow("marking a cached graph shared walks it without reading Object"); item.IsObjectLoaded.Should().BeFalse(); } [Fact] public void MarkShared_SharesTheObjectAnItemAlreadyCarries() { var nestedItem = new RedbListItem { Id = 6, IdList = 1, Value = "nested", IdObject = 43 }; var carried = new RedbObject { id = 42, scheme_id = 100, Props = new PropsWithItem { Label = "carried", Status = nestedItem }, }; var (root, item) = Make(); item.Object = carried; LazyReferenceInstaller.MarkShared(root); IsShared(item).Should().BeTrue("precondition: the item itself is marked"); IsShared(carried).Should().BeTrue("the object an item already carries is shared with the item"); IsShared(nestedItem).Should().BeTrue("and so is what that object holds"); } /// The internal shared mark; the core exposes no internals to tests. private static bool IsShared(object instance) { for (var type = instance.GetType(); type != null; type = type.BaseType) { var field = type.GetField("_isShared", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); if (field != null) return (bool)field.GetValue(instance)!; } throw new InvalidOperationException($"{instance.GetType().Name} carries no shared mark"); } private sealed class NoopLoader : ILazyPropsLoader { public TProps? LoadProps(long objectId, long schemeId) where TProps : class, new() => null; public Task LoadPropsAsync(long objectId, long schemeId, CancellationToken cancellationToken = default) where TProps : class, new() => Task.FromResult(null); public Task LoadPropsForManyAsync(List> objects, CancellationToken cancellationToken = default) where TProps : class, new() => Task.CompletedTask; public Task LoadPropsForManyAsync(List> objects, HashSet? projectedStructureIds, CancellationToken cancellationToken = default) where TProps : class, new() => Task.CompletedTask; public Task LoadPropsForManyAsync(List> objects, int? propsDepth, CancellationToken cancellationToken = default) where TProps : class, new() => Task.CompletedTask; public Task LoadPropsForManyAsync(List> objects, HashSet? projectedStructureIds, int? propsDepth, CancellationToken cancellationToken = default) where TProps : class, new() => Task.CompletedTask; } } Path: redb/redb.Tests.Integration/Tests/Unit/MsSqlProFoldOrderSqlTests.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/Unit/MsSqlProFoldOrderSqlTests.cs ---- using redb.Core.Query.Models; using redb.MSSql.Pro.Query; using redb.MSSql.Sql; namespace redb.Tests.Integration.Tests.Unit; /// /// The SQL Server pivot folds a collection field into one text with STRING_AGG over its element rows. Without an /// order the rows are joined as the plan reads them, so equal lists could give different texts and DistinctBy or /// OrderBy over the whole field depended on the plan. Every fold of the flat pivot names its order: a list by its /// index as a number, a dictionary by its key. /// public class MsSqlProFoldOrderSqlTests { private const string Order = "WITHIN GROUP (ORDER BY TRY_CAST(v2._array_index AS bigint), v2._array_index)"; [Fact] public void EveryCollectionFoldOfThePivot_NamesItsOrder() { var fields = new List { new(101, "String", "_String", "Tags", IsArray: true), new(102, "ListItem", "_ListItem", "Codes.Value", IsArray: true, ListItemProp: ListItemProperty.Value), new(103, "ListItem", "_ListItem", "Codes.Alias", IsArray: true, ListItemProp: ListItemProperty.Alias), new(104, "String", "_String", "Title"), }; var sql = new PvtSqlGenerator(new MsSqlDialect()).GeneratePvtCte(fields, "1=1", "@p0").CteSql; CountOf(sql, "STRING_AGG(").Should().Be(3, "the three collection fields are folded"); CountOf(sql, Order).Should().Be(3, "each fold joins its elements in index order"); } private static int CountOf(string text, string part) { var count = 0; for (var at = text.IndexOf(part, StringComparison.Ordinal); at >= 0; at = text.IndexOf(part, at + part.Length, StringComparison.Ordinal)) count++; return count; } } Path: redb/redb.Tests.Integration/Tests/Unit/NarrowElementLeafTests.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/Unit/NarrowElementLeafTests.cs ---- using redb.Core.Pro.Query; using redb.Core.Query.Models; using redb.Core.Query.QueryExpressions; namespace redb.Tests.Integration.Tests.Unit; /// /// The leaf of a Contains over an array of simple values, read through the capped probe on PostgreSQL: an equality on the /// element rows of that array. Only a top-level conjunct, only an array of simple values; the scalar driving leaf and the /// narrow-conjunct check are not changed by it. /// public class NarrowElementLeafTests { private const long Array = 503; private const long Scalar = 502; private static readonly Dictionary Fields = new() { ["Skills"] = new FieldInfo(Array, "String", "_string", "Skills", IsArray: true), ["Age"] = new FieldInfo(Scalar, "Long", "_long", "Age"), }; private static ComparisonExpression Has(string value) => new(new PropertyInfo("Skills", typeof(string[])), ComparisonOperator.ArrayContains, value); [Fact] public void Contains_IsAnEqualityOnTheElementRows() { var leaf = PvtPrefilterPlanner.NarrowElementLeaf(Has("C#"), Fields)!; leaf.StructureId.Should().Be(Array); leaf.Predicates.Should().ContainSingle().Which.Op.Should().Be(ComparisonOperator.Equal); } [Fact] public void Contains_InTheTopLevelAnd_IsFound_ButNotUnderAnOr() { var age = new ComparisonExpression(new PropertyInfo("Age", typeof(long)), ComparisonOperator.GreaterThan, 30L); PvtPrefilterPlanner.NarrowElementLeaf(new LogicalExpression(LogicalOperator.And, [age, Has("C#")]), Fields) .Should().NotBeNull(); PvtPrefilterPlanner.NarrowElementLeaf(new LogicalExpression(LogicalOperator.Or, [age, Has("C#")]), Fields) .Should().BeNull("an OR is no superset a leaf can read"); } [Fact] public void Contains_DoesNotBecomeADrivingLeafOrANarrowConjunct() { PvtPrefilterPlanner.DrivingLeaf(Has("C#"), Fields).Should().BeNull("it is only read through the probe"); PvtPrefilterPlanner.HasNarrowConjunct(Has("C#"), Fields).Should().BeFalse("the forms of the other providers stay"); } } Path: redb/redb.Tests.Integration/Tests/Unit/NestedDictionaryIndexerRefusalTests.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/Unit/NestedDictionaryIndexerRefusalTests.cs ---- using System.Linq.Expressions; using redb.Core.Pro.Query; using redb.Core.Query; using redb.Core.Query.QueryExpressions; namespace redb.Tests.Integration.Tests.Unit; /// /// A dictionary entry read through another dictionary entry (D["a"]["b"]) is not a chain of fields of the /// queried object: the filter refuses it with the field path message. It used to reach the query with the outer /// dictionary cut to the literal "Dict" in its path. One dictionary entry, with or without a field of its value, is /// read. No database is needed: the parser decides. /// public class NestedDictionaryIndexerRefusalTests { public class Entry { public string Name { get; set; } = ""; } public class NestedDictionaryProps { public Dictionary> ByGroup { get; set; } = new(); public Dictionary> Counts { get; set; } = new(); public Dictionary ByKey { get; set; } = new(); public Dictionary Scores { get; set; } = new(); } private readonly ProFilterExpressionParser _parser = new(); [Fact] public void FieldOfAnEntryOfAnEntry_IsRefused() { var name = "x"; var act = () => _parser.ParseFilter(p => p.ByGroup["a"]["b"].Name == name); act.Should().Throw() .WithMessage(FieldPathRefusal.Message("p.ByGroup.get_Item(\"a\")")); } [Fact] public void SimpleValueOfAnEntryOfAnEntry_IsRefused() { var act = () => _parser.ParseFilter(p => p.Counts["a"]["b"] == 5); act.Should().Throw() .WithMessage(FieldPathRefusal.Message("p.Counts.get_Item(\"a\")")); } [Fact] public void FieldOfOneEntry_IsRead() { var result = _parser.ParseFilter(p => p.ByKey["a"].Name == "x"); var comparison = Assert.IsType(result); comparison.Property.Name.Should().Be("ByKey[a].Name"); } [Fact] public void NullableValueOfOneEntry_IsRead() { var result = _parser.ParseFilter(p => p.Scores["a"].Value == 1); var comparison = Assert.IsType(result); comparison.Property.Name.Should().Be("Scores[a]"); } } Path: redb/redb.Tests.Integration/Tests/Unit/NoDynamicTypeTests.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/Unit/NoDynamicTypeTests.cs ---- using System.Text; using System.Text.RegularExpressions; namespace redb.Tests.Integration.Tests.Unit; /// /// The repository does not use the C# type dynamic: values are strongly typed. The test /// reads every C# source file of the tree it runs from (the whole repository on a development tree, the redb module on /// the public mirror) and fails with the file and line of each use. Comments, string and character literals and /// preprocessor lines are left out, so the word in prose or in a message does not count. /// public class NoDynamicTypeTests { private static readonly Regex DynamicKeyword = new(@"(? !IsBuildOutput(root!, f)) .ToList(); files.Should().Contain(f => f.EndsWith("IRedbService.cs", StringComparison.Ordinal), "the scan reaches the core sources"); var uses = new List(); foreach (var file in files) { var code = CodeOnly(File.ReadAllText(file)); foreach (Match m in DynamicKeyword.Matches(code)) { var line = 1 + code.AsSpan(0, m.Index).Count('\n'); uses.Add($"{Path.GetRelativePath(root!, file)}:{line}"); } } uses.Should().BeEmpty("the type dynamic is not used in this repository; use a strong type instead"); } [Theory] [InlineData("dynamic x = 1;", 1)] [InlineData("var list = new List();", 1)] [InlineData("var y = (dynamic)x;", 1)] [InlineData("// a dynamic value\nint a = 1;", 0)] [InlineData("/* dynamic */ int a = 1;", 0)] [InlineData("var s = \"a dynamic node\";", 0)] [InlineData("var s = @\"a \"\"dynamic\"\" node\";", 0)] [InlineData("var s = $\"{(ok ? \"dynamic\" : \"static\")} node\";", 0)] [InlineData("var s = $\"{Make()} node\";", 1)] [InlineData("var s = \"\"\"\n dynamic \"text\"\n \"\"\";", 0)] [InlineData("#region dynamic part\nint a = 1;", 0)] [InlineData("var c = '\"'; dynamic d = c;", 1)] [InlineData("bool _dynamic = true; var s = x.dynamicName;", 0)] public void CodeOnly_KeepsCode_AndDropsCommentsAndLiterals(string source, int expected) { DynamicKeyword.Matches(CodeOnly(source)).Count.Should().Be(expected); } private static bool IsBuildOutput(string root, string file) { var parts = Path.GetRelativePath(root, file).Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); return parts.Any(p => p is "bin" or "obj" or ".git" or "node_modules"); } // The root is the repository (the folder that holds redb.DB/src/redb.Core) or, on the public mirror, the folder that // holds redb.Core next to the tests. private static string? FindSourceRoot() { for (var dir = new DirectoryInfo(AppContext.BaseDirectory); dir != null; dir = dir.Parent) { if (File.Exists(Path.Combine(dir.FullName, "redb.DB", "src", "redb.Core", "IRedbService.cs")) || File.Exists(Path.Combine(dir.FullName, "redb.Core", "IRedbService.cs"))) return dir.FullName; } return null; } /// /// The text with comments, string and character literals and preprocessor lines replaced by blanks. Line breaks are /// kept, so positions map to the same line. The holes of an interpolated string are code and are kept. /// internal static string CodeOnly(string text) { var sb = new StringBuilder(text.Length); var i = 0; Scan(text, ref i, sb, stopAtBrace: false); return sb.ToString(); } private static void Scan(string t, ref int i, StringBuilder sb, bool stopAtBrace) { var depth = 0; var lineStart = true; while (i < t.Length) { var c = t[i]; var next = i + 1 < t.Length ? t[i + 1] : '\0'; if (lineStart && c == '#') { while (i < t.Length && t[i] != '\n') i++; continue; } if (c is not (' ' or '\t' or '\r')) lineStart = c == '\n'; if (c == '/' && next == '/') { while (i < t.Length && t[i] != '\n') i++; continue; } if (c == '/' && next == '*') { var end = t.IndexOf("*/", i + 2, StringComparison.Ordinal); var stop = end < 0 ? t.Length : end + 2; Blank(t, i, stop, sb); i = stop; continue; } if (c == '"' || ((c == '@' || c == '$') && (next == '"' || next == '@' || next == '$'))) { SkipString(t, ref i, sb); continue; } if (c == '\'') { var j = i + 1; if (j < t.Length && t[j] == '\\') j += 2; while (j < t.Length && t[j] != '\'' && t[j] != '\n') j++; i = Math.Min(j + 1, t.Length); sb.Append(' '); continue; } if (stopAtBrace) { if (c == '{') depth++; else if (c == '}' && depth-- == 0) return; } sb.Append(c); i++; } } private static void SkipString(string t, ref int i, StringBuilder sb) { var dollars = 0; var verbatim = false; while (i < t.Length && (t[i] == '$' || t[i] == '@')) { if (t[i] == '$') dollars++; else verbatim = true; i++; } var quotes = 0; while (i + quotes < t.Length && t[i + quotes] == '"') quotes++; if (quotes >= 3) { // Raw string literal: ends at the next run of as many quotes; holes take as many braces as there are dollars. i += quotes; var close = new string('"', quotes); var open = new string('{', Math.Max(dollars, 1)); while (i < t.Length && string.CompareOrdinal(t, i, close, 0, quotes) != 0) { if (dollars > 0 && string.CompareOrdinal(t, i, open, 0, open.Length) == 0 && (i + open.Length >= t.Length || t[i + open.Length] != '{')) { i += open.Length; Scan(t, ref i, sb, stopAtBrace: true); i += Math.Min(dollars, t.Length - i); continue; } if (t[i] == '\n') sb.Append('\n'); i++; } i = Math.Min(i + quotes, t.Length); sb.Append(' '); return; } i++; // opening quote while (i < t.Length) { var c = t[i]; if (verbatim && c == '"' && i + 1 < t.Length && t[i + 1] == '"') { i += 2; continue; } if (!verbatim && c == '\\') { i += 2; continue; } if (c == '"') { i++; break; } if (!verbatim && c == '\n') break; if (dollars > 0 && c == '{') { if (i + 1 < t.Length && t[i + 1] == '{') { i += 2; continue; } i++; Scan(t, ref i, sb, stopAtBrace: true); i++; // closing brace continue; } if (c == '\n') sb.Append('\n'); i++; } sb.Append(' '); } private static void Blank(string t, int from, int to, StringBuilder sb) { for (var k = from; k < to; k++) if (t[k] == '\n') sb.Append('\n'); sb.Append(' '); } } Path: redb/redb.Tests.Integration/Tests/Unit/NullableParserTests.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/Unit/NullableParserTests.cs ---- using System.Linq.Expressions; using redb.Core.Models.Contracts; using redb.Core.Query.Parsing; using redb.Core.Query.QueryExpressions; namespace redb.Tests.Integration.Tests.Unit; /// /// Unit tests for Nullable<T>.Value / .HasValue handling in expression parser. /// No database required — tests pure expression tree parsing. /// public class NullableParserTests { private readonly FilterExpressionParser _parser = new(); [Fact] public void ParentId_Value_Equal_ShouldParseTo_ParentId_BaseField() { Expression> expr = o => o.ParentId.Value == 42; var result = _parser.ParseRedbFilter(expr); var comparison = Assert.IsType(result); Assert.Equal("ParentId", comparison.Property.Name); Assert.True(comparison.Property.IsBaseField); Assert.Equal(ComparisonOperator.Equal, comparison.Operator); Assert.Equal(42L, comparison.Value); } [Fact] public void ParentId_HasValue_ShouldParseTo_IsNotNull() { Expression> expr = o => o.ParentId.HasValue; var result = _parser.ParseRedbFilter(expr); var nullCheck = Assert.IsType(result); Assert.Equal("ParentId", nullCheck.Property.Name); Assert.True(nullCheck.Property.IsBaseField); Assert.False(nullCheck.IsNull); // HasValue = true → IS NOT NULL } [Fact] public void Not_ParentId_HasValue_ShouldParseTo_IsNull() { Expression> expr = o => !o.ParentId.HasValue; var result = _parser.ParseRedbFilter(expr); var nullCheck = Assert.IsType(result); Assert.Equal("ParentId", nullCheck.Property.Name); Assert.True(nullCheck.Property.IsBaseField); Assert.True(nullCheck.IsNull); // !HasValue → IS NULL } [Fact] public void ParentId_EqualNull_ShouldParseTo_IsNull() { Expression> expr = o => o.ParentId == null; var result = _parser.ParseRedbFilter(expr); var nullCheck = Assert.IsType(result); Assert.Equal("ParentId", nullCheck.Property.Name); Assert.True(nullCheck.Property.IsBaseField); Assert.True(nullCheck.IsNull); } [Fact] public void ValueLong_Value_GreaterThan_ShouldParseTo_ValueLong_BaseField() { Expression> expr = o => o.ValueLong.Value > 50; var result = _parser.ParseRedbFilter(expr); var comparison = Assert.IsType(result); Assert.Equal("ValueLong", comparison.Property.Name); Assert.True(comparison.Property.IsBaseField); Assert.Equal(ComparisonOperator.GreaterThan, comparison.Operator); } [Fact] public void Key_HasValue_ShouldParseTo_IsNotNull() { Expression> expr = o => o.Key.HasValue; var result = _parser.ParseRedbFilter(expr); var nullCheck = Assert.IsType(result); Assert.Equal("Key", nullCheck.Property.Name); Assert.True(nullCheck.Property.IsBaseField); Assert.False(nullCheck.IsNull); } [Fact] public void HasValue_And_Value_Equal_ShouldParseToLogical() { long target = 42; Expression> expr = o => o.ParentId.HasValue && o.ParentId.Value == target; var result = _parser.ParseRedbFilter(expr); var logical = Assert.IsType(result); Assert.Equal(LogicalOperator.And, logical.Operator); Assert.Equal(2, logical.Operands.Count); var nullCheck = Assert.IsType(logical.Operands[0]); Assert.Equal("ParentId", nullCheck.Property.Name); Assert.False(nullCheck.IsNull); var comparison = Assert.IsType(logical.Operands[1]); Assert.Equal("ParentId", comparison.Property.Name); Assert.Equal(ComparisonOperator.Equal, comparison.Operator); } } Path: redb/redb.Tests.Integration/Tests/Unit/PostgresServerVersionTests.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/Unit/PostgresServerVersionTests.cs ---- using System; using AwesomeAssertions; using redb.Postgres.Data; using Xunit; namespace redb.Tests.Integration.Tests.Unit; /// /// PostgreSQL 15 is the lowest supported server: the schema creates a unique index with NULLS NOT DISTINCT. An older /// server is refused before any schema work with one message that names the server found and the one required, /// instead of a syntax error from the middle of the creation script. Shown on server_version_num values, no server /// needed. /// public class PostgresServerVersionTests { [Theory] [InlineData("150000")] [InlineData("150014")] [InlineData("160004")] [InlineData("180001")] [InlineData(" 170002\n")] public void Supported_server_passes(string versionNum) => PostgresServerVersion.FindProblem(versionNum).Should().BeNull(); [Theory] [InlineData("140012", "14.12")] [InlineData("140000", "14.0")] [InlineData("130018", "13.18")] [InlineData("90624", "9.6.24")] public void Older_server_is_refused_with_both_versions(string versionNum, string shown) { var problem = PostgresServerVersion.FindProblem(versionNum); problem.Should().NotBeNull(); problem.Should().Contain($"PostgreSQL {shown}"); problem.Should().Contain("PostgreSQL 15 or newer"); } [Theory] [InlineData(null)] [InlineData("")] [InlineData("fifteen")] public void Unreadable_answer_is_refused_and_quoted(string? versionNum) { var problem = PostgresServerVersion.FindProblem(versionNum); problem.Should().NotBeNull(); problem.Should().Contain("PostgreSQL 15 or newer"); } [Fact] public void Ensure_throws_NotSupportedException_with_the_message() { var act = () => PostgresServerVersion.EnsureSupported("140012"); act.Should().Throw().WithMessage("*PostgreSQL 15 or newer*PostgreSQL 14.12*"); } [Fact] public void Ensure_passes_on_a_supported_server() { var act = () => PostgresServerVersion.EnsureSupported("150004"); act.Should().NotThrow(); } } Path: redb/redb.Tests.Integration/Tests/Unit/ProFreeOfChargeTests.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/Unit/ProFreeOfChargeTests.cs ---- using System.Reflection; namespace redb.Tests.Integration.Tests.Unit; /// /// redb Pro is free of charge, whatever the version of the package: a build of any major version runs every Pro /// feature, and nothing is refused or counted. The policy and the guard are internal, so the test reaches them by /// reflection and hands them the version a package of a higher major would pass. /// [Collection("LicenseState")] public class ProFreeOfChargeTests { private static readonly Assembly Licensing = typeof(redb.Licensing.LicenseStore).Assembly; private static readonly Assembly CorePro = typeof(redb.Core.Pro.Extensions.RedbProServiceCollectionExtensions).Assembly; private static Type Policy => Licensing.GetType("redb.Licensing.LicensePolicy", throwOnError: true)!; private static Type Guard => CorePro.GetType("redb.Core.Pro.Licensing.LicenseGuard", throwOnError: true)!; [Theory] [InlineData(4)] [InlineData(5)] [InlineData(99)] public void Policy_TreatsEveryMajorAsFree(int major) { var isFree = Policy.GetMethod("IsFreeVersion", BindingFlags.Public | BindingFlags.Static)!; ((bool)isFree.Invoke(null, [new Version(major, 0, 0)])!).Should().BeTrue(); } [Theory] [InlineData(5)] [InlineData(99)] public void Guard_WithoutAKey_RefusesNothing_AndCountsNothing(int major) { redb.Licensing.LicenseStore.Reset(); redb.Licensing.LicenseStore.All.Should().BeEmpty("the test host sets no key"); var check = Guard.GetMethod("CheckFeature", BindingFlags.NonPublic | BindingFlags.Static)!; var dailyLimit = (int)Guard.GetField("DailyLimit", BindingFlags.NonPublic | BindingFlags.Static)!.GetRawConstantValue()!; var counter = Guard.GetField("_requestCount", BindingFlags.NonPublic | BindingFlags.Static)!; var before = (int)counter.GetValue(null)!; // Past the old daily trial limit: the dormant path would have thrown LicenseRequiredException here. var version = new Version(major, 0, 0); var act = () => { for (var i = 0; i < dailyLimit + 10; i++) check.Invoke(null, ["core.pro", version]); }; act.Should().NotThrow(); ((int)counter.GetValue(null)!).Should().Be(before, "no request is counted"); } } Path: redb/redb.Tests.Integration/Tests/Unit/ProFriendAccessTests.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/Unit/ProFriendAccessTests.cs ---- using System.Reflection; using System.Runtime.CompilerServices; namespace redb.Tests.Integration.Tests.Unit; /// /// redb.Postgres and redb.MSSql give their Pro provider access to the batch methods of their connections, which are /// internal. The grant names the public key of the Pro assemblies (RedbProPublicKey of the root Directory.Build.props). /// Built without that property, the grant came out as "PublicKey=" and granted nothing: the build stayed green and a /// list query of Pro threw MethodAccessException at run time. Each grant must carry the key the Pro provider is signed /// with. /// public class ProFriendAccessTests { [Theory] [InlineData(typeof(redb.Postgres.RedbService), typeof(redb.Postgres.Pro.Query.PvtSqlGenerator))] [InlineData(typeof(redb.MSSql.RedbService), typeof(redb.MSSql.Pro.Query.PvtSqlGenerator))] public void FreeProvider_GrantsItsProProvider_ByTheProPublicKey(Type freeType, Type proType) { var pro = proType.Assembly.GetName(); var proKey = Convert.ToHexString(pro.GetPublicKey() ?? []); proKey.Should().NotBeEmpty($"{pro.Name} is strong-named"); var grants = freeType.Assembly.GetCustomAttributes() .Select(a => a.AssemblyName) .Where(n => n.StartsWith(pro.Name + ",", StringComparison.Ordinal) || n == pro.Name) .ToList(); grants.Should().ContainSingle($"{freeType.Assembly.GetName().Name} grants {pro.Name} friend access"); var key = grants[0].Split("PublicKey=", 2) is [_, var k] ? k.Trim() : ""; key.Should().NotBeEmpty("a grant without a key reaches no signed assembly"); key.Should().BeEquivalentTo(proKey, "the grant names the key the Pro provider is signed with"); } } Path: redb/redb.Tests.Integration/Tests/Unit/PropsCacheEvictionTests.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/Unit/PropsCacheEvictionTests.cs ---- using redb.Core.Caching; using redb.Core.Models.Entities; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Unit; /// /// The props cache under load (production, 2026-09-15): an insert into a full cache sorted every entry under the /// write lock, and hit validation - the object hash and the walk of its loaded graph - ran under one process-wide /// lock, so concurrent readers queued behind each other with their connections open. Eviction is now least /// recently used, a tenth of the limit at a time, and validation runs outside the lock. A re-cached object starts /// a new lifetime. /// public class PropsCacheEvictionTests { private static RedbObject MakeObject(long id) { var obj = new RedbObject { id = id, name = $"evict-{id}", scheme_id = 1000, Props = new SimpleProps { Title = $"evict-{id}" } }; obj.RecomputeHash(); return obj; } [Fact] public void Overflow_EvictsATenthOfTheLimitAtOnce() { var cache = new MemoryRedbObjectCache(maxSize: 100); for (long id = 1; id <= 100; id++) cache.Set(MakeObject(id)); cache.GetStats().TotalEntries.Should().Be(100); cache.Set(MakeObject(101)); cache.GetStats().TotalEntries.Should().Be(91, "an insert into a full cache evicts a tenth of the limit, so the next inserts do not pay an eviction each"); } [Fact] public void Overflow_EvictsTheLeastRecentlyUsed_NotTheOldest() { var cache = new MemoryRedbObjectCache(maxSize: 10); var objects = Enumerable.Range(1, 10).Select(i => MakeObject(i)).ToList(); foreach (var obj in objects) cache.Set(obj); // The oldest entry is read, so it becomes the most recently used one. cache.Get(1, objects[0].hash!.Value).Should().NotBeNull(); cache.Set(MakeObject(11)); cache.Get(1, objects[0].hash!.Value).Should().NotBeNull("the entry just read is the last one to go"); cache.Get(2, objects[1].hash!.Value).Should().BeNull("the least recently used entry is evicted"); } [Fact] public void ReSet_AfterTheTtl_StartsANewLifetime() { var cache = new MemoryRedbObjectCache(ttl: TimeSpan.FromMilliseconds(200)); var obj = MakeObject(1); cache.Set(obj); Thread.Sleep(300); // A periodic job loads and re-caches the same objects on every pass. cache.Set(obj); cache.Get(1, obj.hash!.Value).Should().NotBeNull( "a re-cached object is current again; keeping its first lifetime made it miss for ever once one TTL had passed"); } [Fact] public void ExpiredEntry_IsDroppedOnRead() { var cache = new MemoryRedbObjectCache(ttl: TimeSpan.FromMilliseconds(100)); var obj = MakeObject(1); cache.Set(obj); Thread.Sleep(200); cache.Get(1, obj.hash!.Value).Should().BeNull(); cache.GetStats().TotalEntries.Should().Be(0, "an expired entry frees its slot instead of holding it until eviction"); } /// Props whose getter can be slowed down and counts the readers inside it at the same time. public sealed class ParallelProbeProps { public static volatile int DelayMs; private static int _inFlight; private static int _maxInFlight; public static int MaxInFlight => _maxInFlight; private string _title = string.Empty; public string Title { get { if (DelayMs > 0) { var now = Interlocked.Increment(ref _inFlight); int seen; while (now > (seen = _maxInFlight) && Interlocked.CompareExchange(ref _maxInFlight, now, seen) != seen) { } Thread.Sleep(DelayMs); Interlocked.Decrement(ref _inFlight); } return _title; } set => _title = value; } } [Fact] public async Task HitsOfDifferentObjects_ValidateAtTheSameTime() { var cache = new MemoryRedbObjectCache(); var first = new RedbObject { id = 1, name = "first", scheme_id = 1000, Props = new ParallelProbeProps { Title = "first" } }; var second = new RedbObject { id = 2, name = "second", scheme_id = 1000, Props = new ParallelProbeProps { Title = "second" } }; first.RecomputeHash(); second.RecomputeHash(); cache.Set(first); cache.Set(second); ParallelProbeProps.DelayMs = 300; RedbObject?[] hits; try { using var start = new Barrier(2); hits = await Task.WhenAll( Task.Run(() => { start.SignalAndWait(); return cache.Get(1, first.hash!.Value); }), Task.Run(() => { start.SignalAndWait(); return cache.Get(2, second.hash!.Value); })); } finally { ParallelProbeProps.DelayMs = 0; } hits.Should().OnlyContain(h => h != null); ParallelProbeProps.MaxInFlight.Should().Be(2, "two hits validate their objects at the same time instead of queueing behind one cache lock"); } } Path: redb/redb.Tests.Integration/Tests/Unit/PropsCacheMutationDiagTests.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/Unit/PropsCacheMutationDiagTests.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Data; using redb.Core.Models.Configuration; using redb.Core.Models.Entities; using redb.Core.Pro.Extensions; using redb.SQLite.Data; using redb.SQLite.Pro.Extensions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Unit; /// /// DIAGNOSTIC — reproduces the OAuth "already redeemed" story on the storage layer with /// EnablePropsCache=true, to find WHERE a stale read comes from (not to assert final behaviour). /// Self-contained: own ServiceProvider with the cache ON, own SQLite file. SQLite because the bug /// report is SQLite (Free+Pro). /// public sealed class PropsCacheMutationDiagTests : IAsyncLifetime { private ServiceProvider _sp = null!; private IRedbService _redb = null!; public async Task InitializeAsync() { SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension(); const string cs = "Data Source=redb_diag_cache.db"; SqliteTestSupport.DeleteDbFiles(cs); var services = new ServiceCollection(); services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning)); services.AddRedbPro(options => // ← Pro (free, no license key): ChangeTracking is Pro-only options.UseSqlite(cs) .Configure(c => { c.PropsSaveStrategy = PropsSaveStrategy.ChangeTracking; // ← Identity Pro uses this, not DeleteInsert c.SkipHashValidationOnCacheCheck = false; c.EnablePropsCache = true; // ← the whole point })); _sp = services.BuildServiceProvider(); _redb = _sp.GetRequiredService(); try { await _redb.InitializeAsync(ensureCreated: true); } catch { await _redb.InitializeAsync(); } await _redb.SyncSchemeAsync(); } public async Task DisposeAsync() { if (_sp is not null) await _sp.DisposeAsync(); } private static RedbObject New(string title) => new() { name = "diag", Props = new SimpleProps { Title = title, Price = 1m, Count = 1, IsActive = true } }; /// Baseline: plain Save → mutate → Save → Load. Does the cache alone go stale? [Fact] public async Task MutateCycle_NoLock_LoadSeesLatest() { var obj = New("valid"); obj.id = await _redb.SaveAsync(obj); var l1 = await _redb.LoadAsync(obj.id); l1!.Props.Title.Should().Be("valid"); // mutate a field (analogue of Status: valid → redeemed) and persist l1.Props.Title = "redeemed"; await _redb.SaveAsync(l1); var l2 = await _redb.LoadAsync(obj.id); l2!.Props.Title.Should().Be("redeemed", "a full Save recomputes _hash; Load must see the new state"); } /// The OAuth shape: LockForUpdate → Load(current) → check → Save, done TWICE per request. [Fact] public async Task LockLoadSaveCycle_SecondPass_CurrentIsFresh() { var obj = New("valid"); obj.id = await _redb.SaveAsync(obj); // pass 1 — redeem await _redb.Context.ExecuteAtomicAsync(async () => { await _redb.LockForUpdateAsync(obj.id); var current = await _redb.LoadAsync(obj.id); current!.Props.Title.Should().Be("valid", "pass-1 current must be the pre-redeem state"); current.Props.Title = "redeemed"; await _redb.SaveAsync(current); }); // pass 2 — a metadata-only touch in the same logical request; current must reflect pass 1 await _redb.Context.ExecuteAtomicAsync(async () => { await _redb.LockForUpdateAsync(obj.id); var current = await _redb.LoadAsync(obj.id); current!.Props.Title.Should().Be("redeemed", "pass-2 current must be fresh (redeemed) — a stale 'valid' here is the bug, " + "a stale 'redeemed' seen as valid would be the OAuth symptom"); }); } /// /// The real Identity shape: writes go through SaveAsync, but the token/authorization stores READ via /// Query<TProps>() (server-side, bypasses PropsCache) AND via LoadAsync (through /// PropsCache). After a mutation, do the two read paths agree? /// [Fact] public async Task QueryVsLoad_AfterMutation_BothSeeLatest() { var obj = New("valid"); obj.id = await _redb.SaveAsync(obj); // warm the cache via Load (as a prior request would) (await _redb.LoadAsync(obj.id))!.Props.Title.Should().Be("valid"); // mutate + persist through the normal Save path var toUpdate = await _redb.LoadAsync(obj.id); toUpdate!.Props.Title = "redeemed"; await _redb.SaveAsync(toUpdate); // Query path (bypasses PropsCache — reads SQL) var viaQuery = await _redb.Query() .WhereRedb(o => o.Id == obj.id) .FirstOrDefaultAsync(); // Load path (through PropsCache) var viaLoad = await _redb.LoadAsync(obj.id); viaQuery!.Props.Title.Should().Be("redeemed", "Query reads SQL directly"); viaLoad!.Props.Title.Should().Be("redeemed", "Load must not serve a stale cached copy"); viaLoad.Props.Title.Should().Be(viaQuery.Props.Title, "the two read paths must agree"); } /// /// The path the single-object tests missed: BATCH load routes through /// ProLazyPropsLoader.LoadPropsForManyAsync → FilterNeedToLoad (the batch cache filter). Warm a /// batch, mutate ONE member, reload the batch — does the mutated one come back fresh? /// [Fact] public async Task BatchLoad_AfterMutatingOne_AllFresh() { var a = New("a"); a.id = await _redb.SaveAsync(a); var b = New("b"); b.id = await _redb.SaveAsync(b); var c = New("c"); c.id = await _redb.SaveAsync(c); // warm the cache with a BATCH load (FilterNeedToLoad → Set all three) _ = await _redb.LoadAsync(new[] { a.id, b.id, c.id }); // mutate only B, persist through the normal Save path var bLoad = await _redb.LoadAsync(b.id); bLoad!.Props.Title = "b-changed"; await _redb.SaveAsync(bLoad); // reload the whole batch — B must reflect the mutation, A/C untouched var again = await _redb.LoadAsync(new[] { a.id, b.id, c.id }); var bAgain = again.First(o => o.Id == b.id) as RedbObject; var aAgain = again.First(o => o.Id == a.id) as RedbObject; bAgain!.Props.Title.Should().Be("b-changed", "batch FilterNeedToLoad must not serve a stale B"); aAgain!.Props.Title.Should().Be("a", "A was not mutated"); } /// /// THE root cause: PropsCache stores/returns a REFERENCE. If a caller mutates a loaded object /// in place (as OpenIddict's SetStatusAsync does BEFORE Save), the cache — holding the same /// reference — instantly reflects the mutation, under the SAME hash key. A later LoadAsync then /// returns the mutated object ("redeemed") even though the DB row is still "valid" → "already /// redeemed" on a valid code. The cache must isolate its snapshot from external mutation. /// [Fact] public async Task Aliasing_InPlaceMutationOfLoadedObject_DoesNotLeakIntoCache() { var obj = New("valid"); obj.id = await _redb.SaveAsync(obj); var loaded1 = await _redb.LoadAsync(obj.id); // warms cache (Set stores the ref) loaded1!.Props.Title = "redeemed-inplace"; // mutate IN PLACE, WITHOUT Save var loaded2 = await _redb.LoadAsync(obj.id); // must still read committed "valid" loaded2!.Props.Title.Should().Be("valid", "the cache must isolate its snapshot — an in-place mutation of a loaded object must not leak in"); } } Path: redb/redb.Tests.Integration/Tests/Unit/PropsCacheTests.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/Unit/PropsCacheTests.cs ---- using redb.Core.Caching; using redb.Core.Models.Entities; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Unit; /// /// PropsCache (the whole-object cache behind ) unit behaviour: keyed by /// objectId, validated by object hash, type-safe on read, honours TTL. The fixtures run with /// EnablePropsCache=false, so this exercises directly. /// public class PropsCacheTests { // Real object: hash = ComputeHash(Props), like production (Save writes it, materialization // reproduces it). The cache's live-hash dirty-check relies on this invariant — a fabricated random // hash would (correctly) be seen as a dirty snapshot and missed. private static RedbObject MakeObject(long id, string title) { var obj = new RedbObject { id = id, name = title, scheme_id = 1000, Props = new SimpleProps { Title = title } }; obj.RecomputeHash(); // hash now matches Props return obj; } [Fact] public void Get_WithMatchingHash_ReturnsObject() { var cache = new MemoryRedbObjectCache(); var obj = MakeObject(1, "hit"); cache.Set(obj); var got = cache.Get(1, obj.hash!.Value); got.Should().NotBeNull(); got!.Props.Title.Should().Be("hit"); } [Fact] public void Get_WithChangedHash_ReturnsNull() { var cache = new MemoryRedbObjectCache(); cache.Set(MakeObject(2, "stale")); // Different hash = the object changed in the DB → cache must miss so fresh data is loaded. cache.Get(2, Guid.NewGuid()).Should().BeNull(); } [Fact] public void GetWithoutHashValidation_ReturnsObject_IgnoringHash() { var cache = new MemoryRedbObjectCache(); cache.Set(MakeObject(3, "trusted")); // SkipHashValidationOnCacheCheck path: trust the cache, no DB-hash compare (dirty-check still applies). var got = cache.GetWithoutHashValidation(3); got.Should().NotBeNull(); got!.Props.Title.Should().Be("trusted"); } [Fact] public void Get_WrongType_ReturnsNull_NotGarbage() { var cache = new MemoryRedbObjectCache(); var obj = MakeObject(4, "typed"); cache.Set(obj); // Same objectId, different TProps: `entry.RedbObject as RedbObject` yields null rather // than a mistyped object — the caller reloads instead of getting garbage. cache.Get(4, obj.hash!.Value).Should().BeNull(); } [Fact] public void Remove_EvictsEntry() { var cache = new MemoryRedbObjectCache(); var obj = MakeObject(5, "gone"); cache.Set(obj); cache.Get(5, obj.hash!.Value).Should().NotBeNull(); cache.Remove(5); cache.Get(5, obj.hash!.Value).Should().BeNull(); } [Fact] public void Ttl_Expired_ReturnsNull() { var cache = new MemoryRedbObjectCache(ttl: TimeSpan.Zero); var obj = MakeObject(6, "expired"); cache.Set(obj); // TTL zero → the entry is already stale on the next read. cache.Get(6, obj.hash!.Value).Should().BeNull(); } [Fact] public void DirtySnapshot_MutatedAfterSet_ReturnsNull() { var cache = new MemoryRedbObjectCache(); var obj = MakeObject(8, "clean"); cache.Set(obj); // Mutate the SAME object in place after caching (aliasing) WITHOUT re-Set — the cache holds a // reference, so its snapshot is now dirty. The live-hash check must detect it and miss. obj.Props.Title = "mutated-in-place"; cache.Get(8, obj.hash!.Value).Should().BeNull( "a cached object mutated in place after Set is a dirty snapshot — must miss, not serve stale"); } [Fact] public void Stats_TrackHitsAndMisses() { var cache = new MemoryRedbObjectCache(); var obj = MakeObject(7, "s"); cache.Set(obj); cache.Get(7, obj.hash!.Value); // hit cache.Get(999, Guid.NewGuid()); // miss var stats = cache.GetStats(); stats.HitCount.Should().BeGreaterThan(0); stats.MissCount.Should().BeGreaterThan(0); } } Path: redb/redb.Tests.Integration/Tests/Unit/PropsCacheWarningTests.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/Unit/PropsCacheWarningTests.cs ---- using redb.Core.Caching; using redb.Core.Models.Entities; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Unit; /// /// The props cache names its own trouble (production, 2026-09-15: a cache too small for the working set and a /// slow hit check degraded a process ×5-10 without a single log line). Each warning is written at most once per /// 10-second window. /// public class PropsCacheWarningTests { private static RedbObject MakeObject(long id) { var obj = new RedbObject { id = id, name = $"warn-{id}", scheme_id = 1000, Props = new SimpleProps { Title = $"warn-{id}" } }; obj.RecomputeHash(); return obj; } [Fact] public void WorkingSetAboveTheLimit_WarnsOnce_NamingTheSetting() { var capture = new CapturingLoggerProvider(); var cache = new MemoryRedbObjectCache(maxSize: 10, logger: capture.CreateLogger("props-cache")); for (long id = 1; id <= 60; id++) cache.Set(MakeObject(id)); capture.Warnings.Should().ContainSingle(m => m.Contains("PropsCacheMaxSize"), "evicting most of the cache within seconds means the objects in use do not fit it"); } /// Props whose getter can be slowed down: every validation of a cached hit reads it. public sealed class SlowProbeProps { public static volatile int DelayMs; private string _title = string.Empty; public string Title { get { if (DelayMs > 0) Thread.Sleep(DelayMs); return _title; } set => _title = value; } } [Fact] public void SlowHitValidation_WarnsOnce() { var capture = new CapturingLoggerProvider(); var cache = new MemoryRedbObjectCache(logger: capture.CreateLogger("props-cache")); var obj = new RedbObject { id = 7, name = "slow", scheme_id = 1000, Props = new SlowProbeProps { Title = "slow" } }; obj.RecomputeHash(); cache.Set(obj); SlowProbeProps.DelayMs = 60; try { cache.Get(7, obj.hash!.Value).Should().NotBeNull(); cache.Get(7, obj.hash!.Value).Should().NotBeNull(); } finally { SlowProbeProps.DelayMs = 0; } capture.Warnings.Should().ContainSingle(m => m.Contains("validation") && m.Contains("7"), "a hit whose check takes this long makes every cache hit that slow"); } [Fact] public void CurrentEntriesServedNone_WarnsOnce() { var capture = new CapturingLoggerProvider(); var cache = new MemoryRedbObjectCache(logger: capture.CreateLogger("props-cache")); var obj = MakeObject(1); cache.Set(obj); // The stored hash still matches, but the cached instance no longer hashes to it - what a read model that // does not reproduce the saved graph looks like on every lookup. obj.Props.Title = "changed in place"; for (var i = 0; i < 150; i++) cache.Get(1, obj.hash!.Value).Should().BeNull(); capture.Warnings.Should().ContainSingle(m => m.Contains("served none")); } [Fact] public void HealthyCache_StaysSilent() { var capture = new CapturingLoggerProvider(); var cache = new MemoryRedbObjectCache(maxSize: 1000, logger: capture.CreateLogger("props-cache")); var objects = Enumerable.Range(1, 200).Select(i => MakeObject(i)).ToList(); foreach (var obj in objects) cache.Set(obj); for (var pass = 0; pass < 3; pass++) foreach (var obj in objects) cache.Get(obj.id, obj.hash!.Value).Should().NotBeNull(); capture.Warnings.Should().BeEmpty(); } } Path: redb/redb.Tests.Integration/Tests/Unit/PvtModuleVersionConsistencyTests.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/Unit/PvtModuleVersionConsistencyTests.cs ---- using System.Reflection; using System.Text.RegularExpressions; using redb.Core.Query; using redb.MSSql.Pro.Sql; using redb.MSSql.Sql; using redb.Postgres.Pro.Sql; using redb.Postgres.Sql; using redb.SQLite.Pro.Sql; using redb.SQLite.Sql; namespace redb.Tests.Integration.Tests.Unit; /// /// The version a dialect requires of the database module is the version the shipped module reports. Start-up compares /// the two for equality: when they differ, every start applies the module again, and a start that may not change the /// schema (AutoApplyDatabaseUpgrades off, or a role without the rights) stops with RedbSchemaOutdatedException for good. /// SQL Server shipped that way from 4.6.1 to 4.7.0: the dialect asked for 0.2.40, the module still answered 0.2.39. /// No database is needed: the module text is read from the assembly (PostgreSQL, SQL Server) or from the source of the /// native extension (SQLite). /// public class PvtModuleVersionConsistencyTests { private static readonly Regex ModuleVersionFunction = new( @"FUNCTION\s+(?:\[?dbo\]?\.)?\[?pvt_module_version\]?[\s\S]*?RETURN\s+N?'(?\d+\.\d+\.\d+)'", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); private static readonly Regex NativeModuleVersion = new( @"#define\s+PVT_MODULE_VERSION\s+""(?\d+\.\d+\.\d+)""", RegexOptions.CultureInvariant); // pvt_module_compat: '|' (PostgreSQL: SELECT '...'::text, SQL Server: RETURN N'...'). private static readonly Regex ModuleCompatFunction = new( @"FUNCTION\s+(?:\[?dbo\]?\.)?\[?pvt_module_compat\]?[\s\S]*?(?:RETURN|SELECT)\s+N?'(?\d+\.\d+\.\d+)\|(?\d+\.\d+\.\d+)'", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); /// /// The module states what it serves, and it serves at least the package it ships with: the oldest module version it /// names is not above its own. /// [Theory] [InlineData("redb.MSSql.sql.v2-pvt.pvt_bundle.sql", typeof(redb.MSSql.RedbService))] [InlineData("redb.Postgres.sql.v2-pvt.pvt_bundle.sql", typeof(redb.Postgres.RedbService))] public void Module_StatesWhatItServes_AndServesItsOwnPackage(string resourceName, Type serviceType) { using var stream = serviceType.Assembly.GetManifestResourceStream(resourceName); using var reader = new StreamReader(stream!); var text = reader.ReadToEnd(); var compat = ModuleCompatFunction.Match(text); compat.Success.Should().BeTrue($"{resourceName} defines pvt_module_compat as '|'"); var own = ModuleVersionFunction.Match(text).Groups["v"].Value; new Version(compat.Groups["min"].Value).Should().BeLessThanOrEqualTo(new Version(own)); redb.Core.Data.ModuleCompatibility.Serves($"{compat.Groups["min"].Value}|{compat.Groups["pkg"].Value}", own, out var pkg) .Should().BeTrue(); pkg.Should().Be(compat.Groups["pkg"].Value); } // The guard at the head of the module: the own version it compares a deployed module with // (PostgreSQL: _own constant text := '...', SQL Server: @own nvarchar(50) = N'...'). private static readonly Regex GuardOwnVersion = new( @"(?:_own\s+constant\s+text\s*:=|@own\s+nvarchar\(50\)\s*=)\s*N?'(?\d+\.\d+\.\d+)'", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); /// /// The guard that stops a hand-run older script over a newer module compares with the version the same script /// stamps (a guard left at an old version would let the script take back the modules between the two), and it /// stands before the first statement that changes anything. /// [Theory] [InlineData("redb.MSSql.sql.v2-pvt.pvt_bundle.sql", typeof(redb.MSSql.RedbService))] [InlineData("redb.Postgres.sql.v2-pvt.pvt_bundle.sql", typeof(redb.Postgres.RedbService))] public void Guard_ComparesWithTheVersionTheScriptStamps_BeforeAnyChange(string resourceName, Type serviceType) { using var stream = serviceType.Assembly.GetManifestResourceStream(resourceName); using var reader = new StreamReader(stream!); var text = reader.ReadToEnd(); var guard = GuardOwnVersion.Match(text); guard.Success.Should().BeTrue($"{resourceName} starts with the guard against a newer module"); guard.Groups["v"].Value.Should().Be(ModuleVersionFunction.Match(text).Groups["v"].Value); guard.Index.Should().BeLessThan(text.IndexOf("ALTER TABLE", StringComparison.OrdinalIgnoreCase)); } [Theory] [InlineData("0.7.25", "0.7.24", true)] [InlineData("0.7.24", "0.7.24", false)] [InlineData("0.7.23", "0.7.24", false)] [InlineData("0.10.0", "0.9.9", true)] [InlineData("0.0.0-test", "0.7.24", false)] [InlineData(null, "0.7.24", false)] [InlineData("garbage", "0.7.24", false)] public void IsNewer_ComparesVersionsAsNumbers(string? deployed, string required, bool newer) => redb.Core.Data.ModuleCompatibility.IsNewer(deployed, required).Should().Be(newer); [Theory] [InlineData("0.7.24|4.8.0", "0.7.24", true, "4.8.0")] [InlineData("0.7.20|4.8.0", "0.7.24", true, "4.8.0")] [InlineData("0.7.30|4.9.0", "0.7.24", false, "4.9.0")] [InlineData(null, "0.7.24", false, null)] [InlineData("0.7.20", "0.7.24", true, null)] [InlineData("x|4.9.0", "0.7.24", false, "4.9.0")] public void Serves_WhenTheOldestServedModuleIsNotAboveTheOwn(string? compat, string required, bool serves, string? package) { redb.Core.Data.ModuleCompatibility.Serves(compat, required, out var named).Should().Be(serves); named.Should().Be(package); } [Fact] public void SqlServer_ModuleReportsTheVersionTheDialectRequires() { var shipped = VersionInBundle(typeof(redb.MSSql.RedbService).Assembly, "redb.MSSql.sql.v2-pvt.pvt_bundle.sql"); Required(new MsSqlDialect()).Should().Be(shipped); Required(new ProMsSqlDialect()).Should().Be(shipped); } [Fact] public void PostgreSql_ModuleReportsTheVersionTheDialectRequires() { var shipped = VersionInBundle(typeof(redb.Postgres.RedbService).Assembly, "redb.Postgres.sql.v2-pvt.pvt_bundle.sql"); Required(new PostgreSqlDialect()).Should().Be(shipped); Required(new ProPostgreSqlDialect()).Should().Be(shipped); } [Fact] public void Sqlite_NativeExtensionReportsTheVersionTheDialectRequires() { var source = FindNativeSource(); source.Should().NotBeNull("the source of the native extension (redb.SQLite/native/src/redb_pvt.c) is part of the tree the tests run from"); var match = NativeModuleVersion.Match(File.ReadAllText(source!)); match.Success.Should().BeTrue("redb_pvt.c defines PVT_MODULE_VERSION"); var shipped = match.Groups["v"].Value; Required(new SqliteDialect()).Should().Be(shipped); Required(new ProSqliteDialect()).Should().Be(shipped); } private static string Required(ISqlDialect dialect) { var required = dialect.Query_PvtRequiredVersion(); required.Should().NotBeNullOrWhiteSpace($"{dialect.GetType().Name} names the module version it needs"); return required!; } private static string VersionInBundle(Assembly assembly, string resourceName) { using var stream = assembly.GetManifestResourceStream(resourceName); stream.Should().NotBeNull($"{assembly.GetName().Name} embeds {resourceName}"); using var reader = new StreamReader(stream!); var match = ModuleVersionFunction.Match(reader.ReadToEnd()); match.Success.Should().BeTrue($"{resourceName} defines pvt_module_version with a RETURN of the version"); return match.Groups["v"].Value; } /// redb_pvt.c in the public mirror layout (redb.SQLite at the top) or in the development one (redb.DB/src). private static string? FindNativeSource() { for (var dir = new DirectoryInfo(AppContext.BaseDirectory); dir != null; dir = dir.Parent) { var candidate = Path.Combine(dir.FullName, "redb.SQLite", "native", "src", "redb_pvt.c"); if (!File.Exists(candidate)) candidate = Path.Combine(dir.FullName, "redb.DB", "src", "redb.SQLite", "native", "src", "redb_pvt.c"); if (File.Exists(candidate)) return candidate; } return null; } } Path: redb/redb.Tests.Integration/Tests/Unit/QuoteIdentifierDoublingTests.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/Unit/QuoteIdentifierDoublingTests.cs ---- using AwesomeAssertions; using redb.MSSql.Sql; using redb.Postgres.Sql; using redb.SQLite.Sql; using Xunit; namespace redb.Tests.Integration.Tests.Unit; /// /// A quoted identifier must escape its own closing quote by doubling it. Without that, a name that /// carries a closing quote ends the identifier and the remainder becomes SQL (SQLI-PoC p.7). The /// correct pattern already lived in MssqlQueryProvider.QuoteGwndIdent; the dialects did not /// follow it. /// public class QuoteIdentifierDoublingTests { [Fact] public void MsSql_DoublesClosingBracket() => new MsSqlDialect().QuoteIdentifier("a]b; SELECT 1--").Should().Be("[a]]b; SELECT 1--]"); [Fact] public void Postgres_DoublesDoubleQuote() => new PostgreSqlDialect().QuoteIdentifier("a\"b").Should().Be("\"a\"\"b\""); [Fact] public void Sqlite_DoublesDoubleQuote() => new SqliteDialect().QuoteIdentifier("a\"b").Should().Be("\"a\"\"b\""); [Fact] public void PlainNameIsUnchanged() { new MsSqlDialect().QuoteIdentifier("Age").Should().Be("[Age]"); new PostgreSqlDialect().QuoteIdentifier("Age").Should().Be("\"Age\""); new SqliteDialect().QuoteIdentifier("Age").Should().Be("\"Age\""); } } Path: redb/redb.Tests.Integration/Tests/Unit/RedbHashCanonCollisionTests.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/Unit/RedbHashCanonCollisionTests.cs ---- using System.Globalization; using System.Security.Cryptography; using System.Text; using redb.Core.Utils; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Unit; /// /// The hash canon tells apart values whose plain joined strings coincide: a separator inside a string ('|', ',', '=') /// and a dictionary key that is not a simple value. ChangeTracking skips an object, a collection or a nested class whose /// hash did not move, so a collision is a lost change. A value with no separator and no escape character keeps the /// canon it had before the escaping, so stored hashes of such objects stay valid. /// public sealed class RedbHashCanonCollisionTests { private static Guid HashOf(TProps props) where TProps : class, new() => RedbHash.ComputeForProps(props)!.Value; private static Guid Md5(string canon) => new(MD5.HashData(Encoding.UTF8.GetBytes(canon))); [Fact] public void PipeInsideAString_DoesNotCollide() => HashOf(new HashCanonPair { A = "x|y", B = "" }) .Should().NotBe(HashOf(new HashCanonPair { A = "x", B = "y|" })); [Fact] public void CommaInsideAnElement_DoesNotCollide() => HashOf(new HashCanonProbeProps { Tags = ["a,b"] }) .Should().NotBe(HashOf(new HashCanonProbeProps { Tags = ["a", "b"] })); [Fact] public void EqualsAndCommaInsideADictionaryValue_DoNotCollide() => HashOf(new HashCanonProbeProps { Dict = new() { ["a"] = "1,b=2" } }) .Should().NotBe(HashOf(new HashCanonProbeProps { Dict = new() { ["a"] = "1", ["b"] = "2" } })); [Fact] public void EqualsInsideADictionaryKey_DoesNotCollide() => HashOf(new HashCanonProbeProps { Dict = new() { ["a=b"] = "c" } }) .Should().NotBe(HashOf(new HashCanonProbeProps { Dict = new() { ["a"] = "b=c" } })); [Fact] public void EscapeCharacterItself_DoesNotCollide() => HashOf(new HashCanonPair { A = "x\u0001", B = "|y" }) .Should().NotBe(HashOf(new HashCanonPair { A = "x\u0001|", B = "y" })); /// /// A hash stored before the escaping is the hash of the plain canon. A value that held the escaped form of the new /// value as text must not hash like it, or a node that upgraded skips the change against the stored hash: with a /// backslash as the escape, "a\,b" stored before and "a,b" saved after shared the canon "[a\,b]". /// [Fact] public void EscapedCanon_DoesNotMatchACanonStoredBeforeTheEscaping() { // The canons stored before for Tags = ["a\,b"] and for A = "x\|y", B = "\e". HashOf(new HashCanonProbeProps { Tags = ["a,b"] }).Should().NotBe(Md5("||||||[a\\,b]")); HashOf(new HashCanonPair { A = "x|y", B = "" }).Should().NotBe(Md5("x\\|y|\\e")); } [Fact] public void NullElementAndTheStringNull_DoNotCollide() => HashOf(new HashCanonProbeProps { Tags = [null] }) .Should().NotBe(HashOf(new HashCanonProbeProps { Tags = ["null"] })); [Fact] public void EmptyCollectionAndOneEmptyString_DoNotCollide() => HashOf(new HashCanonProbeProps { Tags = [] }) .Should().NotBe(HashOf(new HashCanonProbeProps { Tags = [""] })); [Fact] public void NullDictionaryValueAndTheStringNull_DoNotCollide() => HashOf(new HashCanonProbeProps { Dict = new() { ["a"] = null! } }) .Should().NotBe(HashOf(new HashCanonProbeProps { Dict = new() { ["a"] = "null" } })); [Fact] public void NullPropertyAndAnEmptyString_DoNotCollide() => HashOf(new HashCanonPair { A = null, B = "b" }) .Should().NotBe(HashOf(new HashCanonPair { A = "", B = "b" })); [Fact] public void ClassKeysWithoutToString_DoNotCollide() => HashOf(new HashCanonClassKeyProps { ByKey = new() { [new HashCanonKey { Code = "a", Rank = 1 }] = "v" } }) .Should().NotBe(HashOf(new HashCanonClassKeyProps { ByKey = new() { [new HashCanonKey { Code = "b", Rank = 2 }] = "v" } })); [Fact] public void TupleKeyOfDoubleAndDate_HashesTheSame_UnderEveryCulture() { var at = new DateTime(2026, 9, 16, 12, 30, 15, DateTimeKind.Utc); HashCanonTupleKeyProps Props() => new() { ByTuple = new() { [(1.5, at)] = "v" } }; var ruRu = Under("ru-RU", () => HashOf(Props())); var enUs = Under("en-US", () => HashOf(Props())); var deDe = Under("de-DE", () => HashOf(Props())); ruRu.Should().Be(enUs); ruRu.Should().Be(deDe); } /// /// The canon of an object with no separator and no escape character in its strings, written out by hand: the /// escaping must leave it as it was, so the hashes stored for such objects stay valid. /// [Fact] public void StringsWithoutSeparators_KeepTheirCanon() { var props = new HashCanonProbeProps { A = "x", B = "y z", Label = null, Tags = ["a", null, "b.c", "c:\\d"], Dict = new() { ["k2"] = "v 2", ["k1"] = "v1" }, Inner = new HashCanonPair { A = "p", B = "q" }, Items = [new HashCanonPair { A = "p", B = "q" }, new HashCanonPair { A = "r", B = null }], }; var pq = Md5("p|q").ToString("N"); var r = Md5("r|").ToString("N"); // Ordinal order of the properties: A, B, Dict, Inner, Items, Label, Tags. var canon = $"x|y z|{{k1=v1,k2=v 2}}|{pq}|[{pq},{r}]||[a,null,b.c,c:\\d]"; HashOf(props).Should().Be(Md5(canon)); } private static Guid Under(string culture, Func compute) { var previous = CultureInfo.CurrentCulture; CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(culture); try { return compute(); } finally { CultureInfo.CurrentCulture = previous; } } } Path: redb/redb.Tests.Integration/Tests/Unit/RedbHashHeaderCanonTests.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/Unit/RedbHashHeaderCanonTests.cs ---- using redb.Core.Models.Entities; using redb.Core.Utils; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Unit; /// /// Full-object-hash plan (2026-09-11): _hash covers the header of the row, not only the /// Props. What is in and what is out is a contract, pinned here without a database: /// every header column takes part; the audit trio (date_create, date_modify, who_change) and the /// identity (id, scheme id) do not - they are stamped outside the hash computation and a hash /// that carried them could never be reproduced from a reloaded row; header dates canonicalise /// at second precision in UTC, so a value survives the round trip through any of the three /// databases. /// public sealed class RedbHashHeaderCanonTests { private static RedbObject Baseline() => new() { id = 42, scheme_id = 7, parent_id = 3, owner_id = 1, who_change_id = 1, name = "n", note = "note", key = 5, value_long = 1, value_string = "s", value_guid = Guid.Parse("11111111-1111-1111-1111-111111111111"), value_bool = true, value_double = 1.5, value_numeric = 2.25m, value_datetime = new DateTimeOffset(2026, 9, 11, 12, 0, 0, TimeSpan.Zero), value_bytes = [1, 2, 3], value_unique = "K-1", date_begin = new DateTimeOffset(2026, 1, 1, 0, 0, 0, TimeSpan.Zero), date_complete = new DateTimeOffset(2026, 2, 1, 0, 0, 0, TimeSpan.Zero), date_create = new DateTimeOffset(2026, 9, 1, 0, 0, 0, TimeSpan.Zero), date_modify = new DateTimeOffset(2026, 9, 2, 0, 0, 0, TimeSpan.Zero), Props = new SimpleProps { Title = "p", Count = 1 } }; private static Guid HashOf(Action> mutate) { var obj = Baseline(); mutate(obj); return RedbHash.ComputeFor(obj)!.Value; } public static IEnumerable HeaderMutations() => [ [nameof(RedbObject.name), (Action>)(o => o.name = "other")], [nameof(RedbObject.note), (Action>)(o => o.note = "other")], [nameof(RedbObject.parent_id), (Action>)(o => o.parent_id = 4)], [nameof(RedbObject.owner_id), (Action>)(o => o.owner_id = 2)], [nameof(RedbObject.key), (Action>)(o => o.key = 6)], [nameof(RedbObject.value_long), (Action>)(o => o.value_long = 2)], [nameof(RedbObject.value_string), (Action>)(o => o.value_string = "t")], [nameof(RedbObject.value_guid), (Action>)(o => o.value_guid = Guid.NewGuid())], [nameof(RedbObject.value_bool), (Action>)(o => o.value_bool = false)], [nameof(RedbObject.value_double), (Action>)(o => o.value_double = 2.5)], [nameof(RedbObject.value_numeric), (Action>)(o => o.value_numeric = 3.25m)], [nameof(RedbObject.value_datetime), (Action>)(o => o.value_datetime = o.value_datetime!.Value.AddSeconds(1))], [nameof(RedbObject.value_bytes), (Action>)(o => o.value_bytes = [1, 2, 4])], [nameof(RedbObject.value_unique), (Action>)(o => o.value_unique = "K-2")], [nameof(RedbObject.date_begin), (Action>)(o => o.date_begin = o.date_begin!.Value.AddDays(1))], [nameof(RedbObject.date_complete), (Action>)(o => o.date_complete = null)], ]; [Theory] [MemberData(nameof(HeaderMutations))] public void EveryHeaderColumn_TakesPart(string column, Action> mutate) { HashOf(mutate).Should().NotBe(HashOf(_ => { }), $"a change of {column} on another node must move _hash, or the props cache serves the stale header"); } [Fact] public void Props_StillTakePart() { HashOf(o => o.Props.Count = 2).Should().NotBe(HashOf(_ => { })); } [Fact] public void AuditAndIdentity_DoNotTakePart() { var baseline = HashOf(_ => { }); HashOf(o => o.date_create = o.date_create.AddDays(1)).Should().Be(baseline, "date_create is stamped on the row outside the hash computation"); HashOf(o => o.date_modify = o.date_modify.AddDays(1)).Should().Be(baseline, "date_modify is stamped on every save; with it in the hash no resave could ever be a no-op"); HashOf(o => o.who_change_id = 9).Should().Be(baseline, "who_change is audit, not content"); HashOf(o => o.id = 43).Should().Be(baseline, "the id is identity, and 0 until the save assigns it"); HashOf(o => o.scheme_id = 8).Should().Be(baseline, "the scheme id is assigned after the batch recomputes hashes - in the hash it would cost every new object its first hits"); HashOf(o => o.hash = Guid.NewGuid()).Should().Be(baseline, "the hash never hashes itself"); } [Fact] public void HeaderDates_CanonAtSecondsInUtc() { var baseline = HashOf(_ => { }); HashOf(o => o.value_datetime = o.value_datetime!.Value.AddMilliseconds(999)).Should().Be(baseline, "sub-second digits do not survive every database (SQLite REAL Julian keeps ~40 microseconds) - the canon stops at seconds"); HashOf(o => o.value_datetime = o.value_datetime!.Value.ToOffset(TimeSpan.FromHours(3))).Should().Be(baseline, "the same instant in another offset is the same value - MSSQL keeps the offset, PostgreSQL returns UTC"); HashOf(o => o.date_begin = o.date_begin!.Value.AddTicks(5)).Should().Be(baseline); } [Fact] public void BaseFieldsHash_IsTheHeaderCanon() { // An object without Props hashes its header alone - the same canon, so a typed object // with null Props and a non-generic RedbObject agree with each other. var a = Baseline(); a.Props = null!; var b = Baseline(); b.Props = null!; b.name = "other"; RedbHash.ComputeForBaseFields(a).Should().NotBe(RedbHash.ComputeForBaseFields(b)); var c = Baseline(); c.Props = null!; c.date_modify = c.date_modify.AddDays(1); RedbHash.ComputeForBaseFields(a).Should().Be(RedbHash.ComputeForBaseFields(c)); } } Path: redb/redb.Tests.Integration/Tests/Unit/RedbHashPropsCanonTests.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/Unit/RedbHashPropsCanonTests.cs ---- using System.Globalization; using redb.Core.Models.Entities; using redb.Core.Utils; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Unit; /// /// The canon of Props values inside the object hash: a value /// canonicalises the same on every node, whatever the process culture, and a temporal value keeps its milliseconds. /// The hash decides whether the ChangeTracking save writes at all, so a change the canon cannot see is a lost write. /// Milliseconds are the precision every database keeps (SQLite stores an OLE date, truncated to milliseconds by .NET), /// so the canon truncates there: a value survives the round trip with the hash it was saved with. /// public sealed class RedbHashPropsCanonTests { private sealed class NumericProps { public double Ratio { get; set; } public float Weight { get; set; } public decimal Amount { get; set; } } private static readonly DateTimeOffset Moment = new(2026, 9, 16, 12, 30, 15, TimeSpan.Zero); private static Guid HashOf(TProps props) where TProps : class, new() => RedbHash.ComputeFor(new RedbObject { id = 1, Props = props })!.Value; private static Guid Under(string culture, Func compute) { var previous = CultureInfo.CurrentCulture; CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(culture); try { return compute(); } finally { CultureInfo.CurrentCulture = previous; } } [Fact] public void NumericProps_HashTheSame_UnderEveryCulture() { NumericProps Props() => new() { Ratio = 1.5, Weight = 2.25f, Amount = 3.125m }; var ruRu = Under("ru-RU", () => HashOf(Props())); var enUs = Under("en-US", () => HashOf(Props())); var invariant = Under("", () => HashOf(Props())); ruRu.Should().Be(enUs, "a decimal separator of the process culture must not move the hash between nodes"); ruRu.Should().Be(invariant); } [Fact] public void TemporalProps_HashTheSame_UnderEveryCulture() { TemporalProps Props() => new() { When = Moment.UtcDateTime, Moment = Moment, Day = new DateOnly(2026, 9, 16), Clock = new TimeOnly(12, 30, 15), Span = TimeSpan.FromMinutes(90), Label = "t" }; var ruRu = Under("ru-RU", () => HashOf(Props())); var enUs = Under("en-US", () => HashOf(Props())); ruRu.Should().Be(enUs, "a date format of the process culture must not move the hash between nodes"); } [Fact] public void ASubSecondChange_MovesTheHash() { var baseline = HashOf(new TemporalProps { When = Moment.UtcDateTime, Moment = Moment, Label = "t" }); HashOf(new TemporalProps { When = Moment.UtcDateTime, Moment = Moment.AddMilliseconds(100), Label = "t" }) .Should().NotBe(baseline, "a DateTimeOffset changed by 100 ms is a different value - the save must see it"); HashOf(new TemporalProps { When = Moment.UtcDateTime.AddMilliseconds(100), Moment = Moment, Label = "t" }) .Should().NotBe(baseline, "a DateTime changed by 100 ms is a different value - the save must see it"); } [Fact] public void AChangeBelowAMillisecond_KeepsTheHash() { // The contract: milliseconds are the precision every database keeps, and the hash of a saved object must // equal the hash of its reloaded twin. Anything finer would move the hash on every reload. var baseline = HashOf(new TemporalProps { When = Moment.UtcDateTime, Moment = Moment, Label = "t" }); HashOf(new TemporalProps { When = Moment.UtcDateTime, Moment = Moment.AddTicks(4567), Label = "t" }) .Should().Be(baseline, "456.7 microseconds do not survive the databases and are not part of the canon"); } [Fact] public void DateTimeKind_DoesNotMoveTheHash() { // Storage takes the clock reading and stamps Kind=Utc without converting (DateTimeConverter); the canon does // the same, so a Local value hashes before the save as it will after the reload. var clock = new DateTime(2026, 9, 16, 12, 30, 15, 250); var utc = HashOf(new TemporalProps { When = DateTime.SpecifyKind(clock, DateTimeKind.Utc), Moment = Moment, Label = "t" }); var local = HashOf(new TemporalProps { When = DateTime.SpecifyKind(clock, DateTimeKind.Local), Moment = Moment, Label = "t" }); var unspecified = HashOf(new TemporalProps { When = DateTime.SpecifyKind(clock, DateTimeKind.Unspecified), Moment = Moment, Label = "t" }); local.Should().Be(utc); unspecified.Should().Be(utc); } [Fact] public void ADateTimeOffsetWithAnotherOffset_HashesByItsInstant() { var plusThree = HashOf(new TemporalProps { When = Moment.UtcDateTime, Moment = Moment.ToOffset(TimeSpan.FromHours(3)), Label = "t" }); var utc = HashOf(new TemporalProps { When = Moment.UtcDateTime, Moment = Moment, Label = "t" }); plusThree.Should().Be(utc, "the databases keep the instant, not the offset it was written with"); } } Path: redb/redb.Tests.Integration/Tests/Unit/RedbHashReferenceCycleTests.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/Unit/RedbHashReferenceCycleTests.cs ---- using redb.Core.Models.Entities; using redb.Core.Utils; namespace redb.Tests.Integration.Tests.Unit; /// /// The object hash walks nested classes of the Props by reflection. A graph where a nested object is reached again /// through its own properties (a back-reference) has no end: the walk must stop with an error that names the cycle, /// not recurse until the stack overflows and takes the process down. One object reached twice without a cycle (a /// shared instance) is not a cycle and hashes as before. /// public sealed class RedbHashReferenceCycleTests { public sealed class CycleNode { public string? Name { get; set; } public CycleNode? Next { get; set; } } public sealed class CycleHolder { public CycleNode? Head { get; set; } public List? Items { get; set; } } [Fact] public void BackReferenceThroughAClassProperty_IsRefused() { var a = new CycleNode { Name = "a" }; var b = new CycleNode { Name = "b", Next = a }; a.Next = b; var act = () => RedbHash.ComputeFor(new RedbObject { id = 1, Props = new CycleHolder { Head = a } }); act.Should().Throw() .WithMessage($"*reference cycle*{nameof(CycleNode)}*"); } [Fact] public void BackReferenceThroughAListElement_IsRefused() { var a = new CycleNode { Name = "a" }; a.Next = a; var act = () => RedbHash.ComputeFor(new RedbObject { id = 1, Props = new CycleHolder { Items = [a] } }); act.Should().Throw().WithMessage("*reference cycle*"); } [Fact] public void SharedInstanceWithoutACycle_HashesLikeTwoEqualCopies() { var shared = new CycleNode { Name = "s" }; var sharedHash = RedbHash.ComputeFor(new RedbObject { id = 1, Props = new CycleHolder { Head = shared, Items = [shared, shared] } }); var copiesHash = RedbHash.ComputeFor(new RedbObject { id = 1, Props = new CycleHolder { Head = new() { Name = "s" }, Items = [new() { Name = "s" }, new() { Name = "s" }] } }); sharedHash.Should().NotBeNull(); sharedHash.Should().Be(copiesHash); } } Path: redb/redb.Tests.Integration/Tests/Unit/RedbHashRenameOrderTests.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/Unit/RedbHashRenameOrderTests.cs ---- using System.Security.Cryptography; using System.Text; using redb.Core.Attributes; using redb.Core.Models.Entities; using redb.Core.Utils; namespace redb.Tests.Integration.Tests.Unit; /// /// The order of the properties in the hash canon: by the first name of the chain, /// by the property name when there is none, then by the property name; both ordinal. A class without the attribute /// hashes exactly as before the attribute existed (ordered by name), so no stored hash of an existing database moves, /// and a rename keeps the property where it sorted, so the hashes stored before the rename stay valid after it. /// public sealed class RedbHashRenameOrderTests { // Declared out of name order on purpose; ordinal order is Alpha, Beta, Mid, alpha, zeta. private sealed class PlainProps { public string zeta { get; set; } = ""; public string Mid { get; set; } = ""; public long Beta { get; set; } public string alpha { get; set; } = ""; public PlainNested Alpha { get; set; } = new(); } private sealed class PlainNested { public string Street { get; set; } = ""; public string City { get; set; } = ""; } private sealed class TitleV1 { public string Alpha { get; set; } = ""; public string Title { get; set; } = ""; public string Zulu { get; set; } = ""; } private sealed class TitleV2 { [RedbRename("Title")] public string Aaron { get; set; } = ""; public string Alpha { get; set; } = ""; public string Zulu { get; set; } = ""; } private sealed class TitleV3 { [RedbRename("Title")] [RedbRename("Aaron")] public string Zzz { get; set; } = ""; public string Alpha { get; set; } = ""; public string Zulu { get; set; } = ""; } private sealed class SwapV1 { public string Left { get; set; } = ""; public string Right { get; set; } = ""; } private sealed class SwapV2 { [RedbRename("Left")] [RedbRename("Tmp")] public string Right { get; set; } = ""; [RedbRename("Right")] public string Left { get; set; } = ""; } private sealed class ReuseProps { public string Title { get; set; } = ""; [RedbRename("Title")] public string Heading { get; set; } = ""; } private static Guid Md5(string payload) => new(MD5.HashData(Encoding.UTF8.GetBytes(payload))); private static Guid HashOf(TProps props) where TProps : class, new() => RedbHash.ComputeFor(new RedbObject { id = 1, name = "n", Props = props })!.Value; /// The object hash over a Props canon built by hand: header canon, then the Props hash. private static Guid Expected(TProps props, string propsCanon) where TProps : class, new() => Md5(RedbHash.HeaderCanon(new RedbObject { id = 1, name = "n", Props = props }) + "||" + Md5(propsCanon).ToString("N")); [Fact] public void AClassWithoutTheAttribute_HashesInNameOrder_AsBefore() { var props = new PlainProps { zeta = "z", Mid = "m", Beta = 2, alpha = "a", Alpha = new PlainNested { Street = "Gate", City = "Oslo" }, }; var nested = Md5("Oslo|Gate").ToString("N"); HashOf(props).Should().Be(Expected(props, $"{nested}|2|m|a|z"), "the canon of a class without [RedbRename] is the ordinal name order the stored hashes were computed in"); } [Fact] public void ARename_KeepsTheHash_WhereTheNewNameSortsElsewhere() { var before = HashOf(new TitleV1 { Alpha = "a", Title = "t", Zulu = "z" }); HashOf(new TitleV2 { Alpha = "a", Aaron = "t", Zulu = "z" }).Should().Be(before); } [Fact] public void AChain_SortsByItsFirstName() { var before = HashOf(new TitleV1 { Alpha = "a", Title = "t", Zulu = "z" }); HashOf(new TitleV3 { Alpha = "a", Zzz = "t", Zulu = "z" }).Should().Be(before); } [Fact] public void ASwap_KeepsTheStoredHash_AndSeesTheValuesSwappedBack() { var stored = HashOf(new SwapV1 { Left = "x", Right = "y" }); // Swapped through Tmp: the old Left is Right now, the old Right is Left. HashOf(new SwapV2 { Right = "x", Left = "y" }).Should().Be(stored); HashOf(new SwapV2 { Right = "y", Left = "x" }).Should().NotBe(stored, "ordered by the current names these values would hash as the stored row, and the save would skip them"); } [Fact] public void AFreedNameTakenAgain_SortsAfterTheRenamedProperty() { var props = new ReuseProps { Heading = "h", Title = "t" }; // Both sort by Title; the tie is broken by the property name: Heading, then Title. HashOf(props).Should().Be(Expected(props, "h|t")); } } Path: redb/redb.Tests.Integration/Tests/Unit/RedbIndexComparerTests.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/Unit/RedbIndexComparerTests.cs ---- using redb.Core.Models; namespace redb.Tests.Integration.Tests.Unit; /// The comparison of expected indexes with the catalog (RedbIndexComparer), and the one-line form of a statement. public class RedbIndexComparerTests { private static RedbExpectedIndex Expected(string name, string[] key, string[]? include = null, bool unique = false) => new(name, "_values", unique, key, include ?? [], $"CREATE INDEX {name}"); private static RedbIndexShape Actual(string name, string[] key, string[]? include = null, bool unique = false, bool valid = true) => new() { Name = name, Table = "_values", KeyColumns = key, IncludedColumns = include ?? [], IsUnique = unique, IsValid = valid }; [Fact] public void Reports_Missing_Invalid_Differs_AndNothingForTheRest() { var expected = new[] { Expected("IX_a", ["_id_structure", "_array_index"]), Expected("IX_b", ["_id_object"]), Expected("IX_c", ["_id_structure", "_id_object"], ["_long", "_double"]), Expected("IX_d", ["_id_structure", "_id_object"]), Expected("IX_e", ["_id_object"], unique: true), }; var actual = new[] { Actual("ix_b", ["_ID_OBJECT"]), // same, by name and columns, any case Actual("IX_c", ["_id_structure", "_id_object"], ["_double", "_long"]), // INCLUDE is a set Actual("IX_d", ["_id_object", "_id_structure"]), // key order differs Actual("IX_e", ["_id_object"], valid: false), // INVALID Actual("IX_mine", ["_note"]), // an index of the operator: not reported }; var report = RedbIndexComparer.Compare(expected, actual); report.ExpectedCount.Should().Be(5); report.Findings.Select(f => (f.Name, f.State)).Should().BeEquivalentTo(new[] { ("IX_a", RedbIndexState.Missing), ("IX_d", RedbIndexState.Differs), ("IX_e", RedbIndexState.Invalid), }); report.Repairable.Select(f => f.Name).Should().BeEquivalentTo(["IX_a", "IX_e"]); } [Fact] public void Uniqueness_IsPartOfTheShape() { var report = RedbIndexComparer.Compare([Expected("IX_u", ["_id"], unique: true)], [Actual("IX_u", ["_id"])]); report.Findings.Single().State.Should().Be(RedbIndexState.Differs); } [Fact] public void Finding_SaysWhatTheIndexServes() { var report = RedbIndexComparer.Compare([Expected("IX__values__array_key", ["_id_structure", "_array_index"])], []); report.Findings.Single().ToString().Should().Contain("Missing").And.Contain("dictionary key"); RedbIndexPurpose.Of("IX__values__structure_long_object").Should().Contain("long"); } [Fact] public void OneLine_CollapsesWhitespace_OutsideQuotedText() { RedbExpectedIndex.OneLine("CREATE INDEX \"IX a\"\r\n ON _values (_id)\n WHERE _s = 'a b'") .Should().Be("CREATE INDEX \"IX a\" ON _values (_id) WHERE _s = 'a b'"); RedbExpectedIndex.OneLine("CREATE INDEX [IX b] ON [dbo].[_values] ([_id])") .Should().Be("CREATE INDEX [IX b] ON [dbo].[_values] ([_id])"); } [Fact] public void RepairResult_TheFourParameterConstructorOf480_StillBuilds_WithNoDuplicates() => new RedbIndexRepairResult([], [], [], null).Duplicates.Should().BeEmpty(); } Path: redb/redb.Tests.Integration/Tests/Unit/RedbKeySerializerValueTupleTests.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/Unit/RedbKeySerializerValueTupleTests.cs ---- using System.Text; using redb.Core.Utils; namespace redb.Tests.Integration.Tests.Unit; /// /// A dictionary key that is a ValueTuple of eight or more fields. Such a tuple keeps its fields from the eighth on in a /// nested ValueTuple in the field Rest. The key text is the JSON of the tuple's fields: two keys that differ only from /// the eighth field on must give two texts, and the text must read back to the same key. No database required. /// public class RedbKeySerializerValueTupleTests { private static string Text(string json) => Convert.ToBase64String(Encoding.UTF8.GetBytes(json)); [Fact] public void EightFieldKeys_DifferingInTheEighthField_GiveDifferentTexts() { var first = (1, 2, 3, 4, 5, 6, 7, 8); var second = (1, 2, 3, 4, 5, 6, 7, 9); RedbKeySerializer.Serialize(first).Should().NotBe(RedbKeySerializer.Serialize(second), "the two keys differ in their eighth field"); } [Fact] public void EightFieldKey_ReadsBackAsWritten() { var key = (1, 2, 3, 4, 5, 6, 7, 8); RedbKeySerializer.Deserialize<(int, int, int, int, int, int, int, int)>(RedbKeySerializer.Serialize(key)) .Should().Be(key); } [Fact] public void EightFieldKey_WritesRestAsTheObjectOfItsOwnFields() { RedbKeySerializer.Serialize((1, 2, 3, 4, 5, 6, 7, 8)).Should().Be( Text("{\"Item1\":1,\"Item2\":2,\"Item3\":3,\"Item4\":4,\"Item5\":5,\"Item6\":6,\"Item7\":7,\"Rest\":{\"Item1\":8}}")); } [Fact] public void NineFieldKey_OfMixedTypes_ReadsBackAsWritten() { var key = (1, "two", 3L, 4.5m, true, 'f', (short)7, Guid.Parse("8c0e7e0f-1d7a-4c56-9f6c-3b1a2c4d5e6f"), "nine"); RedbKeySerializer.Deserialize<(int, string, long, decimal, bool, char, short, Guid, string)>( RedbKeySerializer.Serialize(key)) .Should().Be(key); } [Fact] public void SixteenFieldKey_RestInsideRest_ReadsBackAsWritten_AndTheLastFieldCounts() { var key = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); var other = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17); RedbKeySerializer.Deserialize<(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int)>( RedbKeySerializer.Serialize(key)) .Should().Be(key); RedbKeySerializer.Serialize(key).Should().NotBe(RedbKeySerializer.Serialize(other), "the sixteenth field sits in the Rest of the Rest and must reach the text"); } [Fact] public void SevenFieldKey_ReadsBackAsWritten() { var key = (1, 2, 3, 4, 5, 6, 7); RedbKeySerializer.Deserialize<(int, int, int, int, int, int, int)>(RedbKeySerializer.Serialize(key)) .Should().Be(key); } [Fact] public void KeysOfUpToSevenFields_GiveTheTextTheyAlwaysGave() { RedbKeySerializer.Serialize((1, "a")).Should().Be(Text("{\"Item1\":1,\"Item2\":\"a\"}")); RedbKeySerializer.Serialize((1, 2, 3, 4, 5, 6, 7)).Should().Be( Text("{\"Item1\":1,\"Item2\":2,\"Item3\":3,\"Item4\":4,\"Item5\":5,\"Item6\":6,\"Item7\":7}")); } [Fact] public void StoredEightFieldKey_WithEmptyRest_ReadsAsBefore_TailAtDefault() { var stored = Text("{\"Item1\":1,\"Item2\":2,\"Item3\":3,\"Item4\":4,\"Item5\":5,\"Item6\":6,\"Item7\":7,\"Rest\":{}}"); RedbKeySerializer.Deserialize<(int, int, int, int, int, int, int, int)>(stored) .Should().Be((1, 2, 3, 4, 5, 6, 7, 0)); } // A ValueTuple nested in a field of the key, not as Rest: System.Text.Json writes no fields, so the nested tuple // must be taken apart the same way as the key itself. [Fact] public void NestedTupleKeys_DifferingInTheNestedTuple_GiveDifferentTexts() { RedbKeySerializer.Serialize(((1, 2), 3)).Should().NotBe(RedbKeySerializer.Serialize(((9, 9), 3)), "the two keys differ in their nested tuple"); } [Fact] public void NestedTupleKey_ReadsBackAsWritten() { var key = ((1, "a"), 3, (4, (5L, 6))); RedbKeySerializer.Deserialize<((int, string), int, (int, (long, int)))>(RedbKeySerializer.Serialize(key)) .Should().Be(key); } [Fact] public void NestedTupleKey_WritesTheNestedTupleAsTheObjectOfItsFields() { RedbKeySerializer.Serialize(((1, 2), 3)).Should().Be( Text("{\"Item1\":{\"Item1\":1,\"Item2\":2},\"Item2\":3}")); } [Fact] public void StoredNestedTupleKey_WithEmptyNestedPart_ReadsAsBefore_Defaults() { var stored = Text("{\"Item1\":{},\"Item2\":3}"); RedbKeySerializer.Deserialize<((int, int), int)>(stored).Should().Be(((0, 0), 3)); } // Tuple<> is a class with properties; System.Text.Json writes and reads it. A ValueTuple inside it is not. [Fact] public void ReferenceTupleKey_ReadsBackAsWritten_EightItemsIncluded() { var pair = Tuple.Create(1, "a"); var eight = Tuple.Create(1, 2, 3, 4, 5, 6, 7, 8); RedbKeySerializer.Deserialize>(RedbKeySerializer.Serialize(pair)).Should().Be(pair); RedbKeySerializer.Deserialize>>(RedbKeySerializer.Serialize(eight)) .Should().Be(eight); RedbKeySerializer.Serialize(eight).Should().NotBe(RedbKeySerializer.Serialize(Tuple.Create(1, 2, 3, 4, 5, 6, 7, 9))); } [Fact] public void ReferenceTupleKey_WithANestedValueTuple_KeepsIt() { var key = Tuple.Create((1, 2), 3); RedbKeySerializer.Serialize(key).Should().NotBe(RedbKeySerializer.Serialize(Tuple.Create((9, 9), 3))); RedbKeySerializer.Deserialize>(RedbKeySerializer.Serialize(key)).Should().Be(key); } public sealed record KeyWithTuple(string Name, (int, int) Pair); public sealed record PlainKey(int A, string B); [Fact] public void ClassKey_WithAValueTupleProperty_KeepsIt() { var key = new KeyWithTuple("k", (1, 2)); RedbKeySerializer.Serialize(key).Should().NotBe(RedbKeySerializer.Serialize(new KeyWithTuple("k", (9, 9)))); RedbKeySerializer.Deserialize(RedbKeySerializer.Serialize(key)).Should().Be(key); } [Fact] public void KeysWithNoNestedTuple_GiveTheTextTheyAlwaysGave() { RedbKeySerializer.Serialize(new PlainKey(1, "x")).Should().Be(Text("{\"A\":1,\"B\":\"x\"}")); RedbKeySerializer.Serialize(Tuple.Create(1, "a")).Should().Be(Text("{\"Item1\":1,\"Item2\":\"a\"}")); } [Fact] public void DictionaryHash_FollowsTheKeyText_EightFieldKeysDifferingInTheEighthField() { var first = new Dictionary<(int, int, int, int, int, int, int, int), string> { [(1, 2, 3, 4, 5, 6, 7, 8)] = "v" }; var second = new Dictionary<(int, int, int, int, int, int, int, int), string> { [(1, 2, 3, 4, 5, 6, 7, 9)] = "v" }; var firstHash = RedbHash.ComputeForProps(first); var secondHash = RedbHash.ComputeForProps(second); firstHash.Should().NotBeNull(); (firstHash == secondHash).Should().BeFalse("the two keys differ in their eighth field"); } } Path: redb/redb.Tests.Integration/Tests/Unit/RedbListItemSerializationTests.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/Unit/RedbListItemSerializationTests.cs ---- using System.Text.Json; using redb.Core.Models.Entities; namespace redb.Tests.Integration.Tests.Unit; /// /// is a lazy load behind a property getter. A serializer walking /// public properties must not wake it: that is how an audit log or an HTTP response ends up issuing /// database loads (a production report, 2026-09). /// /// No redb scope is live here: a read of Object would throw (a lazy load runs on the reader's scope, owner decision /// 2026-09-15) or, under a configured fresh scope, leave the item loaded - both are caught. /// /// [Collection("RedbListItemSerialization")] public class RedbListItemSerializationTests { [Fact] public void SystemTextJson_DoesNotWakeTheLazyObjectLoader() { var item = new RedbListItem { Id = 1, IdList = 2, Value = "v", IdObject = 42 }; var json = JsonSerializer.Serialize(item); item.IsObjectLoaded.Should().BeFalse("serialization is not a request to load the linked object"); json.Should().NotContain("\"object\""); json.Should().Contain("\"id_object\":42"); } } Path: redb/redb.Tests.Integration/Tests/Unit/RedbMd5Tests.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/Unit/RedbMd5Tests.cs ---- using System.Security.Cryptography; using System.Text; using redb.Core.Utils; namespace redb.Tests.Integration.Tests.Unit; /// /// Guards the managed MD5 fallback used on browser-wasm (Blazor WebAssembly), where the runtime ships /// no MD5 provider and MD5.Create() throws. /// /// /// Why this matters beyond wasm: REDB stores hashes as in the database, so a managed /// implementation that differs from the platform one by a single bit would silently invalidate every /// existing database — change tracking and cache validation compare these values. These tests assert /// bit-for-bit equality against , which is what makes the /// fallback safe to ship. /// /// /// No database — pure calculator check. /// public class RedbMd5Tests { private static byte[] SystemMd5(byte[] data) { using var md5 = MD5.Create(); return md5.ComputeHash(data); } /// RFC 1321 section A.5 test suite — the canonical vectors. [Theory] [InlineData("", "d41d8cd98f00b204e9800998ecf8427e")] [InlineData("a", "0cc175b9c0f1b6a831c399e269772661")] [InlineData("abc", "900150983cd24fb0d6963f7d28e17f72")] [InlineData("message digest", "f96b697d7cb7938d525a2f31aaf161d0")] [InlineData("abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b")] [InlineData("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "d174ab98d277d9f5a5611c2c9f419d9f")] [InlineData("12345678901234567890123456789012345678901234567890123456789012345678901234567890", "57edf4a22be3c955ac49da2e2107b67a")] public void Managed_Matches_RfcVectors(string input, string expectedHex) { var actual = RedbMd5.ComputeHashManaged(Encoding.ASCII.GetBytes(input)); Assert.Equal(expectedHex, Convert.ToHexString(actual).ToLowerInvariant()); } /// /// Padding is where MD5 implementations go wrong: the message is padded to a 64-byte block with a /// trailing 8-byte length, so lengths around 55/56 and 119/120 exercise the "one extra block" branch. /// [Theory] [InlineData(0)] [InlineData(1)] [InlineData(54)] [InlineData(55)] [InlineData(56)] [InlineData(57)] [InlineData(63)] [InlineData(64)] [InlineData(65)] [InlineData(119)] [InlineData(120)] [InlineData(127)] [InlineData(128)] [InlineData(129)] [InlineData(1000)] public void Managed_Matches_System_AtBlockBoundaries(int length) { var data = new byte[length]; for (int i = 0; i < length; i++) data[i] = (byte)(i * 31 + 7); Assert.Equal(SystemMd5(data), RedbMd5.ComputeHashManaged(data)); } [Fact] public void Managed_Matches_System_OnRandomBuffers() { var rnd = new Random(20260731); for (int i = 0; i < 200; i++) { var data = new byte[rnd.Next(0, 4096)]; rnd.NextBytes(data); Assert.Equal(SystemMd5(data), RedbMd5.ComputeHashManaged(data)); } } /// /// The dispatcher must return the same bytes whichever implementation it picked — otherwise a hash /// written on one platform would not match the same object read on another. /// [Fact] public void ComputeHash_Matches_System() { var data = Encoding.UTF8.GetBytes("redb|hash|payload|значение|42"); Assert.Equal(SystemMd5(data), RedbMd5.ComputeHash(data)); } /// Digest is always 16 bytes — it is stored as a Guid. [Fact] public void Digest_Is_16_Bytes() { Assert.Equal(16, RedbMd5.ComputeHashManaged([]).Length); Assert.Equal(16, RedbMd5.ComputeHashManaged(new byte[5000]).Length); } } Path: redb/redb.Tests.Integration/Tests/Unit/RedbServiceConfigurationCopyTests.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/Unit/RedbServiceConfigurationCopyTests.cs ---- using System.Reflection; using redb.Core.Models.Configuration; namespace redb.Tests.Integration.Tests.Unit; /// /// Copying a configuration (review CFG-1). Clone listed its settings by hand and had fallen behind: five of them /// (AutoApplyDatabaseUpgrades, StringCollation, EnablePvtPrefilter, PropsSaveStrategy, /// DefaultCheckPermissionsOnQuery) came back at their defaults, so a configuration "fixed" by the validator could /// switch automatic schema upgrades back on. Every writable setting is set here to a value that is not its default /// and must survive the copy - a setting added later without being copied fails this test. No database required. /// public class RedbServiceConfigurationCopyTests { private static readonly PropertyInfo[] Settings = typeof(RedbServiceConfiguration) .GetProperties(BindingFlags.Public | BindingFlags.Instance) .Where(p => p.CanRead && p.CanWrite) .ToArray(); /// The identity of a connection, as opposed to the behaviour settings a temporary scope may change. private static readonly string[] Identity = [nameof(RedbServiceConfiguration.ConnectionString), nameof(RedbServiceConfiguration.CacheDomain)]; private static RedbServiceConfiguration WithEverySettingChanged() { var config = new RedbServiceConfiguration(); foreach (var p in Settings) p.SetValue(config, NotTheDefault(p, p.GetValue(config))); return config; } private static object? NotTheDefault(PropertyInfo p, object? current) => p.PropertyType switch { var t when t == typeof(bool) => !(bool)current!, var t when t == typeof(int) => 7, // valid for every ranged int setting, the default of none var t when t == typeof(long) => 7L, var t when t == typeof(TimeSpan) => TimeSpan.FromMinutes(3), var t when t == typeof(TimeSpan?) => TimeSpan.FromMinutes(3), var t when t == typeof(string) => "und-x-icu", // a valid collation name, and a valid anything else var t when t.IsEnum => Enum.GetValues(t).Cast().First(v => !v.Equals(current)), var t when t == typeof(JsonSerializationOptions) => new JsonSerializationOptions { WriteIndented = !((JsonSerializationOptions)current!).WriteIndented, UseUnsafeRelaxedJsonEscaping = !((JsonSerializationOptions)current!).UseUnsafeRelaxedJsonEscaping }, var t => throw new NotSupportedException( $"Setting {p.Name} of type {t.Name}: teach this test a non-default value for the type.") }; private static void ShouldMatch(RedbServiceConfiguration copy, RedbServiceConfiguration source, IEnumerable settings) { foreach (var p in settings) { if (p.PropertyType == typeof(JsonSerializationOptions)) { copy.JsonOptions.Should().NotBeSameAs(source.JsonOptions, "the copy owns its JSON options"); copy.JsonOptions.Should().BeEquivalentTo(source.JsonOptions, $"{p.Name} is copied"); continue; } p.GetValue(copy).Should().Be(p.GetValue(source), $"{p.Name} is copied"); } } [Fact] public void Clone_CopiesEverySetting() { var source = WithEverySettingChanged(); ShouldMatch(source.Clone(), source, Settings); } [Fact] public void CopyBehaviourFrom_CopiesEverySettingButTheConnectionIdentity() { var source = WithEverySettingChanged(); var target = new RedbServiceConfiguration { ConnectionString = "Data Source=mine", CacheDomain = "mine" }; target.CopyBehaviourFrom(source); ShouldMatch(target, source, Settings.Where(p => !Identity.Contains(p.Name))); target.ConnectionString.Should().Be("Data Source=mine"); target.CacheDomain.Should().Be("mine"); } } Path: redb/redb.Tests.Integration/Tests/Unit/RedundantArrayGuardTests.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/Unit/RedundantArrayGuardTests.cs ---- using System.Linq.Expressions; using redb.Core.Pro.Query; using redb.Core.Query.QueryExpressions; namespace redb.Tests.Integration.Tests.Unit; /// /// The Pro parser drops the null guard of an array that an element test of the same AND chain already requires, and /// keeps every other guard. Pure parsing, no database. /// public class RedundantArrayGuardTests { public class GuardRow { public string? Kind { get; set; } } public class GuardProps { public string[]? Skills { get; set; } public List? Tags { get; set; } public GuardRow[]? Rows { get; set; } public int Age { get; set; } } private static FilterExpression Parse(Expression> predicate) => new ProFilterExpressionParser().ParseFilter(predicate); private static List Guards(FilterExpression node) => node switch { NullCheckExpression n => [n], LogicalExpression l => l.Operands.SelectMany(Guards).ToList(), _ => [] }; // Dropped [Fact] public void GuardBeforeContains_IsDropped() { var filter = Parse(p => p.Skills != null && p.Skills.Contains("C#")); var contains = Assert.IsType(filter); Assert.Equal(ComparisonOperator.ArrayContains, contains.Operator); Assert.Equal("Skills", contains.Property.Name); } [Fact] public void GuardAfterContains_IsDropped() { var filter = Parse(p => p.Skills!.Contains("C#") && p.Skills != null); Assert.IsType(filter); } [Fact] public void GuardBetweenScalarAndContains_IsDropped_TheScalarStays() { var filter = Parse(p => p.Age > 30 && p.Skills != null && p.Skills.Contains("C#")); Assert.Empty(Guards(filter)); var and = Assert.IsType(filter); Assert.Equal(LogicalOperator.And, and.Operator); Assert.Contains(and.Operands, o => o is ComparisonExpression { Property.Name: "Age" }); Assert.Contains(and.Operands, o => o is ComparisonExpression { Operator: ComparisonOperator.ArrayContains }); } [Fact] public void GuardWithTwoContainsUnderAnd_IsDropped() { var filter = Parse(p => p.Skills != null && p.Skills.Contains("C#") && p.Skills.Contains("SQL")); Assert.Empty(Guards(filter)); var and = Assert.IsType(filter); Assert.Equal(2, and.Operands.Count); } [Fact] public void GuardBeforeOrOfContainsOnTheSameArray_IsDropped() { var filter = Parse(p => p.Skills != null && (p.Skills.Contains("C#") || p.Skills.Contains("Python"))); var or = Assert.IsType(filter); Assert.Equal(LogicalOperator.Or, or.Operator); Assert.Empty(Guards(filter)); } [Fact] public void GuardBeforeAnyWithPredicateOverClasses_IsDropped() { var filter = Parse(p => p.Rows != null && p.Rows.Any(r => r.Kind == "a")); Assert.IsType(filter); } [Fact] public void GuardInANestedAndOfTheRootChain_IsDropped() { var filter = Parse(p => (p.Skills != null && p.Age > 30) && p.Skills.Contains("C#")); Assert.Empty(Guards(filter)); } // Kept [Fact] public void GuardAlone_Stays() { var filter = Parse(p => p.Skills != null); Assert.IsType(filter); } [Fact] public void GuardWithAScalarOnly_Stays() { Assert.Single(Guards(Parse(p => p.Skills != null && p.Age > 30))); } [Fact] public void GuardOnAnotherArray_Stays() { var guard = Assert.Single(Guards(Parse(p => p.Tags != null && p.Skills!.Contains("C#")))); Assert.Equal("Tags", guard.Property.Name); } [Fact] public void IsNull_Stays() { var guard = Assert.Single(Guards(Parse(p => p.Skills == null || p.Skills.Contains("C#")))); Assert.True(guard.IsNull); } [Fact] public void GuardUnderOr_Stays() { Assert.Single(Guards(Parse(p => (p.Skills != null || p.Age > 30) && p.Skills!.Contains("C#")))); } [Fact] public void GuardUnderNot_Stays() { Assert.Single(Guards(Parse(p => !(p.Skills != null && p.Skills.Contains("C#"))))); } [Fact] public void GuardBeforeNegatedContains_Stays() { Assert.Single(Guards(Parse(p => p.Skills != null && !p.Skills.Contains("C#")))); } [Fact] public void GuardBeforeContainsOfNull_Stays() { Assert.Single(Guards(Parse(p => p.Skills != null && p.Skills.Contains(null!)))); } [Fact] public void GuardBeforeOrWithABranchWithoutAnElementTest_Stays() { Assert.Single(Guards(Parse(p => p.Skills != null && (p.Skills.Contains("C#") || p.Age > 30)))); } [Fact] public void GuardBeforeOrOfContainsOnDifferentArrays_Stays() { Assert.Single(Guards(Parse(p => p.Skills != null && (p.Skills.Contains("C#") || p.Tags!.Contains("x"))))); } [Fact] public void GuardBeforeACount_Stays() { Assert.Single(Guards(Parse(p => p.Tags != null && p.Tags.Count > 0))); Assert.Single(Guards(Parse(p => p.Tags != null && p.Tags.Count == 0))); } } Path: redb/redb.Tests.Integration/Tests/Unit/RollbackAfterFailureTests.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/Unit/RollbackAfterFailureTests.cs ---- using System; using System.Threading.Tasks; using redb.Core.Data; namespace redb.Tests.Integration.Tests.Unit; /// /// A rollback after failed work must not replace the failure. On SQL Server a timeout or a deadlock victim ends the /// transaction on the server, the client's rollback then throws "This SqlTransaction has completed", and that error used /// to surface instead of the SqlException. The original is rethrown as it was; the rollback error rides on its Data. /// No database required. /// public class RollbackAfterFailureTests { [Fact] public async Task FailedRollback_IsAttached_AndTheOriginalStaysTheOneToRethrow() { var original = new TimeoutException("the work failed"); var rollbackFailure = new InvalidOperationException("This SqlTransaction has completed; it is no longer usable."); await RollbackAfterFailure.RollbackAsync(new Transaction(rollbackFailure), original); original.Data[RollbackAfterFailure.DataKey].Should().BeSameAs(rollbackFailure); } [Fact] public async Task SuccessfulRollback_LeavesTheOriginalUntouched() { var original = new TimeoutException("the work failed"); var transaction = new Transaction(null); await RollbackAfterFailure.RollbackAsync(transaction, original); transaction.RolledBack.Should().BeTrue(); original.Data.Contains(RollbackAfterFailure.DataKey).Should().BeFalse(); } private sealed class Transaction(Exception? rollbackFailure) : IRedbTransaction { public bool RolledBack { get; private set; } public Guid TransactionId { get; } = Guid.NewGuid(); public bool IsActive => !RolledBack; public DateTimeOffset StartedAt { get; } = DateTimeOffset.UtcNow; public Task CommitAsync() => Task.CompletedTask; public Task RollbackAsync() { if (rollbackFailure != null) throw rollbackFailure; RolledBack = true; return Task.CompletedTask; } public ValueTask DisposeAsync() => ValueTask.CompletedTask; } } Path: redb/redb.Tests.Integration/Tests/Unit/RootProviderDetectionTests.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/Unit/RootProviderDetectionTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core; namespace redb.Tests.Integration.Tests.Unit; /// /// The fact rests on: in Microsoft.Extensions.DependencyInjection the root /// scope's provider - what a service resolved from the container itself receives - is its own /// , and a child scope's provider is not. A change of the container would fail here, /// not in production. /// public class RootProviderDetectionTests { private sealed class Probe { public Probe(IServiceProvider serviceProvider) => FromRoot = RedbServiceProviders.IsRoot(serviceProvider); public bool FromRoot { get; } } [Fact] public void TheRootProvider_IsRecognised_AndAScopeIsNot() { var services = new ServiceCollection(); services.AddScoped(); using var root = services.BuildServiceProvider(); root.GetRequiredService().FromRoot.Should().BeTrue("resolved from the container itself"); using var scope = root.CreateScope(); scope.ServiceProvider.GetRequiredService().FromRoot.Should().BeFalse("resolved from a scope"); } } Path: redb/redb.Tests.Integration/Tests/Unit/SaveInterceptorRegistryTests.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/Unit/SaveInterceptorRegistryTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core.Extensions; using redb.Core.Interception; using redb.SQLite.Extensions; namespace redb.Tests.Integration.Tests.Unit; /// /// The run-time registry of save interceptors and the pipeline a storage provider reads it through: subscription /// and removal, the order DI first then registry, snapshots that do not move under a running operation, no /// allocation when nobody listens, and the TryAdd registration that lets several containers share one registry. /// No database: the save path itself is covered by SaveInterceptorTestsBase. /// public class SaveInterceptorRegistryTests { private sealed class Probe(string name) : IRedbSaveInterceptor { public override string ToString() => name; } [Fact] public void Add_ThenDispose_RemovesOnlyThatSubscription() { var registry = new RedbSaveInterceptorRegistry(); var a = new Probe("a"); var b = new Probe("b"); var ha = registry.Add(a); using var hb = registry.Add(b); registry.Current.Should().Equal(a, b); ha.Dispose(); registry.Current.Should().Equal(b); } [Fact] public void Dispose_Twice_IsANoOp() { var registry = new RedbSaveInterceptorRegistry(); var a = new Probe("a"); var h = registry.Add(a); h.Dispose(); h.Dispose(); registry.Current.Should().BeEmpty(); } [Fact] public void SameInstanceAddedTwice_RunsTwice_AndEachHandleRemovesOne() { var registry = new RedbSaveInterceptorRegistry(); var a = new Probe("a"); var h1 = registry.Add(a); var h2 = registry.Add(a); registry.Current.Should().Equal(a, a); h1.Dispose(); h1.Dispose(); registry.Current.Should().Equal(a); h2.Dispose(); registry.Current.Should().BeEmpty(); } [Fact] public void Current_IsASnapshot_ThatLaterChangesDoNotTouch() { var registry = new RedbSaveInterceptorRegistry(); var a = new Probe("a"); using var ha = registry.Add(a); var before = registry.Current; using var hb = registry.Add(new Probe("b")); ha.Dispose(); before.Should().Equal(a); } [Fact] public void Add_Null_Throws() { var registry = new RedbSaveInterceptorRegistry(); var act = () => registry.Add(null!); act.Should().Throw(); } [Fact] public async Task ConcurrentAddAndDispose_LoseNothing() { var registry = new RedbSaveInterceptorRegistry(); var keep = Enumerable.Range(0, 200).Select(i => new Probe($"keep{i}")).ToArray(); await Task.WhenAll(Enumerable.Range(0, 200).Select(i => Task.Run(() => { registry.Add(keep[i]); var temp = registry.Add(new Probe($"temp{i}")); temp.Dispose(); temp.Dispose(); }))); registry.Current.Should().HaveCount(200).And.OnlyHaveUniqueItems(); registry.Current.Should().OnlyContain(p => keep.Contains(p), "every temporary subscription is gone"); } [Fact] public void Pipeline_RunsDiFirst_ThenTheRegistryInSubscriptionOrder() { var registry = new RedbSaveInterceptorRegistry(); var di1 = new Probe("di1"); var di2 = new Probe("di2"); var r1 = new Probe("r1"); var r2 = new Probe("r2"); using var h1 = registry.Add(r1); using var h2 = registry.Add(r2); var pipeline = new RedbSaveInterceptorPipeline([di1, di2], registry); pipeline.Snapshot().Should().Equal(di1, di2, r1, r2); } [Fact] public void Pipeline_Snapshot_DoesNotMoveWhenTheRegistryChanges() { var registry = new RedbSaveInterceptorRegistry(); var di = new Probe("di"); var r = new Probe("r"); var pipeline = new RedbSaveInterceptorPipeline([di], registry); var h = registry.Add(r); var during = pipeline.Snapshot(); h.Dispose(); using var late = registry.Add(new Probe("late")); during.Should().Equal(di, r); pipeline.Snapshot().Should().HaveCount(2).And.NotContain(r); } [Fact] public void Pipeline_WithNobodyListening_ReturnsTheSameEmptyList() { var withRegistry = new RedbSaveInterceptorPipeline(null, new RedbSaveInterceptorRegistry()); var first = withRegistry.Snapshot(); var second = withRegistry.Snapshot(); first.Should().BeEmpty(); second.Should().BeSameAs(first, "an empty snapshot allocates nothing"); RedbSaveInterceptorPipeline.Empty.Snapshot().Should().BeEmpty(); } [Fact] public void Pipeline_WithOneSourceOnly_HandsItOutWithoutCopying() { var registry = new RedbSaveInterceptorRegistry(); using var h = registry.Add(new Probe("r")); var registryOnly = new RedbSaveInterceptorPipeline(null, registry); registryOnly.Snapshot().Should().BeSameAs(registry.Current); var diOnly = new RedbSaveInterceptorPipeline([new Probe("di")], new RedbSaveInterceptorRegistry()); diOnly.Snapshot().Should().BeSameAs(diOnly.Snapshot()); } [Fact] public void AddRedb_RegistersOneRegistry_AndKeepsOneRegisteredBefore() { var services = new ServiceCollection(); services.AddRedb(o => o.UseSqlite("Data Source=unused.db")); using (var sp = services.BuildServiceProvider()) { var registry = sp.GetRequiredService(); registry.Should().BeOfType(); sp.GetRequiredService().Should().BeSameAs(registry, "a singleton"); } var shared = new RedbSaveInterceptorRegistry(); var withShared = new ServiceCollection(); withShared.AddSingleton(shared); withShared.AddRedb(o => o.UseSqlite("Data Source=unused.db")); using var sp2 = withShared.BuildServiceProvider(); sp2.GetRequiredService().Should().BeSameAs(shared, "TryAdd keeps the instance a host hands over, so its named instances share the subscriptions"); } } Path: redb/redb.Tests.Integration/Tests/Unit/SchemeHashCalculatorTests.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/Unit/SchemeHashCalculatorTests.cs ---- using redb.Core.Models.Entities; using redb.Core.Utils; namespace redb.Tests.Integration.Tests.Unit; /// /// The scheme structure hash drives every cache invalidation (metadata cache, structure tree, Pro /// registry): a marker that changes what the builders emit must change the hash. V4 added two such /// markers - the unique-key flag (UNIQUE §4.10) and the lazy-reference marker (LAZY §6). /// public class SchemeHashCalculatorTests { private static Guid HashOf(bool? unique, bool? lazy) => SchemeHashCalculator.ComputeSchemeStructureHash(new List { new() { Id = 1, IdScheme = 7, IdType = RedbTypeIds.String, Name = "Code", Order = 1, Unique = unique, Lazy = lazy }, new() { Id = 2, IdScheme = 7, IdType = RedbTypeIds.Object, Name = "Next", Order = 2 }, }); [Fact] public void UniqueFlag_IsPartOfTheHash() { HashOf(true, null).Should().NotBe(HashOf(false, null), "a key appearing or disappearing must invalidate the caches"); HashOf(true, null).Should().NotBe(HashOf(null, null)); } [Fact] public void LazyMarker_IsPartOfTheHash() { HashOf(null, true).Should().NotBe(HashOf(null, false), "virtual appearing or disappearing must invalidate the caches"); HashOf(null, true).Should().NotBe(HashOf(null, null)); } [Fact] public void SameStructures_SameHash() { HashOf(true, true).Should().Be(HashOf(true, true)); } } Path: redb/redb.Tests.Integration/Tests/Unit/SchemeNameValidatorTests.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/Unit/SchemeNameValidatorTests.cs ---- using redb.Core.Attributes; using redb.Core.Exceptions; namespace redb.Tests.Integration.Tests.Unit; /// /// The explicit-name rules, one test per rule. /// /// These live here rather than in the integration suite on purpose: a type declaring an invalid /// [RedbScheme(Name = "...")] cannot exist in the test assembly, because InitializeAsync /// auto-syncs every attributed type it can see and rethrows, which is exactly the "a bad name must /// not boot" behaviour we want in production. The rules are enforced by this validator, so this is /// where they are pinned down. /// /// /// The same rules are duplicated in the database triggers of all three providers. When a rule changes /// here, it has to change in redbPostgre.sql, redbMSSQL.sql and redbSqlite.sql too. /// /// public class SchemeNameValidatorTests { [Theory] [InlineData("Employee")] [InlineData("identity.user")] [InlineData("blog.author_stats")] [InlineData("_tsak_metrics")] [InlineData("redb.Core.Models.SomeProps")] [InlineData("Outer+Inner")] [InlineData("_leading_underscore")] [InlineData("With9Digits")] public void ValidNames_Accepted(string name) { SchemeNameValidator.IsValid(name, out var error).Should().BeTrue($"'{name}' should be valid but got: {error}"); } [Theory] [InlineData("@@__deleted")] [InlineData("@@anything goes here")] public void SystemPrefixed_BypassesEveryRule(string name) { SchemeNameValidator.IsValid(name, out _).Should().BeTrue(); } [Theory] [InlineData("", "empty")] [InlineData(" ", "empty")] [InlineData("9Lives", "digit")] [InlineData("Naming With Spaces", "characters outside")] [InlineData("Именование", "characters outside")] [InlineData("_parent: Store", "characters outside")] [InlineData("trailing.", "ends with a dot")] [InlineData("two..dots", "two consecutive dots")] [InlineData("naming.class", "reserved word")] [InlineData("object", "reserved word")] [InlineData("a.9bad", "not a valid identifier")] public void InvalidNames_RejectedWithReason(string name, string expectedReasonFragment) { SchemeNameValidator.IsValid(name, out var error).Should().BeFalse($"'{name}' must be rejected"); error.Should().NotBeNull().And.Contain(expectedReasonFragment); } [Fact] public void NameLongerThan128_Rejected() { var name = new string('a', SchemeNameValidator.MaxLength + 1); SchemeNameValidator.IsValid(name, out var error).Should().BeFalse(); error.Should().Contain("longer than"); } [Fact] public void NameOfExactly128_Accepted() { var name = new string('a', SchemeNameValidator.MaxLength); SchemeNameValidator.IsValid(name, out _).Should().BeTrue("128 is the limit, not one past it"); } [Fact] public void Validate_NamesTheOffendingTypeAndTheBrokenRule() { var act = () => SchemeNameValidator.Validate("Naming With Spaces", typeof(SchemeNameValidatorTests)); var ex = act.Should().Throw(); ex.Which.SchemeName.Should().Be("Naming With Spaces"); ex.Which.DeclaringType.Should().Be(typeof(SchemeNameValidatorTests)); ex.Which.Message.Should().Contain(nameof(SchemeNameValidatorTests), "the developer needs to know which class to fix, not just that something is wrong"); } /// /// Scenario G's payload: the conflict exception must name BOTH claimants. End-to-end detection /// (two attributed types with one name) is not automatable in-process — see the class remarks. /// [Fact] public void ConflictException_NamesBothTypes() { var ex = new RedbSchemeNameConflictException("naming.duplicate", typeof(string), typeof(int)); ex.Message.Should().Contain("System.String").And.Contain("System.Int32"); ex.SchemeName.Should().Be("naming.duplicate"); } } Path: redb/redb.Tests.Integration/Tests/Unit/SqlRedbTransactionServerEndedTests.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/Unit/SqlRedbTransactionServerEndedTests.cs ---- using System; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Microsoft.Data.SqlClient; using redb.MSSql.Data; namespace redb.Tests.Integration.Tests.Unit; /// /// A transaction that the SQL Server ended itself (command timeout, deadlock victim, an error that dooms it) is a /// zombie in SqlClient: its Connection reads null and its Rollback throws "This SqlTransaction has completed". A /// rollback asked for then has already happened, so redb's RollbackAsync and DisposeAsync stay quiet; a rollback after /// redb's own Commit or Rollback still throws as before. The zombie here is the driver's own state: a SqlTransaction /// without its internal transaction, exactly what SqlClient leaves after the server ends it. No database required. /// public class SqlRedbTransactionServerEndedTests { private static SqlTransaction Zombie() { var zombie = (SqlTransaction)RuntimeHelpers.GetUninitializedObject(typeof(SqlTransaction)); zombie.Connection.Should().BeNull("the driver reports the transaction as ended"); zombie.Invoking(t => t.Rollback()).Should().Throw( "the driver's own rollback of an ended transaction throws, which is what redb must not pass on"); return zombie; } [Fact] public async Task Rollback_OfATransactionTheServerEnded_IsQuiet_AndReleasesTheConnectionOnce() { var released = 0; var tx = new SqlRedbTransaction(Zombie(), () => released++); await tx.RollbackAsync(); tx.IsActive.Should().BeFalse(); released.Should().Be(1); } [Fact] public async Task SecondRollback_StillThrows_OurOwnStateDecidesBeforeTheDriver() { var tx = new SqlRedbTransaction(Zombie(), () => { }); await tx.RollbackAsync(); var again = () => tx.RollbackAsync(); await again.Should().ThrowAsync().WithMessage("*not active*"); } [Fact] public async Task RollbackAfterOurCommitAttempt_StillThrows() { var tx = new SqlRedbTransaction(Zombie(), () => { }); var commit = () => tx.CommitAsync(); await commit.Should().ThrowAsync("a commit of an ended transaction fails as before"); var rollback = () => tx.RollbackAsync(); await rollback.Should().ThrowAsync().WithMessage("*not active*", "after our own Commit the transaction is ours to have completed, not the server's"); } [Fact] public async Task UsingBlock_AfterTheServerEndedTheTransaction_IsQuiet() { var released = 0; var tx = new SqlRedbTransaction(Zombie(), () => released++); var dispose = async () => await tx.DisposeAsync(); await dispose.Should().NotThrowAsync(); tx.IsActive.Should().BeFalse(); released.Should().BeGreaterThanOrEqualTo(1); } [Fact] public async Task UserRollbackInCatch_ThenUsingBlock_IsQuiet() { var tx = new SqlRedbTransaction(Zombie(), () => { }); await tx.RollbackAsync(); var dispose = async () => await tx.DisposeAsync(); await dispose.Should().NotThrowAsync(); } } Path: redb/redb.Tests.Integration/Tests/Unit/SqlStatementTextTests.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/Unit/SqlStatementTextTests.cs ---- using redb.Core.Pro.Query; namespace redb.Tests.Integration.Tests.Unit; /// /// A tree count drops the ordering of the query it counts by cutting at the statement's ORDER BY. An ORDER BY inside an /// aggregate (the ordered fold of a collection field), a subquery or a CTE body is not the statement's: cutting there /// left the statement unfinished. /// public class SqlStatementTextTests { [Fact] public void TheStatementsOwnOrderBy_IsFound_AfterOnesInsideAggregatesAndSubqueries() { const string sql = "WITH t AS (SELECT a FROM x ORDER BY a) SELECT json_group_array(v.c ORDER BY v.i) FROM t ORDER BY 1 LIMIT 5"; SqlStatementText.LastTopLevelIndexOf(sql, "ORDER BY").Should().Be(sql.LastIndexOf("ORDER BY 1", StringComparison.Ordinal)); } [Fact] public void AStatementWithoutItsOwnOrderBy_GivesMinusOne_ThoughAnAggregateIsOrdered() { SqlStatementText.LastTopLevelIndexOf("SELECT array_agg(v.c ORDER BY v.i) FROM v", "ORDER BY").Should().Be(-1); SqlStatementText.LastTopLevelIndexOf("SELECT STRING_AGG(c, ',') WITHIN GROUP (ORDER BY i) FROM v", "ORDER BY").Should().Be(-1); } [Fact] public void QuotedTextAndParenthesesInLiterals_DoNotCount() { const string sql = "SELECT 'ORDER BY (' AS s, [a)b] FROM v WHERE n = 'it''s' ORDER BY s"; SqlStatementText.LastTopLevelIndexOf(sql, "ORDER BY").Should().Be(sql.LastIndexOf("ORDER BY s", StringComparison.Ordinal)); } [Fact] public void TheStartBoundsTheSearch() { const string sql = "SELECT a FROM v ORDER BY a"; SqlStatementText.LastTopLevelIndexOf(sql, "ORDER BY", sql.Length - 3).Should().Be(-1); } } Path: redb/redb.Tests.Integration/Tests/Unit/SqliteNativeExtensionGateTests.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/Unit/SqliteNativeExtensionGateTests.cs ---- using redb.SQLite.Data; namespace redb.Tests.Integration.Tests.Unit; /// /// The native SQLite extension is versioned like the PostgreSQL and SQL Server modules: a build that does not report /// the version the dialect requires is refused at initialization, naming the file. Before the gate a stale /// redbsqlite.dll next to the application loaded silently and answered in an old shape - list item JSON in the /// old form, a regex filter failing with an unrelated error. /// public class SqliteNativeExtensionGateTests { [Fact] public void AStaleExtension_IsRefused_NamingBothVersionsAndTheFile() { var act = () => SqliteNativeExtension.EnsureVersion(@"C:\app\redbsqlite.dll", deployed: "0.6.5", required: "0.6.6"); act.Should().Throw().Which.Message .Should().Contain("0.6.5").And.Contain("0.6.6").And.Contain(@"C:\app\redbsqlite.dll"); } [Fact] public void AnExtensionWithoutTheVersionFunction_IsRefused() { var act = () => SqliteNativeExtension.EnsureVersion(@"C:\app\redbsqlite.dll", deployed: null, required: "0.6.6"); act.Should().Throw().Which.Message .Should().Contain("pvt_module_version").And.Contain("0.6.6"); } [Fact] public void TheMatchingExtension_Passes() { var act = () => SqliteNativeExtension.EnsureVersion(@"C:\app\redbsqlite.dll", deployed: "0.6.6", required: "0.6.6"); act.Should().NotThrow(); } } Path: redb/redb.Tests.Integration/Tests/Unit/StreamsIndexesFilePinTests.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/Unit/StreamsIndexesFilePinTests.cs ---- using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Text; namespace redb.Tests.Integration.Tests.Unit; /// /// The streams index files of PostgreSQL Pro and SQL Server Pro are built once, at the module step that brings them /// (StreamsIndexes.Since). A change of a file therefore goes with a new module version and Since set to it; otherwise /// no existing database ever builds the changed set at start-up. This pin fails on any change of either file until the /// hash here is updated, which is the moment to do both. /// public class StreamsIndexesFilePinTests { [Theory] [InlineData("redb.Postgres.Pro", "84C1FDB8E26648AB135D863491FA26DFCED6520000ED4EB8AAE2DA424A23ACD1", "0.7.33")] [InlineData("redb.MSSql.Pro", "6D6447044394F386A34961ADE314FA5C6602BC253389570455957E1F41F5CEB9", "0.2.50")] public void StreamsIndexFile_IsTheOneItsSinceVersionBrings(string project, string sha256, string since) { var text = File.ReadAllText(Path.Combine(SourceRoot(), project, "Sql", "pvt_streams_indexes.sql")).Replace("\r\n", "\n"); Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(text))).Should().Be(sha256, "{0}/Sql/pvt_streams_indexes.sql changed: bump the module version, set StreamsIndexes.Since (now {1}) to it, " + "then update this hash", project, since); } private static string SourceRoot([CallerFilePath] string path = "") => Path.Combine(Directory.GetParent(path)!.Parent!.Parent!.Parent!.FullName, "src"); } Path: redb/redb.Tests.Integration/Tests/Unit/StringCollationIndexNameTests.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/Unit/StringCollationIndexNameTests.cs ---- using System.Text; using redb.Core.Query; using redb.Postgres.Sql; namespace redb.Tests.Integration.Tests.Unit; /// /// The name of the StringCollation index is the name PostgreSQL keeps. PostgreSQL cuts an identifier past 63 bytes, and /// a collation name may be 63 characters long (CollationNameValidator), so the prefix plus the collation can pass the /// limit. The build statement is cut by the server, but the look-up of an INVALID leftover compares the name as a value: /// with the long name it never finds the leftover, CREATE INDEX IF NOT EXISTS then meets the cut name and builds nothing, /// and every start logs the index as built while it stays INVALID. No database required. /// public class StringCollationIndexNameTests { private const int PostgreSqlIdentifierBytes = 63; [Fact] public void LongCollation_GivesTheNamePostgreSqlKeeps() { var collation = "und-u-ks-level2-kc-false-ka-shifted-x-icu"; CollationNameValidator.IsValid(collation).Should().BeTrue("the setting accepts it"); var name = new PostgreSqlDialect().StringCollationIndexName(collation); Encoding.UTF8.GetByteCount(name).Should().BeLessThanOrEqualTo(PostgreSqlIdentifierBytes); name.Should().Be("IX__values__String_pattern_und_u_ks_level2_kc_false_ka_shifted_x_icu"[..PostgreSqlIdentifierBytes], "an index built before under the cut name keeps being found"); } [Fact] public void ShortCollation_KeepsItsName() { new PostgreSqlDialect().StringCollationIndexName("und-x-icu").Should().Be("IX__values__String_pattern_und_x_icu"); } } Path: redb/redb.Tests.Integration/Tests/Unit/TemporalSemanticsTests.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/Unit/TemporalSemanticsTests.cs ---- using System.Globalization; using System.Text.Json; using redb.Core.Query.Mapping; using redb.Core.Query.Utils; using redb.Core.Serialization; using redb.Core.Utils; namespace redb.Tests.Integration.Tests.Unit; /// /// REDB's temporal contract, pinned. /// /// /// DateTime carries no time zone. The clock reading is the datum: 14:00 written is 14:00 /// read, on any machine, in any zone, through any read path. is the /// opposite and deliberately untouched: it is the native .NET type and carries a real instant. /// /// /// /// No form follows the culture. and are stored as their Ticks in /// _values._Long; the text forms ( on the JSON side, dictionary keys) must not depend on the /// ambient , or a value written on one host stops loading on another. /// /// /// /// These are unit tests on purpose: every defect they cover sits in a pure conversion, and the /// integration suites never reached any of them. All their DateTime values are /// DateTime.UtcNow or DateTimeKind.Utc literals, where the zone-less and the /// instant reading coincide exactly, and no test aggregates or projects a date at all. /// /// public class TemporalSemanticsTests { /// Runs under a specific culture, restoring the previous one. private static void UnderCulture(string name, Action body) { var previous = CultureInfo.CurrentCulture; try { CultureInfo.CurrentCulture = new CultureInfo(name); body(); } finally { CultureInfo.CurrentCulture = previous; } } private static JsonElement Json(string raw) => JsonDocument.Parse(raw).RootElement; // --------------------------------------------------------------------- // DateTime: the wall-clock contract, on every read path // --------------------------------------------------------------------- /// /// The analytics path (Min/Max, AggregateRedbAsync, GroupBy, Window, scalar projections) goes /// through . It used to call a bare DateTime.TryParse, /// whose default converts a zoned ISO string INTO THE CALLER'S /// LOCAL ZONE and returns . The reading must survive intact. /// [Theory] [InlineData("\"2025-06-15T10:30:00Z\"")] [InlineData("\"2025-06-15T10:30:00+00:00\"")] [InlineData("\"2025-06-15T10:30:00.0000000Z\"")] public void AnalyticsPath_DateTime_KeepsWallClockReadingAndUtcKind(string json) { var value = (DateTime)JsonValueConverter.Convert(Json(json), typeof(DateTime))!; value.Should().Be(new DateTime(2025, 6, 15, 10, 30, 0, DateTimeKind.Utc)); // Kind is the part that stayed broken even on a UTC host: DateTimeStyles.None labels the // result Local regardless of whether the value moved. value.Kind.Should().Be(DateTimeKind.Utc); } /// /// The same stored value read through analytics and through object materialization must be the /// same value. Previously the two disagreed by the reader's UTC offset. /// [Fact] public void AnalyticsPath_AgreesWithObjectMaterializationPath() { const string wire = "2025-06-15T10:30:00+00:00"; var viaAnalytics = (DateTime)JsonValueConverter.Convert(Json($"\"{wire}\""), typeof(DateTime))!; var viaObject = JsonSerializer.Deserialize( $"\"{wire}\"", SystemTextJsonRedbSerializer.Options); viaAnalytics.Should().Be(viaObject); viaAnalytics.Kind.Should().Be(viaObject.Kind); } /// /// DateTimeOffset keeps native semantics: it carries an instant. Both read paths reduce it to /// the same UTC-based value so a caller never sees a provider's stored offset leak through. /// [Fact] public void AnalyticsPath_DateTimeOffset_NormalizesToUtcLikeObjectPath() { const string wire = "2025-06-15T13:30:00+03:00"; var viaAnalytics = (DateTimeOffset)JsonValueConverter.Convert(Json($"\"{wire}\""), typeof(DateTimeOffset))!; var viaObject = JsonSerializer.Deserialize( $"\"{wire}\"", SystemTextJsonRedbSerializer.Options); viaAnalytics.Should().Be(viaObject); viaAnalytics.Offset.Should().Be(TimeSpan.Zero); viaAnalytics.UtcDateTime.Should().Be(new DateTime(2025, 6, 15, 10, 30, 0, DateTimeKind.Utc)); } /// The reading must not depend on the reader's culture either. [Theory] [InlineData("ru-RU")] [InlineData("en-US")] [InlineData("de-DE")] public void DateTime_ReadIsCultureIndependent(string culture) { UnderCulture(culture, () => { var viaAnalytics = (DateTime)JsonValueConverter.Convert( Json("\"2025-06-15T10:30:00Z\""), typeof(DateTime))!; var viaObject = JsonSerializer.Deserialize( "\"2025-06-15T10:30:00Z\"", SystemTextJsonRedbSerializer.Options); viaAnalytics.Should().Be(new DateTime(2025, 6, 15, 10, 30, 0, DateTimeKind.Utc)); viaObject.Should().Be(new DateTime(2025, 6, 15, 10, 30, 0, DateTimeKind.Utc)); }); } // --------------------------------------------------------------------- // DateOnly / TimeOnly / TimeSpan: invariant text form // --------------------------------------------------------------------- /// /// ru-RU uses '.' as its date separator, so even the explicit pattern "yyyy-MM-dd" produced /// "2026.08.23" — which then failed to parse back. The wire form must be invariant. /// [Theory] [InlineData("ru-RU")] [InlineData("en-US")] [InlineData("de-DE")] public void DateOnly_RoundTripsUnderAnyCulture(string culture) { var value = new DateOnly(2026, 8, 23); UnderCulture(culture, () => { var json = JsonSerializer.Serialize(value, SystemTextJsonRedbSerializer.Options); json.Should().Be("\"2026-08-23\""); JsonSerializer.Deserialize(json, SystemTextJsonRedbSerializer.Options) .Should().Be(value); }); } /// /// en-US renders a bare TimeOnly as "2:30 PM"; the DB write path used exactly that. Both the /// JSON form and the column form now go through the same invariant round-trip. /// [Theory] [InlineData("ru-RU")] [InlineData("en-US")] [InlineData("de-DE")] public void TimeOnly_RoundTripsUnderAnyCulture(string culture) { var value = new TimeOnly(14, 30, 15); UnderCulture(culture, () => { var json = JsonSerializer.Serialize(value, SystemTextJsonRedbSerializer.Options); JsonSerializer.Deserialize(json, SystemTextJsonRedbSerializer.Options) .Should().Be(value); RedbTemporalFormat.TryParseTimeOnly(RedbTemporalFormat.ToText(value), out var fromColumn) .Should().BeTrue(); fromColumn.Should().Be(value); }); } /// /// The JSON form was @"hh\:mm\:ss", which silently drops the day component and the sign: /// 3 days 2 hours came back as 2 hours. "c" is the constant round-trip format. /// [Theory] [InlineData(3, 2, 0, 0)] [InlineData(0, 2, 0, 0)] [InlineData(400, 23, 59, 59)] public void TimeSpan_KeepsDayComponent(int days, int hours, int minutes, int seconds) { var value = new TimeSpan(days, hours, minutes, seconds); var json = JsonSerializer.Serialize(value, SystemTextJsonRedbSerializer.Options); JsonSerializer.Deserialize(json, SystemTextJsonRedbSerializer.Options) .Should().Be(value); } [Fact] public void TimeSpan_KeepsSign() { var value = TimeSpan.FromHours(-5); var json = JsonSerializer.Serialize(value, SystemTextJsonRedbSerializer.Options); JsonSerializer.Deserialize(json, SystemTextJsonRedbSerializer.Options) .Should().Be(value); } /// Legacy rows written by an earlier build under a plain culture still load. [Fact] public void LegacyTextForms_StillParse() { RedbTemporalFormat.TryParseTimeSpan("02:00:00", out var span).Should().BeTrue(); span.Should().Be(TimeSpan.FromHours(2)); RedbTemporalFormat.TryParseTimeOnly("14:30:00", out var time).Should().BeTrue(); time.Should().Be(new TimeOnly(14, 30, 0)); RedbTemporalFormat.TryParseDateOnly("2026-08-23", out var date).Should().BeTrue(); date.Should().Be(new DateOnly(2026, 8, 23)); } // --------------------------------------------------------------------- // Type map and dead base field // --------------------------------------------------------------------- /// /// DateOnly is seeded with db_type 'DateTime' and resolves to _DateTimeOffset on the SQL side, /// but the C# map had no case for it and threw "Unknown type ID". /// [Fact] public void TypeMapping_ResolvesTemporalTypes() { RedbTypeMapping.GetValueColumn(RedbTypeIds.DateOnly).Should().Be("_DateTimeOffset"); RedbTypeMapping.GetValueColumn(RedbTypeIds.TimeOnly).Should().Be("_Long"); RedbTypeMapping.GetValueColumn(RedbTypeIds.TimeSpan).Should().Be("_Long"); RedbTypeMapping.GetObjectValueColumn(RedbTypeIds.DateOnly).Should().Be("_value_datetime"); RedbTypeMapping.GetObjectValueColumn(RedbTypeIds.TimeOnly).Should().Be("_value_long"); RedbTypeMapping.GetObjectValueColumn(RedbTypeIds.TimeSpan).Should().Be("_value_long"); } /// /// _date_delete is a leftover of the removed _deleted_objects table and exists in no dialect's /// DDL. Claiming it as a base field let a string-addressed query compile SQL against a column /// that is not there. /// [Theory] [InlineData("DateDelete")] [InlineData("_date_delete")] [InlineData("date_delete")] public void BaseFieldMapper_DoesNotClaimPhantomDateDelete(string name) { BaseFieldMapper.IsBaseField(name).Should().BeFalse(); } [Fact] public void BaseFieldMapper_StillClaimsRealDateFields() { BaseFieldMapper.IsBaseField("DateCreate").Should().BeTrue(); BaseFieldMapper.IsBaseField("DateModify").Should().BeTrue(); BaseFieldMapper.IsBaseField("DateBegin").Should().BeTrue(); BaseFieldMapper.IsBaseField("DateComplete").Should().BeTrue(); BaseFieldMapper.MapToColumn("DateCreate").Should().Be("_date_create"); } } Path: redb/redb.Tests.Integration/Tests/Unit/UniqueKeyEncoderTests.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/Unit/UniqueKeyEncoderTests.cs ---- using System.Text; using redb.Core.Exceptions; using redb.Core.Models.Entities; using redb.Core.Utils; namespace redb.Tests.Integration.Tests.Unit; /// /// The canonical-form rules of , one test per trap from /// UNIQUE_STRING_KEY_PLAN §3.1. The requirement is two-sided: one logical value — one key, /// different values — different keys. Every rule change must bump ; /// these tests pin the rules of version 1. /// public class UniqueKeyEncoderTests { // Non-null helper: every value case has a key; the null case is asserted directly below. private static Guid KeyOf(RedbValue v) => UniqueKeyEncoder.Compute(v)!.Value; [Fact] public void Decimal_TrailingZeros_AreOneKey() { KeyOf(new RedbValue { Numeric = 1.50m }).Should().Be(KeyOf(new RedbValue { Numeric = 1.5m })); KeyOf(new RedbValue { Numeric = 1.5m }).Should().NotBe(KeyOf(new RedbValue { Numeric = 1.51m })); KeyOf(new RedbValue { Numeric = 0.0m }).Should().Be(KeyOf(new RedbValue { Numeric = decimal.Negate(0.0m) }), "there is one zero"); } [Fact] public void Timestamps_SameInstant_IsOneKey() { var moscow = new DateTimeOffset(2026, 8, 31, 12, 0, 0, TimeSpan.FromHours(3)); var utc = new DateTimeOffset(2026, 8, 31, 9, 0, 0, TimeSpan.Zero); KeyOf(new RedbValue { DateTimeOffset = moscow }).Should().Be(KeyOf(new RedbValue { DateTimeOffset = utc })); // Precision is pinned to milliseconds - the coarsest representation every provider keeps. var aTickMore = utc.AddTicks(1); KeyOf(new RedbValue { DateTimeOffset = aTickMore }).Should().Be(KeyOf(new RedbValue { DateTimeOffset = utc })); KeyOf(new RedbValue { DateTimeOffset = utc.AddMilliseconds(1) }) .Should().NotBe(KeyOf(new RedbValue { DateTimeOffset = utc })); } [Fact] public void Strings_NfcAndNfd_AreOneKey_CaseIsNot() { var nfc = "café"; // é as one code point var nfd = "café"; // e + combining acute nfc.Should().NotBe(nfd, "the raw strings differ"); KeyOf(new RedbValue { String = nfc }).Should().Be(KeyOf(new RedbValue { String = nfd })); // No case folding and no trimming: the application owns the notion of its key. KeyOf(new RedbValue { String = "ORD-1" }).Should().NotBe(KeyOf(new RedbValue { String = "ord-1" })); KeyOf(new RedbValue { String = "ORD-1" }).Should().NotBe(KeyOf(new RedbValue { String = "ORD-1 " })); } [Fact] public void Doubles_NegativeZero_IsZero_NaNRefused() { KeyOf(new RedbValue { Double = -0.0 }).Should().Be(KeyOf(new RedbValue { Double = 0.0 })); KeyOf(new RedbValue { Double = 0.1 }).Should().NotBe(KeyOf(new RedbValue { Double = 0.2 })); var nan = () => KeyOf(new RedbValue { Double = double.NaN }); nan.Should().Throw("NaN is not equal to itself and cannot be a key"); var inf = () => KeyOf(new RedbValue { Double = double.PositiveInfinity }); inf.Should().Throw(); } [Fact] public void ByteArray_IsHashedRaw() { var a = Encoding.UTF8.GetBytes("payload"); var b = Encoding.UTF8.GetBytes("payload"); var c = Encoding.UTF8.GetBytes("payloae"); KeyOf(new RedbValue { ByteArray = a }).Should().Be(KeyOf(new RedbValue { ByteArray = b })); KeyOf(new RedbValue { ByteArray = a }).Should().NotBe(KeyOf(new RedbValue { ByteArray = c })); } [Fact] public void CrossColumn_SameText_IsNotOneKey() { // The column tag keeps the form injective across columns: long 1 is not string "1", // bool true is not long 1. KeyOf(new RedbValue { Long = 1 }).Should().NotBe(KeyOf(new RedbValue { String = "1" })); KeyOf(new RedbValue { Boolean = true }).Should().NotBe(KeyOf(new RedbValue { Long = 1 })); KeyOf(new RedbValue { Boolean = true }).Should().NotBe(KeyOf(new RedbValue { String = "1" })); } [Fact] public void NullValue_HasNoKey() { UniqueKeyEncoder.Compute(new RedbValue()).Should().BeNull("NULL never takes part in uniqueness"); } [Fact] public void Guids_AreCaseInsensitiveByConstruction() { var g = Guid.Parse("00112233-4455-6677-8899-AABBCCDDEEFF"); KeyOf(new RedbValue { Guid = g }).Should().Be(KeyOf(new RedbValue { Guid = Guid.Parse(g.ToString().ToLowerInvariant()) })); } } Path: redb/redb.Tests.Integration/Tests/Unit/WalkerPropertyRuleTests.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/Unit/WalkerPropertyRuleTests.cs ---- using System.Reflection; using redb.Core.Attributes; using redb.Core.Models.Contracts; using redb.Core.Models.Entities; using redb.Core.Pro.Materialization; using redb.Core.Providers; using redb.Core.Utils; namespace redb.Tests.Integration.Tests.Unit; /// /// The /// scheme and the save take every public instance property except and read it without /// a catch - a throwing getter fails the save. The graph walkers of a load read [RedbIgnore] properties too and /// swallowed whatever a getter threw. Now they walk the save's property set and let a getter's exception surface. /// public class WalkerPropertyRuleTests { private sealed class Counter { public int Value; } private sealed class PropsWithIgnoredGetter { public string Label { get; set; } = "props"; [RedbIgnore] public Counter Reads { get; } = new(); [RedbIgnore] public string Technical { get { Reads.Value++; return "technical"; } } } public sealed class PropsWithThrowingGetter { public string Label { get; set; } = "props"; public int Total => throw new InvalidOperationException("computed getter"); } private static void InvokeCollectBareStubs(object node) { var method = typeof(ProLazyPropsLoader).GetMethod("CollectBareStubs", BindingFlags.NonPublic | BindingFlags.Static) ?? throw new InvalidOperationException("ProLazyPropsLoader.CollectBareStubs not found - update this test"); method.Invoke(null, new object[] { node, new Dictionary>(), new HashSet(ReferenceEqualityComparer.Instance) }); } public static IEnumerable Walkers() => [ ["loader install", (Action)(props => LazyReferenceInstaller.InstallInto(props, new NoopLoader()))], ["mark unloaded", (Action)(props => LazyReferenceInstaller.MarkUnloadedWherePropsAreNull(props))], ["dirty guard", (Action)(props => LoadedGraphInspector.HasDirtyLoadedReference(props))], ["Pro stub collector", (Action)InvokeCollectBareStubs], ]; [Theory] [MemberData(nameof(Walkers))] public void Walker_DoesNotReadRedbIgnoreProperties(string walker, Action walk) { var props = new PropsWithIgnoredGetter(); walk(props); props.Reads.Value.Should().Be(0, $"{walker}: a [RedbIgnore] property is not redb's - the scheme and the save never read it"); } [Theory] [MemberData(nameof(Walkers))] public void Walker_ThrowingGetter_Surfaces(string walker, Action walk) { var act = () => walk(new PropsWithThrowingGetter()); act.Should().Throw($"{walker}: a getter that throws fails the walk as it fails the save, it is not swallowed") .Which.GetBaseException().Should().BeOfType(); } [Fact] public void PropsHash_ThrowingGetter_Surfaces() { var act = () => RedbHash.ComputeForProps(new PropsWithThrowingGetter()); act.Should().Throw("the hash does not stand in an empty string for a getter that threw") .Which.GetBaseException().Should().BeOfType(); } private sealed class NoopLoader : ILazyPropsLoader { public TProps? LoadProps(long objectId, long schemeId) where TProps : class, new() => null; public Task LoadPropsAsync(long objectId, long schemeId, CancellationToken cancellationToken = default) where TProps : class, new() => Task.FromResult(null); public Task LoadPropsForManyAsync(List> objects, CancellationToken cancellationToken = default) where TProps : class, new() => Task.CompletedTask; public Task LoadPropsForManyAsync(List> objects, HashSet? projectedStructureIds, CancellationToken cancellationToken = default) where TProps : class, new() => Task.CompletedTask; public Task LoadPropsForManyAsync(List> objects, int? propsDepth, CancellationToken cancellationToken = default) where TProps : class, new() => Task.CompletedTask; public Task LoadPropsForManyAsync(List> objects, HashSet? projectedStructureIds, int? propsDepth, CancellationToken cancellationToken = default) where TProps : class, new() => Task.CompletedTask; } } Path: redb/redb.Tests.Integration/Tests/Unit/WindowFunctionNameTests.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/Unit/WindowFunctionNameTests.cs ---- using System; using AwesomeAssertions; using redb.Core.Query.Window; using Xunit; namespace redb.Tests.Integration.Tests.Unit; /// /// is a public settable string, so a provider that appends it to /// the call text unquoted (the old func + "()" fallback in nine places across the three free /// and three Pro providers) lets a caller close a comment, a bracket or a quote and inject SQL /// (SQLI-PoC: window function name). is the single /// gate: plain identifiers pass, everything else is refused. /// public class WindowFunctionNameTests { [Theory] [InlineData("ROW_NUMBER", "ROW_NUMBER()")] [InlineData("rank", "RANK()")] [InlineData("Cume_Dist", "CUME_DIST()")] [InlineData("percent_rank", "PERCENT_RANK()")] public void PlainIdentifier_BecomesZeroArgCall(string input, string expected) => WindowFunctionName.ZeroArgCall(input).Should().Be(expected); [Theory] [InlineData("x*/ as [i],(select count(*) from sys.objects)/*")] [InlineData("COUNT); DROP TABLE _objects; --")] [InlineData("COUNT) OVER (ORDER BY 1)--")] [InlineData("1=1 OR ")] [InlineData("ROW NUMBER")] [InlineData("")] [InlineData(" ")] public void AnythingElse_IsRefused(string payload) { var act = () => WindowFunctionName.ZeroArgCall(payload); act.Should().Throw(); } [Fact] public void OverlongName_IsRefused() => WindowFunctionName.IsPlainIdentifier(new string('a', WindowFunctionName.MaxLength + 1)) .Should().BeFalse(); } Path: redb/redb.Tests.Integration/appsettings.json 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/appsettings.json ---- { "ConnectionStrings": { "Postgres": "Host=localhost;Port=5432;Username=postgres;Password=YOUR_PASSWORD;Database=redb;Pooling=true;Include Error Detail=true;Timeout=600;Command Timeout=600;Options=-c jit=off", "MSSql": "Server=localhost,1433;Database=redb;User Id=sa;Password=YOUR_PASSWORD;TrustServerCertificate=true;Command Timeout=600;", "Sqlite": "Data Source=redb_tests_sqlite.db" }, "Redb": { "License": "" } } Path: redb/redb.Tests.Integration/redb.Tests.Integration.csproj 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/redb.Tests.Integration.csproj ---- net10.0;net11.0 enable enable false true all runtime; build; native; contentfiles; analyzers; buildtransitive all runtime; build; native; contentfiles; analyzers; buildtransitive PreserveNewest PreserveNewest PreserveNewest PreserveNewest Path: redb/redb.Tests.Integration/xunit.runner.json 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/xunit.runner.json ---- { "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", "parallelizeTestCollections": false }