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"); } }