Path: redb/redb.Tests.Integration/Tests/Collation/PostgresNoCollationTests.cs Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Collation/PostgresNoCollationTests.cs ---- using redb.Core; using redb.Core.Models.Entities; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.Collation; /// /// The other half of the contract: with StringCollation unset, behaviour on the very same /// C-ctype database is exactly what it was before the feature existed. /// /// /// This is the test that makes the feature safe to ship. It runs against a database where the /// defect is real, and asserts that REDB still reproduces it when nobody asked for a fix. Without /// it, "the default is unchanged" would be a claim rather than a fact, and an existing deployment /// could silently start returning different rows after an upgrade. /// /// /// /// It is also the mirror of : the same rows, the same /// query, the opposite expectation. Should someone later make the folding unconditional, both /// suites cannot stay green, and this one is the one that will say so. /// /// [Collection("PostgresNoCollation")] public class PostgresNoCollationTests { private readonly IRedbService _redb; public PostgresNoCollationTests(PostgresNoCollationFixture fixture) => _redb = fixture.Redb; private async Task SeedAsync() { await _redb.Context.ExecuteAsync( "DELETE FROM _objects WHERE _id_scheme IN (SELECT _id FROM _schemes WHERE _name = " + $"'{typeof(CollationProps).FullName}')"); await _redb.SaveAsync(new List> { new() { name = "cyrillic", Props = new CollationProps { Text = "ПРИВЕТ МИР", Label = "cyrillic" } }, new() { name = "ascii", Props = new CollationProps { Text = "HELLO WORLD", Label = "ascii" } }, }); } private async Task> FindAsync(string needle) { var results = await _redb.Query() .Where(c => c.Text.Contains(needle, StringComparison.OrdinalIgnoreCase)) .Take(50).ToListAsync(); return results.Select(r => r.Props.Label).ToList(); } /// /// The defect, reproduced deliberately. On LC_CTYPE=C the database folds ASCII and nothing else, /// so a lower-case Cyrillic needle finds nothing. This is not a wish, it is the documented /// behaviour of an unconfigured PostgreSQL, and REDB must not change it behind anyone's back. /// [Fact] public async Task WithoutSetting_CyrillicSearchStillFindsNothing() { await SeedAsync(); (await FindAsync("привет")).Should().BeEmpty(); } /// ASCII keeps working, which is what made the defect easy to miss. [Fact] public async Task WithoutSetting_AsciiSearchStillWorks() { await SeedAsync(); (await FindAsync("hello")).Should().Contain("ascii"); } /// An exactly-cased Cyrillic needle matches: the text itself is intact, only folding is absent. [Fact] public async Task WithoutSetting_ExactCaseCyrillicStillMatches() { await SeedAsync(); (await FindAsync("ПРИВЕТ")).Should().Contain("cyrillic"); } }