Class SQLDialect

    • Field Detail

      • LOG_LEVEL

        @NonNull
        public static @NonNull Level LOG_LEVEL
        Controls the log level for previewing generated SQL
    • Constructor Detail

      • SQLDialect

        public SQLDialect()
    • Method Detail

      • escape

        public static String escape​(@NonNull
                                    @NonNull String string)
        Static helper method for properly escaping SQL strings.
        Parameters:
        string - the string to escape
        Returns:
        the escaped string
      • addColumn

        protected String addColumn​(AlterTableAction.AddColumn alterColumn)
        Add column string.
        Parameters:
        alterColumn - the alter column
        Returns:
        the string
      • alterColumn

        protected String alterColumn​(AlterTableAction.AlterColumn alterColumn)
        Alter column string.
        Parameters:
        alterColumn - the alter column
        Returns:
        the string
      • alterTable

        protected String alterTable​(AlterTable alterTable)
        Alter table string.
        Parameters:
        alterTable - the alter table
        Returns:
        the string
      • between

        protected String between​(Between between)
        Between string.
        Parameters:
        between - the between
        Returns:
        the string
      • binaryOperator

        protected String binaryOperator​(@NonNull
                                        @NonNull InfixBinaryOperator binaryOperator)
        Binary operator string.
        Parameters:
        binaryOperator - the binary operator
        Returns:
        the string
      • checkConstraint

        protected void checkConstraint​(CheckConstraint checkConstraint,
                                       boolean isTableConstraint,
                                       StringBuilder builder)
        Check constraint.
        Parameters:
        checkConstraint - the check constraint
        isTableConstraint - the is table constraint
        builder - the builder
      • cleanUnderScores

        protected String cleanUnderScores​(String str)
        Clean under scores string.
        Parameters:
        str - the str
        Returns:
        the string
      • conflictClause

        protected String conflictClause​(ConflictClause conflictClause)
        Generates the SQL for defining what happens on conflict
        Parameters:
        conflictClause - the conflict clause
        Returns:
        the SQL
      • createIndex

        protected String createIndex​(Create createStatement)
        Create index string.
        Parameters:
        createStatement - the create statement
        Returns:
        the string
      • createTable

        protected String createTable​(Create statement)
        Create table string.
        Parameters:
        statement - the statement
        Returns:
        the string
      • createTrigger

        protected String createTrigger​(Create createStatement)
        Create trigger string.
        Parameters:
        createStatement - the create statement
        Returns:
        the string
      • deferrable

        public String deferrable​(Deferrable deferrable)
        Deferrable string.
        Parameters:
        deferrable - the deferrable
        Returns:
        the string
      • defineColumn

        protected abstract void defineColumn​(Column column,
                                             StringBuilder builder)
        Generates the SQL needed to define a column for creating or altering a table.
        Parameters:
        column - the column definition
        builder - the StringBuilder to add the definition to
      • defineConstraint

        protected final void defineConstraint​(Constraint constraint,
                                              boolean isTableConstraint,
                                              StringBuilder builder)
        Define constraint.
        Parameters:
        constraint - the constraint
        isTableConstraint - the is table constraint
        builder - the builder
      • delete

        protected String delete​(Delete delete)
        Generates the SQL to delete from a table.
        Parameters:
        delete - the delete object
        Returns:
        the SQL
      • drop

        protected String drop​(Drop drop)
        Generates the SQL to drop an object
        Parameters:
        drop - the drop object
        Returns:
        the SQL
      • dropColumn

        protected String dropColumn​(AlterTableAction.DropColumn dropColumn)
        Drop column string.
        Parameters:
        dropColumn - the drop column
        Returns:
        the string
      • foreignKeyAction

        public String foreignKeyAction​(ForeignKeyAction action)
        Foreign key action string.
        Parameters:
        action - the action
        Returns:
        the string
      • foreignKeyConstraint

        protected void foreignKeyConstraint​(ForeignKeyConstraint fkc,
                                            boolean isTableConstraint,
                                            StringBuilder builder)
        Foreign key constraint.
        Parameters:
        fkc - the fkc
        isTableConstraint - the is table constraint
        builder - the builder
      • function

        protected String function​(@NonNull
                                  @NonNull SQLFunction function)
        Generates the SQL for a call to a predefined function.
        Parameters:
        function - the function call
        Returns:
        the SQL
      • insert

        protected String insert​(Insert insert)
        Generates the SQL to insert a row into a table
        Parameters:
        insert - the insert object
        Returns:
        the SQL
      • insertType

        protected String insertType​(InsertType insertType)
        Insert type string.
        Parameters:
        insertType - the insert type
        Returns:
        the string
      • join

        protected String join​(@NonNull
                              @NonNull String delimiter,
                              @NonNull
                              @NonNull Collection<? extends SQLElement> items)
        Joins one or more SQLElement as SQL with the given delimiter
        Parameters:
        delimiter - the delimiter to use to separate the SQLElements
        items - the items to join
        Returns:
        the SQL
      • join

        protected String join​(@NonNull
                              @NonNull Join join)
        Generates the SQL defining a join operation
        Parameters:
        join - the join
        Returns:
        the SQL
      • joinType

        protected String joinType​(JoinType joinType)
        Join type string.
        Parameters:
        joinType - the join type
        Returns:
        the string
      • notNullConstraint

        protected void notNullConstraint​(NotNullConstraint notNullConstraint,
                                         boolean isTableConstraint,
                                         StringBuilder builder)
        Not null constraint.
        Parameters:
        notNullConstraint - the not null constraint
        isTableConstraint - the is table constraint
        builder - the builder
      • postfixUnaryOperator

        protected String postfixUnaryOperator​(@NonNull
                                              @NonNull PostfixUnaryOperator op)
        Postfix unary operator string.
        Parameters:
        op - the op
        Returns:
        the string
      • prefixUnaryOperator

        protected String prefixUnaryOperator​(@NonNull
                                             @NonNull PrefixUnaryOperator op)
        Prefix unary operator string.
        Parameters:
        op - the op
        Returns:
        the string
      • primaryKeyConstraint

        protected void primaryKeyConstraint​(PrimaryKeyConstraint primaryKeyConstraint,
                                            boolean isTableConstraint,
                                            StringBuilder builder)
        Primary key constraint.
        Parameters:
        primaryKeyConstraint - the primary key constraint
        isTableConstraint - the is table constraint
        builder - the builder
      • queryOperator

        protected String queryOperator​(QueryOperator queryOperator)
        Generates the SQL for defining a query operator (UNION, EXCLUDE, etc.)
        Parameters:
        queryOperator - the query operator
        Returns:
        the SQL
      • renameColumn

        protected String renameColumn​(AlterTableAction.RenameColumn renameColumn)
        Rename column string.
        Parameters:
        renameColumn - the rename column
        Returns:
        the string
      • renameTable

        protected String renameTable​(AlterTableAction.RenameTable renameTable)
        Rename table string.
        Parameters:
        renameTable - the rename table
        Returns:
        the string
      • render

        public final String render​(@NonNull
                                   @NonNull SQLElement sqlElement)
        Render string.
        Parameters:
        sqlElement - the sql element
        Returns:
        the string
      • select

        protected String select​(@NonNull
                                @NonNull Select select)
        Generates the SQL for select statement
        Parameters:
        select - the select statement
        Returns:
        the SQL
      • sqlDMLOperation

        protected String sqlDMLOperation​(SQLDMLOperation operation)
        Sql dml operation string.
        Parameters:
        operation - the operation
        Returns:
        the string
      • translate

        protected String translate​(String keyword)
        Provides dialect specific translations of keywords and symbols
        Parameters:
        keyword - the keyword
        Returns:
        the tranlsation
      • triggerTime

        protected String triggerTime​(TriggerTime triggerTime)
        Trigger time string.
        Parameters:
        triggerTime - the trigger time
        Returns:
        the string
      • uniqueConstraint

        protected void uniqueConstraint​(UniqueConstraint uniqueConstraint,
                                        boolean isTableConstraint,
                                        StringBuilder builder)
        Unique constraint.
        Parameters:
        uniqueConstraint - the unique constraint
        isTableConstraint - the is table constraint
        builder - the builder
      • update

        protected String update​(Update update)
        Generates the SQL For an update statement
        Parameters:
        update - the update statement
        Returns:
        the SQL
      • updateType

        protected String updateType​(UpdateType updateType)
        Update type string.
        Parameters:
        updateType - the update type
        Returns:
        the string
      • upsertAction

        protected String upsertAction​(UpsertAction upsertAction)
        Upsert action string.
        Parameters:
        upsertAction - the upsert action
        Returns:
        the string
      • upsertClause

        protected String upsertClause​(@NonNull
                                      @NonNull UpsertClause upsertClause)
        Generates the SQL for an upsert clause
        Parameters:
        upsertClause - the upser object
        Returns:
        the SQL