Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(infer): consolidate two main functions #912

Merged
merged 8 commits into from
Nov 28, 2024

Conversation

patricebender
Copy link
Member

@patricebender patricebender commented Nov 25, 2024

Rework #617

when the infer function was developed, it grew quite fast and some functions were tailor made for very specific use cases. While separation of concerns is a good practice w.r.t. maintainability, the wheel must not be re-invented for each minor deviation in behavior.

That being said, the two function inferQueryElement and attachRefLinksToArg are doing essentially the same. They both walk an arg which is - generally spoken - an expression. That might be a simple ref, func, val or a (nested) xpr.

  • inferQueryElement was used for the columns of a query. Each column was resolved to a query element. All elements together formed the set of query elements. The other main part of the function is the attachment of the infamous $refLinks next to each ref array. Moreover, there was a flag insertIntoQueryElements which could be set to false, if the arg must not be inserted into the queries elements. This is the case for nested xpr, the where, having, with, groupBy and orderBy clause of the query.
  • attachRefLinksToArg does exactly what the name implies, it attaches $refLinks to an arg but does not resolve the arg to a query element. This function was used for the from clause of the query.

It is obvious that both functions have significant shared logic. This change removes the usage of the attachRefLinksToArg function.

  • stakeholder tests are all green with this branch → cap/stakeholder-tests/actions/runs/9482613
  • cds tests are all green with this branch → /cap/cds/actions/runs/9483245

@patricebender patricebender marked this pull request as draft November 25, 2024 13:03
@patricebender patricebender marked this pull request as ready for review November 27, 2024 14:35
@patricebender patricebender enabled auto-merge (squash) November 28, 2024 10:18
@patricebender patricebender merged commit 0562858 into main Nov 28, 2024
3 of 4 checks passed
@patricebender patricebender deleted the patrice/refactor-reflinks branch November 28, 2024 13:31
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.

2 participants