spring-projects / spring-projects/spring-data-relational
Support Dialect provided StatementRenderers SPI.
Open
Nobody has claimed this yet.
status: pending-design-work
type: enhancement
- Dominant language
- Java
- Stars
- 827
- Forks
- 394
- PR merge metrics
- No merged PRs in 30d
Description
A custom Dialect should be able to contribute statement rendering capabilities to allow for more divergent rendering strategies.
SPI outline:
interface StatementRenderer<T extends Visitable, SRC extends StatementRenderContext<T>>{
Class<T> getStatementType();
String render(T statement, SRC context);
interface StatementRenderContext<T> {
}
}
interface Dialect {
// ...
@Nullable
<T extends Visitable> StatementRenderer<T, StatementRenderContext<T>> statementRenderer(Class<T> type);
}
Usage in custom implementation
public class MyDialect extends AbstractDialect {
@Override
public <T extends Visitable> StatementRenderer<T, StatementRenderContext<T>>
statementRenderer(Class<T> type) {
if (type == Upsert.class) {
return (StatementRenderer) new MyUpsertRenderer();
}
return super.statementRenderer(type);
}
}
class MyUpsertRenderer implements UpsertStatementRenderer {
@Override
public String render(Upsert statement, UpsertRenderContext context) {
// ...
}
}
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 by reading the Dialect and AbstractDialect APIs, then trace how statements are currently rendered. Compare that flow with the proposed StatementRenderer and StatementRenderContext SPI. Done means custom Dialect implementations can provide renderers for statement types such as Upsert while existing rendering remains supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100