spring-projects / spring-projects/spring-framework
Allow NamedParameterJdbcTemplate to optionally include parameters in comments of SQL
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
NamedParameterJdbcTemplate skips parameters in comments by the logic in NamedParameterUtils.parseSqlStatement(String sql)
...
int skipToPosition = i;
while (i < statement.length) {
skipToPosition = skipCommentsAndQuotes(statement, i);
if (i == skipToPosition) {
break;
}
else {
i = skipToPosition;
}
}
...
I use NamedParameterJdbcTemplate to run SQLs on our own DBMS engine in the company.
I have special cases to use parameters in comment, for example, "/*@ queryCkey(:cafeId) */ SELECT ... ",
If it is allowed in NamedParameterJdbcTemplate, it will be very helpful for our system.
( For your information, MyBatis allows parameters in comments of SQL)
I'd like you to consider adding an optional flag to support this.
var template = new NamedParameterJdbcTemplate(dataSource);
template.setAllowParametersInComments(true);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with NamedParameterUtils.parseSqlStatement(String sql) and the comment-skipping logic shown in the issue, then trace how NamedParameterJdbcTemplate exposes configuration. Done means an optional setting allows parameters in SQL comments while preserving the current default behavior; the payload does not name a test file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100