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

Augment queries - add an additional filter #669

Open
d0ivanov opened this issue Oct 18, 2021 · 4 comments
Open

Augment queries - add an additional filter #669

d0ivanov opened this issue Oct 18, 2021 · 4 comments
Labels
status: pending-design-work Needs design work before any code can be developed type: enhancement A general enhancement

Comments

@d0ivanov
Copy link

The application I'm working on is multi-tenant. The approach to tenant data isolation that all tables get an additional "tenant id" column. This results in pretty much every query having a WHERE clause like "...AND tenant_id = ".
I've been evaluating the possibility of customizing query creation and processing so that this additional clause gets appended "automagically" based on the current security context.
So far I've found this issue in Spring Data JPA, but it doesn't seem like there's any active development on it.
So I was wondering what would be your advice on the best approach right now to appending an additional filter to every query.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 18, 2021
@schauder schauder added type: enhancement A general enhancement status: pending-design-work Needs design work before any code can be developed and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 18, 2021
@mp911de
Copy link
Member

mp911de commented Oct 18, 2021

Thanks for bringing this up. Query augmentation spans a large surface as that is something to consider for derived queries as well. We first need a proper design before we can proceed in any direction. Right now we don't have much bandwidth for that issue.

@d0ivanov
Copy link
Author

I see, thank you for your response!
Granted it would be more of a patch - would you be willing to accept a change to make R2dbcQueryCreator a public class and also add a protected method in PartTreeR2dbcQuery which provides R2dbcQueryCreator instances ?

@mp911de
Copy link
Member

mp911de commented Oct 19, 2021

R2dbcQueryCreator and friends are protected as we do not want to leak implementation details outside of that package. Making things public leads to usage and subclassing and that removes the ability on our side to update implementation details without breaking application code.

@jwmaher
Copy link

jwmaher commented Jan 16, 2023

@mp911de With the current feature set how would you recommend this be accomplished? I have a similar requirement where i would like to inspect each query before it is executed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: pending-design-work Needs design work before any code can be developed type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants