From f527c6037264eaf73398ce22c0d17d2b0aef78f8 Mon Sep 17 00:00:00 2001 From: Paul DeVito Date: Wed, 30 Sep 2026 17:03:13 +0300 Subject: [PATCH] fix(config)!: keep a query name in a nested path in alias replacement The public ReplaceAliasesWithPropertyPaths changed Author.name to Author.Title when name is the query name of a top-level property. The segment after the dot belongs to another type, so the replacement made a wrong path. A query name after a dot now stays as it is. The filter parser does not call this method, so filters do not change. BREAKING CHANGE: QueryKitPropertyMappings.ReplaceAliasesWithPropertyPaths no longer replaces a query name that comes after a dot. Code that calls this method directly and needs the v1.14.2 result must replace the nested segment itself. --- QueryKit.UnitTests/PropertyResolverTests.cs | 4 ++-- QueryKit/QueryKitPropertyMappings.cs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/QueryKit.UnitTests/PropertyResolverTests.cs b/QueryKit.UnitTests/PropertyResolverTests.cs index 294b368..2cc8006 100644 --- a/QueryKit.UnitTests/PropertyResolverTests.cs +++ b/QueryKit.UnitTests/PropertyResolverTests.cs @@ -555,7 +555,7 @@ public void property_prevented_for_filter_and_sort_is_removed_by_its_member_name } [Fact] - public void alias_replacement_replaces_a_query_name_in_a_nested_path() + public void alias_replacement_does_not_replace_a_query_name_in_a_nested_path() { var config = new QueryKitConfiguration(config => { @@ -564,7 +564,7 @@ public void alias_replacement_replaces_a_query_name_in_a_nested_path() var input = config.PropertyMappings.ReplaceAliasesWithPropertyPaths("""Author.Name == "x" && name == "y" """); - input.Should().Be("""Author.Title == "x" && Title == "y" """); + input.Should().Be("""Author.Name == "x" && Title == "y" """); } [Fact] diff --git a/QueryKit/QueryKitPropertyMappings.cs b/QueryKit/QueryKitPropertyMappings.cs index d771ca8..229bb4f 100644 --- a/QueryKit/QueryKitPropertyMappings.cs +++ b/QueryKit/QueryKitPropertyMappings.cs @@ -144,8 +144,9 @@ public string ReplaceAliasesWithPropertyPaths(string input) { // Use regular expression to isolate left side of the expression. Query names and // operators are matched literally, so escape any regex metacharacters they contain - // (e.g. the `^` in `^^` would otherwise be read as a start-of-line anchor). - var regex = AliasRegexCache.Get($@"\b{Regex.Escape(queryKitPropertyInfo.QueryName!)}\b(?=\s*{Regex.Escape(op)})"); + // (e.g. the `^` in `^^` would otherwise be read as a start-of-line anchor). A query name + // after a dot is a segment of a nested path, so it is not replaced. + var regex = AliasRegexCache.Get($@"(?