-
Notifications
You must be signed in to change notification settings - Fork 350
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
Support for SpEL expressions containing table names in annotated queries #1863
Conversation
SpEL expressions in queries get processed in two steps: 1. First SpEL expressions outside parameters are detected and processed. This is done with a `StandardEvaluationContext` with the variables `tableName` and `qualifiedTableName` added. This step is introduced by this commit. 2. Parameters made up by SpEL expressions are processed as usual. Closes #1856 Originial pull request #1863
d0127fe
to
33786ab
Compare
SpEL expressions in queries get processed in two steps: 1. First SpEL expressions outside parameters are detected and processed. This is done with a `StandardEvaluationContext` with the variables `tableName` and `qualifiedTableName` added. This step is introduced by this commit. 2. Parameters made up by SpEL expressions are processed as usual. Closes #1856 Originial pull request #1863
33786ab
to
21a5f74
Compare
* @param queryPreprocessor must not be {@literal null}. | ||
* @since 3.4 | ||
*/ | ||
public StringBasedJdbcQuery(JdbcQueryMethod queryMethod, NamedParameterJdbcOperations operations, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With already the constructor being changed, I wonder what difference it makes handing in the processed query vs. a QueryPreprocessor
that we're going to remove from the signature anyways.
private final SqlIdentifier qualifiedTableName; | ||
private final Dialect dialect; | ||
|
||
public TableNameQueryPreprocessor(SqlIdentifier tableName, SqlIdentifier qualifiedTableName, Dialect dialect) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introducing concepts of QueryPreprocessing
exposes this utility quite prominently. I wonder whether we can avoid repeating table name extraction across JDBC and R2DBC modules and I wonder whether we could have a RelationalQueryLookupStrategy
. Looking at JdbcQueryLookupStrategy
and R2dbcQueryLookupStrategy
, these seem to have sufficient context already for that purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
I kept the TableNameQueryPreprocessor
since putting tons of String manipulation into RelationalQueryLookupStrategy
directly feels wrong.
SpEL expressions in queries get processed in two steps: 1. First SpEL expressions outside parameters are detected and processed. This is done with a `StandardEvaluationContext` with the variables `tableName` and `qualifiedTableName` added. This step is introduced by this commit. 2. Parameters made up by SpEL expressions are processed as usual. Closes #1856 Originial pull request #1863
21a5f74
to
c563c2c
Compare
SpEL expressions in queries get processed in two steps: 1. First SpEL expressions outside parameters are detected and processed. This is done with a `StandardEvaluationContext` with the variables `tableName` and `qualifiedTableName` added. This step is introduced by this commit. 2. Parameters made up by SpEL expressions are processed as usual. Closes #1856 Original pull request #1863
That's merged and polished now. |
Closes #1856