spring-projects / spring-projects/spring-data-relational

Support Dialect provided StatementRenderers SPI.

Open
#2,305 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.