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