Skip to content

fix(config)!: keep a query name in a nested path in alias replacement - #127

Open
pdevito3 wants to merge 1 commit into
mainfrom
fm/qk-breaking-alias-dot
Open

pdevito3 wants to merge 1 commit into
mainfrom
fm/qk-breaking-alias-dot

Conversation

@pdevito3

Copy link
Copy Markdown
Owner

For later consideration in a major version. Do not merge now. #122 restored the v1.14.2 match to keep v1.x non-breaking. This PR takes the fix back.

Summary

 QueryKitPropertyMappings.ReplaceAliasesWithPropertyPaths
-  regex: \b{QueryName}\b(?=\s*{op})
+  regex: (?<!\.)\b{QueryName}\b(?=\s*{op})
  • v1.14.2: The public method QueryKitPropertyMappings.ReplaceAliasesWithPropertyPaths replaces a query name anywhere in front of an operator, also after a dot.
  • New: A query name after a dot is a segment of a nested path. The method keeps it.
  • Why: The segment after the dot belongs to another type. When name is the query name of a top-level property, the old match changes Author.Name to Author.Title, which is a wrong path.

Evidence

With config.Property<Recipe>(x => x.Title).HasQueryName("name") (the match ignores case):

ReplaceAliasesWithPropertyPaths("""Author.Name == "x" && name == "y" """)
  v1.14.2 and main: Author.Title == "x" && Title == "y"
  this PR:          Author.Name == "x" && Title == "y"

The restore test is renamed back to alias_replacement_does_not_replace_a_query_name_in_a_nested_path and expects the new result.

dotnet test on this branch: all unit and integration tests pass, 0 failures.

Merge Danger

Door: two-way

The change is one lookbehind in one regex.

Blast Radius: direct callers

The parser does not call this method, so filters do not change. Only consumer code that calls ReplaceAliasesWithPropertyPaths directly sees the new result.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant