From ac8b5b6ef88fe54cbdb5bbf6923e7a4dcfb6d66f Mon Sep 17 00:00:00 2001 From: "Jeremy D. Miller" Date: Tue, 28 Apr 2026 18:58:36 -0500 Subject: [PATCH] Bump JasperFx 1.28.1 -> 1.28.2 to fix List duplicate-field codegen (#3702) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JasperFx 1.28.2 includes a fix to CodeFormatter.Write that emits safe C# for any enum value — including bit-OR'd combinations on non-[Flags] enums like Npgsql.NpgsqlDbType. Previously a member declared as [DuplicateField(DbType = NpgsqlDbType.Array | NpgsqlDbType.Text, PgType = "text[]", IndexMethod = IndexMethod.gin)] public List ListOfStrings { get; set; } would generate uncompilable source like parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.-2147483629; because Enum.ToString returns the integer literal as a string for undefined enum values. The JasperFx fix emits a checked cast for those values: `((NpgsqlDbType)(-2147483629))`. The reproduction test from elexisvenator's #3702 is preserved here verbatim; the JasperFx-side fix lets it pass with no Marten code change. Closes #3702. Co-Authored-By: Ben Edwards Co-Authored-By: Claude Opus 4.7 (1M context) --- Directory.Packages.props | 2 +- .../Bug_PR_3702_list_index_compile_error.cs | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/DocumentDbTests/Bugs/Bug_PR_3702_list_index_compile_error.cs diff --git a/Directory.Packages.props b/Directory.Packages.props index 5dff0ccc19..2b4419d268 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -13,7 +13,7 @@ - + all diff --git a/src/DocumentDbTests/Bugs/Bug_PR_3702_list_index_compile_error.cs b/src/DocumentDbTests/Bugs/Bug_PR_3702_list_index_compile_error.cs new file mode 100644 index 0000000000..4ba32416f9 --- /dev/null +++ b/src/DocumentDbTests/Bugs/Bug_PR_3702_list_index_compile_error.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Marten; +using Marten.Linq.MatchesSql; +using Marten.Schema; +using Marten.Testing.Harness; +using NpgsqlTypes; +using Weasel.Postgresql.Tables; +using Xunit; + +namespace DocumentDbTests.Bugs; + +public class Bug_PR_3702_list_index_compile_error : BugIntegrationContext +{ + [Fact] + public async Task can_create_array_duplicate_column_on_a_list_field() + { + StoreOptions(opts => + { + opts.RegisterDocumentType(); + }); + + await theStore.Storage.ApplyAllConfiguredChangesToDatabaseAsync(); + + var newDoc = new DocWithIndexOnList { Id = Guid.NewGuid(), ListOfStrings = ["foo", "bar", "baz"] }; + theSession.Store(newDoc); + await theSession.SaveChangesAsync(); + + List arrayFilter = ["foo", "baz"]; + var queriedDoc = await theSession.Query() + .Where(x => x.MatchesSql("d.list_of_strings @> ?", arrayFilter)) + .FirstOrDefaultAsync(); + + Assert.Equal(newDoc.Id, queriedDoc.Id); + } + + public class DocWithIndexOnList + { + public Guid Id { get; set; } + + [DuplicateField(DbType = NpgsqlDbType.Array | NpgsqlDbType.Text, PgType = "text[]", IndexMethod = IndexMethod.gin)] + public List ListOfStrings { get; set; } + } +}