Class SelectSqlGenerator

java.lang.Object
org.litebridge.db.spi.impl.sql.AbstractSqlGenerator
org.litebridge.db.spi.impl.sql.SelectSqlGenerator

public class SelectSqlGenerator extends AbstractSqlGenerator
SQL generator for SELECT statements.
  • Constructor Details

    • SelectSqlGenerator

      public SelectSqlGenerator(LabelGenerator labelGenerator, MathOperationGenerator mathOperationGenerator, BiFunction<Table,ConnectionProvider,TableMetaData> ensureTableMetaData)
      Creates a new SelectSqlGenerator.
      Parameters:
      labelGenerator - the label generator for rendering aliases/identifiers
      mathOperationGenerator - the math operation generator
      ensureTableMetaData - a function to ensure table metadata
  • Method Details

    • generateSql

      public String generateSql(Select select, ConnectionProvider connectionProvider)
      Generates a SQL SELECT query string from the provided logical Select object.
      Parameters:
      select - the Select object representing the logical select query
      connectionProvider - 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

      protected String createJoin(Join join, Select operation, ConnectionProvider connectionProvider)
      Create a SQL JOIN clause based on the provided Join object.

      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 - the Join object containing the target table information and the list of conditions defining the join relationship
      operation - the select operation
      connectionProvider - the connection provider
      Returns:
      Prepared SQL join clause
    • appendLimitClause

      protected void appendLimitClause(Limit limit, StringBuilder sql)
      Appends a LIMIT clause to the SQL.
      Parameters:
      limit - the limit
      sql - the SQL string builder