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

Code maintenance/53379 separate filtering from projections in queries #15662

Draft
wants to merge 28 commits into
base: dev
Choose a base branch
from

Conversation

ulferts
Copy link
Contributor

@ulferts ulferts commented May 24, 2024

Refactors with the following goals:

  • separating filtering from projections in queries. That way, the selects chosen to be displayed can be made responsible for fetching additional information (e.g. by joining another table and selecting values from there) instead of doing it within the query itself or in the table component. This also allows for a more dynamic approach for fetching data. i.e. only when displaying the latest_activity_at column is that information actually computed
  • distinguishing between table components that represent a query and those that are handed in rows. With the query object containing most of the information needed (results, selects, orders) and wanting to turn the tables more dynamic, they are the perfect source for building a table based on this information. But not every table is backed by a query so we need to support both ways.

Todos

  • Attempt to separate constructed SQL query into CTEs for readability
  • Finalize separation between table types

https://community.openproject.org/wp/53379
https://community.openproject.org/wp/53315

.joins("LEFT JOIN (#{wiki_storage_sql}) wiki ON projects.id = wiki.project_id")
.joins("LEFT JOIN (#{work_package_sql}) wp ON projects.id = wp.project_id")
.joins("LEFT JOIN #{Repository.table_name} repos ON repos.project_id = projects.id")
.joins("LEFT JOIN (#{wiki_storage_sql}) wiki_size ON projects.id = wiki_size.project_id")

Check warning

Code scanning / Brakeman

Possible SQL injection. Warning

Possible SQL injection.
@ulferts ulferts force-pushed the code-maintenance/53379-separate-filtering-from-projections-in-queries branch 4 times, most recently from 84d12a2 to 5564ae5 Compare May 30, 2024 16:09
@ulferts ulferts force-pushed the code-maintenance/53379-separate-filtering-from-projections-in-queries branch 11 times, most recently from 37710f9 to bb84895 Compare July 1, 2024 08:40
@ulferts ulferts force-pushed the code-maintenance/53379-separate-filtering-from-projections-in-queries branch 3 times, most recently from 269fe6e to 10f8908 Compare July 12, 2024 10:24
@ulferts ulferts force-pushed the code-maintenance/53379-separate-filtering-from-projections-in-queries branch 3 times, most recently from d54bff0 to 9d4cf1c Compare August 16, 2024 08:30
@ulferts ulferts force-pushed the code-maintenance/53379-separate-filtering-from-projections-in-queries branch from 9d4cf1c to 64bc47e Compare August 16, 2024 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant