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

[Feature Request]: BeforeExecute, AfterExecute hook support #475

Open
kcmvp opened this issue Apr 19, 2022 · 2 comments
Open

[Feature Request]: BeforeExecute, AfterExecute hook support #475

kcmvp opened this issue Apr 19, 2022 · 2 comments

Comments

@kcmvp
Copy link

kcmvp commented Apr 19, 2022

Firstly thank you very much to build such useful framework. I am using it in my project. I have a use case for data privilege, for the same statement different user role would take different data privilege strategies. eg:

select a, b, c from ta

if current use a normal user then the return result of column c should be maksed as "xxxx", in our project (sass, multi-tenancy), there are many cases.

if the framework supports hooks, then we can handle the logic in one place. right now we mix such logic every where. it's not a good practice.

thank you!

@jeffgbutler
Copy link
Member

I'm going to add hooks to the library that will allow you to modify the generated SQL. I'm not sure that's what you are asking about however.

This library does not execute SQL - we defer that to either MyBatis or Spring. So if you need execution hooks, you will need to do it in those libraries. In MyBatis that would probably mean writing a plugin or interceptor - you can read about MyBatis plugins on this page: https://mybatis.org/mybatis-3/configuration.html

@kcmvp
Copy link
Author

kcmvp commented Apr 20, 2022

I'm going to add hooks to the library that will allow you to modify the generated SQL. I'm not sure that's what you are asking about however.

This library does not execute SQL - we defer that to either MyBatis or Spring. So if you need execution hooks, you will need to do it in those libraries. In MyBatis that would probably mean writing a plugin or interceptor - you can read about MyBatis plugins on this page: https://mybatis.org/mybatis-3/configuration.html

yeath, that what I wanted for BeforeHook. , back to AfterHook (my case) is to modify the result.(eg encrypt).

in order to control the BeforeHook and AfterHook precisely, there should be a context I can pass a flag/variable in it. for example If set a variable/flag in context in BeforeHook for a sql, in the following AfterHook I can tell that's the very sql I am caring about by checking(and using) the flag/variable (eg, using it to encrypt the value)

generally speaking: our use case can fall into two categories

1: simply using BeforeHook to modify the sql
2: Using BeforeHook and AfterHook together to modify the returned the result.

Thank you quick reply very much!

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

No branches or pull requests

2 participants