Class QueryBuilder
- java.lang.Object
-
- jetbrains.buildServer.serverSide.db.schema.QueryBuilder
-
- Direct Known Subclasses:
ConnectedQueryBuilder
public class QueryBuilder extends Object
A service class that build SQL statements according to schema definitions.
-
-
Constructor Summary
Constructors Constructor Description QueryBuilder(SQLDialect dialect)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
genCreateKey(TableKeyDef key)
Generates a statement for creating a table key or index.String[]
genCreateSchemaCompletely(SchemaDef schema, DBFunctions dbf)
Generates the complete script for creating a database.String[]
genCreateTableCompletely(TableDef table, DBFunctions dbf)
Generates statements for creating the specified table and its keys and indices.String[]
genPerSessionScript(SchemaDef schema, DBFunctions dbf)
Generates the script that should be executed each DB session started.String
genSelectionStringRepresentationOfSeveralFields(List<TableFieldDef> fields, String delimiter, DBFunctions dbf)
static String
makeDataTypeSpec(TableFieldDef field, DBFunctions dbf)
static String
makeNullability(TableFieldDef field, boolean fieldIsPrimary)
-
-
-
Constructor Detail
-
QueryBuilder
public QueryBuilder(SQLDialect dialect)
-
-
Method Detail
-
genCreateSchemaCompletely
@NotNull public final String[] genCreateSchemaCompletely(@NotNull SchemaDef schema, @NotNull DBFunctions dbf)
Generates the complete script for creating a database. When generating tries to inline keys if the current RDBMS does support it. Includes temporary tables if they are permanent (seeSQLDialect.isRequireToRecreateTemporaryTablesEachSession()
).- Parameters:
schema
- schema to generate.dbf
- the database connection.- Returns:
- script.
- See Also:
ConnectedQueryBuilder.genCreateSchemaCompletely(SchemaDef)
-
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)
-
makeDataTypeSpec
@NotNull public static String makeDataTypeSpec(@NotNull TableFieldDef field, @NotNull DBFunctions dbf)
-
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)
-
-