java.lang.Object
org.litebridge.db.spi.impl.sql.AbstractSqlGenerator
org.litebridge.db.spi.impl.sql.SelectSqlGenerator
SQL generator for SELECT statements.
-
Field Summary
Fields inherited from class org.litebridge.db.spi.impl.sql.AbstractSqlGenerator
labelGenerator, mathOperationGenerator -
Constructor Summary
ConstructorsConstructorDescriptionSelectSqlGenerator(LabelGenerator labelGenerator, MathOperationGenerator mathOperationGenerator, BiFunction<Table, ConnectionProvider, TableMetaData> ensureTableMetaData) Creates a newSelectSqlGenerator. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendFromClause(StringBuilder sql, Select select, ConnectionProvider connectionProvider) protected voidappendLimitClause(Limit limit, StringBuilder sql) Appends a LIMIT clause to the SQL.protected voidappendSelectTarget(StringBuilder sql, SelectTarget selectTarget, ConnectionProvider connectionProvider) protected StringcreateJoin(Join join, Select operation, ConnectionProvider connectionProvider) Create a SQL JOIN clause based on the providedJoinobject.generateSql(Select select, ConnectionProvider connectionProvider) Generates a SQLSELECTquery string from the provided logicalSelectobject.Methods inherited from class org.litebridge.db.spi.impl.sql.AbstractSqlGenerator
appendConditionsAndSubgroups, appendTable, appendValues, createCondition, createMathOperation, ensureColumnMetaData, getColumnValueFragment, mapOperator
-
Constructor Details
-
SelectSqlGenerator
public SelectSqlGenerator(LabelGenerator labelGenerator, MathOperationGenerator mathOperationGenerator, BiFunction<Table, ConnectionProvider, TableMetaData> ensureTableMetaData) Creates a newSelectSqlGenerator.- Parameters:
labelGenerator- the label generator for rendering aliases/identifiersmathOperationGenerator- the math operation generatorensureTableMetaData- a function to ensure table metadata
-
-
Method Details
-
generateSql
Generates a SQLSELECTquery string from the provided logicalSelectobject.- Parameters:
select- theSelectobject representing the logical select queryconnectionProvider- the connection provider- Returns:
- the generated SQL query string
-
appendFromClause
protected void appendFromClause(StringBuilder sql, Select select, ConnectionProvider connectionProvider) -
appendSelectTarget
protected void appendSelectTarget(StringBuilder sql, SelectTarget selectTarget, ConnectionProvider connectionProvider) -
createJoin
Create a SQL JOIN clause based on the providedJoinobject.The join clause is constructed by specifying the target table, optional schema, and any associated conditions for the join operation. Conditional logic is applied to determine the join type (e.g., ON or USING) and format the resulting SQL string.
- Parameters:
join- theJoinobject containing the target table information and the list of conditions defining the join relationshipoperation- the select operationconnectionProvider- the connection provider- Returns:
- Prepared SQL join clause
-
appendLimitClause
Appends a LIMIT clause to the SQL.- Parameters:
limit- the limitsql- the SQL string builder
-