Class QueryBuilder

  • Direct Known Subclasses:
    ConnectedQueryBuilder

    public class QueryBuilder
    extends Object
    A service class that build SQL statements according to schema definitions.
    • Constructor Detail

      • QueryBuilder

        public QueryBuilder​(SQLDialect dialect)
    • Method Detail

      • genPerSessionScript

        @NotNull
        public final String[] genPerSessionScript​(@NotNull
                                                  SchemaDef schema,
                                                  @NotNull
                                                  DBFunctions dbf)
        Generates the script that should be executed each DB session started. Currently, this script contains temporary tables only if the current RDBMS requires to regenerate them each session.
        Parameters:
        schema - schema.
        dbf - the database connection.
        Returns:
        script.
        See Also:
        ConnectedQueryBuilder.genPerSessionScript(SchemaDef)
      • genCreateTableCompletely

        @NotNull
        public final String[] genCreateTableCompletely​(@NotNull
                                                       TableDef table,
                                                       @NotNull
                                                       DBFunctions dbf)
        Generates statements for creating the specified table and its keys and indices.
        Parameters:
        table - table definition.
        dbf - the database connection.
        Returns:
        SQL statements.
        See Also:
        genCreateTable(TableDef, boolean, boolean, String, DBFunctions), genCreateTableKeys(jetbrains.buildServer.serverSide.db.schema.TableDef, boolean), ConnectedQueryBuilder.genCreateTableCompletely(TableDef)
      • makeNullability

        @NotNull
        public static String makeNullability​(@NotNull
                                             TableFieldDef field,
                                             boolean fieldIsPrimary)
      • genCreateKey

        @NotNull
        public final String genCreateKey​(TableKeyDef key)
        Generates a statement for creating a table key or index.
        Parameters:
        key - key the statement create for.
        Returns:
        creation DDL statement.
      • genSelectionStringRepresentationOfSeveralFields

        public final String genSelectionStringRepresentationOfSeveralFields​(@NotNull
                                                                            List<TableFieldDef> fields,
                                                                            @NotNull
                                                                            String delimiter,
                                                                            @NotNull
                                                                            DBFunctions dbf)