name stringlengths 12 178 | code_snippet stringlengths 8 36.5k | score float64 3.26 3.68 |
|---|---|---|
morf_SqlDialect_hasColumnNamed_rdh | /**
* Checks the schema to see if the {@code tableName} has a named column as
* provided.
*
* @param tableName
* the table name.
* @param metadata
* the schema.
* @param columnName
* the column name to check for.
* @return true if a column with the name 'id' is found.
*/
private boolean hasColumnNamed(... | 3.26 |
morf_SqlDialect_decorateTemporaryTableName_rdh | /**
* Decorate the table name in an appropriate manner for temporary table in the
* relevant database.
*
* @param undecoratedName
* core name.
* @return decorated version.
*/
public String decorateTemporaryTableName(String undecoratedName) {
return undecoratedName;
} | 3.26 |
morf_SqlDialect_getSchemaName_rdh | /**
* Returns the database schema name. May be null.
*
* @return The schema name
*/
public String getSchemaName() {return f0;
} | 3.26 |
morf_SqlDialect_tableNameWithSchemaName_rdh | /**
*
* @param tableRef
* The table for which the schema name will be retrieved
* @return full table name that includes a schema name and DB-link if present
*/protected String tableNameWithSchemaName(TableReference tableRef) {
if (StringUtils.isEmpty(tableRef.getSchemaName())) {
return schemaName... | 3.26 |
morf_SqlDialect_copyInsertStatement_rdh | /**
* Copies an insert statement to a duplicate instance.
*
* @param statement
* the {@linkplain InsertStatement} to copy
* @return a new instance of the {@linkplain InsertStatement}
*/
protected InsertStatement copyInsertStatement(InsertStatement statement) {
return
statement.shallowCopy().build();
} | 3.26 |
morf_SqlDialect_requiresOrderByForWindowFunction_rdh | /**
* Windowing function usually have the following syntax
* <b>FUNCTION</b> OVER (<b>partitionClause</b> <b>orderByClause</b>)
* The partitionClause is generally optional, but the orderByClause is mandatory for certain functions. This method
* specifies for which function the orderByClause is mandatory.
* Certain... | 3.26 |
morf_SqlDialect_getExistingMaxAutoNumberValue_rdh | /**
* Builds SQL to get the maximum value of the specified column on the
* specified {@code dataTable}.
*
* @param dataTable
* the table to query over.
* @param fieldName
* Name of the field to query over for the max value.
* @return SQL getting the maximum value from the {@code dataTable}.
*/
protected St... | 3.26 |
morf_SqlDialect_getSqlForLeftTrim_rdh | /**
* Converts the LEFT_TRIM function into SQL.
*
* @param function
* the function to convert.
* @return a string representation of the SQL.
*/
protected String getSqlForLeftTrim(Function function) {
return ("LTRIM(" + getSqlFrom(function.getArguments().get(0))) + ")";
} | 3.26 |
morf_SqlDialect_checkSelectStatementHasNoHints_rdh | /**
* Throws {@link IllegalArgumentException} if the select statement has hints.
*
* @param statement
* The select statement.
* @param errorMessage
* The message for the exception.
*/
protected void checkSelectStatementHasNoHints(SelectStatement statement, String errorMessage) {
if (!statement.getHints().isE... | 3.26 |
morf_SqlDialect_getSqlForUpper_rdh | /**
* Converts the <code>UPPER</code> function into SQL.
*
* @param function
* the function to convert.
* @return a string representation of the SQL.
*/
protected String getSqlForUpper(Function function) {
return ("UPPER(" + getSqlFrom(function.getArguments().get(0))) + ")";
} | 3.26 |
morf_SqlDialect_getAutoIncrementColumnForTable_rdh | /**
* Scans the specified {@link Table} for any autonumbered columns and returns
* that {@link Column} if it is found, or null otherwise.
*
* @param table
* The table to check.
* @return The autonumber column, or null if none exists.
*/
protected Column getAutoIncrementColumnForTable(Table table) {
for (Column... | 3.26 |
morf_SqlDialect_getSqlForWindowFunction_rdh | /**
* Generates standards compliant SQL from the function within a window function
*
* @param function
* The field to convert
* @return The resulting SQL
*/
protected String getSqlForWindowFunction(Function function) {
return getSqlFrom(function);
} | 3.26 |
morf_SqlDialect_appendJoins_rdh | /**
* appends joins clauses to the result
*
* @param result
* joins will be appended here
* @param stmt
* statement with joins clauses
* @param innerJoinKeyword
* The keyword for INNER JOIN
* @param <T>
* The type of {@link AbstractSelectStatement}
*/
protected <T extends AbstractSelectStatement<T>> ... | 3.26 |
morf_SqlDialect_viewDeploymentStatements_rdh | /**
* Creates SQL to deploy a database view.
*
* @param view
* The meta data for the view to deploy.
* @return The statements required to deploy the view.
*/
public Collection<String> viewDeploymentStatements(View view) {
List<String> statements = new ArrayList<>();
// Create the table deployment statem... | 3.26 |
morf_SqlDialect_getSqlForInsertInto_rdh | /**
* Returns the INSERT INTO statement.
*
* @param insertStatement
* he {@linkplain InsertStatement} object which can be used by the overriding methods to customize the INSERT statement.
* @return the INSERT INTO statement.
*/
protected String getSqlForInsertInto(@SuppressWarnings("unused")
InsertStatement
ins... | 3.26 |
morf_SqlDialect_getSqlForLower_rdh | /**
* Converts the <code>LOWER</code> function into SQL.
*
* @param function
* the function to convert.
* @return a string representation of the SQL.
*/
protected String getSqlForLower(Function function)
{
return ("LOWER(" + getSqlFrom(function.getArguments().get(0))) + ")";
} | 3.26 |
morf_SqlDialect_expandInnerSelectFields_rdh | /**
* Creates the fields from any inner selects on the outer select.
*
* @param statement
* the select statement to expand.
*/
private void expandInnerSelectFields(SelectStatement statement) {
if (((statement == null) || (!statement.getFields().isEmpty())) || statement.getFromSel... | 3.26 |
morf_SqlDialect_oldTableForChangeColumn_rdh | /**
* Construct the old table for a change column
*
* @param table
* The table to change
* @param oldColumn
* The old column
* @param newColumn
* The new column
* @return The 'old' table
*/
protected Table oldTableForChangeColumn(Table table, Column oldColumn, Column newColumn) {
return new ChangeColu... | 3.26 |
morf_SqlDialect_prepareBooleanParameter_rdh | /**
* Overridable behaviour for mapping a boolean parameter to a prepared statement.
*
* @param statement
* The statement.
* @param boolVal
* The boolean value.
* @param parameter
* The parameter to map to.
* @throws SQLException
* If an exception occurs setting the parameter.
*/
protected void prepa... | 3.26 |
morf_SqlDialect_getSqlForSum_rdh | /**
* Converts the sum function into SQL.
*
* @param function
* the function details
* @return a string representation of the SQL
*/
protected String getSqlForSum(Function function) {
return ("SUM(" + getSqlFrom(function.getArguments().get(0))) + ")";
} | 3.26 |
morf_SqlDialect_getColumnRepresentation_rdh | /**
* Gets the column representation for the datatype, etc.
*
* @param dataType
* the column datatype.
* @param width
* the column width.
* @param scale
* the column scale.
* @return a string representation of the column definition.
*/
protected String getColumnRepresentation(DataType dataType, int widt... | 3.26 |
morf_SqlDialect_getSqlFrom_rdh | /**
* Convert a {@link WindowFunction} into standards compliant SQL.
*
* @param windowFunctionField
* The field to convert
* @return The resulting SQL
*/
protected String getSqlFrom(WindowFunction windowFunctionField) {if (requiresOrderByForWindowFunction(windowFunctionField.getFunction()) && windowFunctionFiel... | 3.26 |
morf_SqlDialect_getSqlForAverage_rdh | /**
* Converts the average function into SQL.
*
* @param function
* the function details
* @return a string representation of the SQL
*/
protected String getSqlForAverage(Function function) {
return
("AVG(" + getSqlFrom(function.getArguments().get(0))) + ")";
} | 3.26 |
morf_SqlDialect_dropTables_rdh | /**
* Creates SQL to drop the named tables.
*
* @param ifExists
* Should check if table exists before dropping
* @param cascade
* If supported by the dialect, will drop tables/views that depend on any of the provided tables
* @param tables
* The tables to drop
* @return The SQL statements as strings.
*/... | 3.26 |
morf_SqlDialect_getSqlForRowNumber_rdh | /**
* Produce SQL for getting the row number of the row in the partition
*
* @return a string representation of the SQL for finding the last day of the month.
*/
protected String getSqlForRowNumber() {
return "ROW_NUMBER()";
} | 3.26 |
morf_SqlDialect_appendExceptSet_rdh | /**
* appends except set operators to the result
*
* @param result
* except set operators will be appended here
* @param stmt
* statement with set operators
*/
protected void appendExceptSet(StringBuilder result, SelectStatement stmt)
{
if (stmt.getSetOperators() != null) {
for (SetOperator opera... | 3.26 |
morf_SqlDialect_indexDeploymentStatements_rdh | /**
* Generate the SQL to deploy an index on a table.
*
* @param table
* The table to deploy the index on.
* @param index
* The index to deploy on the table.
* @return The SQL to deploy the index on the table.
*/
protected Collection<String> indexDeploymentStatements(Table table, Index index) {
StringBuilde... | 3.26 |
morf_SqlDialect_getUpdateStatementSetFieldSql_rdh | /**
* Returns the SET clause for an SQL UPDATE statement based on the
* {@link List} of {@link AliasedField}s provided.
*
* @param fields
* The {@link List} of {@link AliasedField}s to create the SET
* statement from
* @return The SET clause as a string
*/
protected String getUpdateStatementSetFieldSql(List... | 3.26 |
morf_SqlDialect_getSqlForAnalyseTable_rdh | /**
* Generate the SQL to run analysis on a table.
*
* @param table
* The table to run the analysis on.
* @return The SQL statements to analyse the table.
*/
public Collection<String> getSqlForAnalyseTable(@SuppressWarnings("unused")
Table table) {
return SqlDialect.NO_STATEMENTS;
} | 3.26 |
morf_SqlDialect_renameIndexStatements_rdh | /**
* Creates SQL to rename an index.
*
* @param table
* table on which the index exists
* @param fromIndexName
* The index to rename
* @param toIndexName
* The new index name
* @return SQL Statements required to rename an index
*/
public Collection<String> renameIndexStatements(Table table, String from... | 3.26 |
morf_SqlDialect_getSqlForCount_rdh | /**
* Converts the count function into SQL.
*
* @param function
* the function details
* @return a string representation of the SQL
*/
protected String getSqlForCount(Function function) {
return ("COUNT(" + getSqlFrom(function.getArguments().get(0))) + ")";
} | 3.26 |
morf_SqlDialect_getSqlForRandom_rdh | /**
* Converts the RANDOM function into SQL. This returns a random number between 0 and 1.
*
* @return a string representation of the SQL.
*/
protected String getSqlForRandom() {
return "RAND()";
} | 3.26 |
morf_SqlDialect_selectStatementPostStatementDirectives_rdh | /**
* Returns any SQL code which should be added at the end of a statement for dialect-specific reasons.
*
* @param selectStatement
* The select statement
* @return Any hint code required.
*/
protected String selectStatementPostStatementDirectives(@SuppressWarnings("unused")
SelectStatement selectStatement) {
... | 3.26 |
morf_SqlDialect_getCoalesceFunctionName_rdh | /**
*
* @return The name of the coalesce function
*/
protected String getCoalesceFunctionName() {
return "COALESCE";
} | 3.26 |
morf_SqlDialect_getSubstringFunctionName_rdh | /**
* Gets the function name required to perform a substring command.
* <p>
* The default is provided here and should be overridden in child classes as
* neccessary.
* </p>
*
* @return The substring function name.
*/
protected String getSubstringFunctionName() {
return "SUBSTRING";
} | 3.26 |
morf_SqlDialect_getSqlForLeftPad_rdh | /**
* Converts the LEFT_PAD function into SQL. This is the same format used for
* H2, MySQL and Oracle. SqlServer implementation overrides this function.
*
* @param field
* The field to pad
* @param length
* The length of the padding
* @param character
* The character to use for the padding
* @return st... | 3.26 |
morf_SqlDialect_buildSimpleAutonumberUpdate_rdh | /**
* Builds a simple repair script for AutoNumbers that deletes and inserts a
* value.
*
* @param dataTable
* the table to update for.
* @param generatedFieldName
* Name of the field which has a generated value to
* build an update statement for.
* @param autoNumberTable
* the table to insert the aut... | 3.26 |
morf_SqlDialect_getSqlForMax_rdh | /**
* Converts the max function into SQL.
*
* @param function
* the function details
* @return a string representation of the SQL
*/
protected String getSqlForMax(Function function) {
return ("MAX(" + getSqlFrom(function.getArguments().get(0))) + ")";
} | 3.26 |
morf_SqlDialect_getDeleteLimitPreFromClause_rdh | /**
* Returns the SQL that specifies the deletion limit ahead of the FROM clause, if any, for the dialect.
*
* @param limit
* The delete limit.
* @return The SQL fragment.
*/
protected Optional<String> getDeleteLimitPreFromClause(@SuppressWarnings("unused")
int limit) {
return Optional.empty();
} | 3.26 |
morf_SqlDialect_getSqlForEvery_rdh | /**
* Converts the every function into SQL.
*
* @param function
* the function details
* @return a string representation of the SQL
*/
protected String getSqlForEvery(Function function) {
return getSqlForMin(function);
} | 3.26 |
morf_SqlDialect_md5HashHexEncoded_rdh | /**
*
* @param toHash
* the String to convert
* @return the md5 hash of the string.
*/@SuppressWarnings("deprecation")
private String md5HashHexEncoded(String toHash) {
try {
return CharSource.wrap(toHash).asByteSource(StandardCharsets.UTF_8).hash(Hashing.md5()).toString();
}
catch (IOException
e) {
throw new Ru... | 3.26 |
morf_SqlDialect_sqlIsComment_rdh | /**
*
* @param sql
* The SQL to test
* @return true if the sql provided is a comment
*/
public boolean sqlIsComment(String sql) {
return sql.startsWith("--") && (!sql.contains("\n"));// multi-line statements may have comments as the top line
}
/**
* Given an ordered list of columns and a {@link ResultSet}, cr... | 3.26 |
morf_SqlDialect_updateStatementPreTableDirectives_rdh | /**
* Returns any SQL code which should be added between a <code>UPDATE</code> and the table
* for dialect-specific reasons.
*
* @param updateStatement
* The update statement
* @return Any hint code required.
*/
protected String updateStatementPreTableDirectives(@SuppressWarnings("unused")
UpdateStatement upda... | 3.26 |
morf_SqlDialect_escapeSql_rdh | /**
* Turn a string value into an SQL string literal which has that value.
* This escapes single quotes as double-single quotes.
*
* @param literalValue
* the value to escape
* @return escaped value
*/
protected String escapeSql(String literalValue) {
if (literalValue == null) {
return null;
}
return StringUti... | 3.26 |
morf_SqlDialect_getMergeStatementUpdateExpressions_rdh | /**
* Extracts updating expressions from the given merge statement and returns them as aliased fields,
* similarly to how update expressions are provided to the update statement. Since updating expressions
* are optional in merge statements, uses default expressions for any missing destination fields.
*
* @param s... | 3.26 |
morf_SqlDialect_prepareIntegerParameter_rdh | /**
* Overridable behaviour for mapping an integer parameter to a prepared statement.
*
* @param statement
* The statement.
* @param integerVal
* The integer value.
* @param parameter
* The parameter to map to.
* @throws SQLException
* If an exception occurs setting the parameter.
*/
protected void p... | 3.26 |
morf_SqlDialect_extractParameters_rdh | /**
* Extracts the parameters from a SQL statement.
*
* @param statement
* the SQL statement.
* @return the list of parameters.
*/
public List<SqlParameter> extractParameters(DeleteStatement statement) {
SqlParameterExtractor extractor = new SqlParameterExtractor();
ObjectTreeTraverser.forCallback(extractor).di... | 3.26 |
morf_SqlDialect_getSqlForCriterionValue_rdh | /**
* Convert the an Object criterion value (i.e. right hand side) to valid SQL
* based on its type.
*
* @param value
* the object to convert to a string
* @return a string representation of the object
*/
protected String getSqlForCriterionValue(Object value) {
if (value instanceof String) {
return getSqlFrom... | 3.26 |
morf_SqlDialect_getLeastFunctionName_rdh | /**
*
* @return The name of the LEAST function
*/
protected String getLeastFunctionName() {
return "LEAST";
} | 3.26 |
morf_SqlDialect_getSqlForCriterionValueList_rdh | /**
* Converts a list of values on a criterion into a comma-separated list.
*
* @param criterion
* The criterion to convert
* @return The converted criterion as a String
*/
@SuppressWarnings("unchecked")
protected String getSqlForCriterionValueList(Criterion criterion) {
if (!(criterion.getValue() instanceo... | 3.26 |
morf_SqlDialect_viewDeploymentStatementsAsLiteral_rdh | /**
* Creates SQL script to deploy a database view.
*
* @param view
* The meta data for the view to deploy.
* @return The statements required to deploy the view joined into a script and prepared as literals.
*/
public AliasedField viewDeploymentStatementsAsLiteral(View view) {
return SqlUtils.clobLiteral(vi... | 3.26 |
morf_SqlDialect_defaultNullOrder_rdh | /**
* A database platform may need to specify the null order.
* <p>
* If a null order is not required for a SQL dialect descendant classes need
* to implement this method.
* </p>
*
* @return the null order for an SQL dialect
*/
protected String defaultNullOrder() {
return StringUtils.EMPTY;
} | 3.26 |
morf_SqlDialect_getSqlForMod_rdh | /**
* Converts the mod function into SQL.
*
* @param function
* the function to convert.
* @return a string representation of the SQL.
*/
protected String getSqlForMod(Function function) {
return String.format("MOD(%s, %s)", getSqlFrom(function.getArguments().get(0)), getSqlFrom(function.getArguments().get(1)))... | 3.26 |
morf_SqlDialect_getSqlForRightTrim_rdh | /**
* Converts the RIGHT_TRIM function into SQL.
*
* @param function
* the function to convert.
* @return a string representation of the SQL.
*/
protected String getSqlForRightTrim(Function function) {
return ("RTRIM(" + getSqlFrom(function.getArguments().get(0))) + ")";
} | 3.26 |
morf_SqlDialect_formatSqlStatement_rdh | /**
* Formats the SQL statement provided.
*
* @param sqlStatement
* The statement to format
* @return the formatted SQL statement
*/
public String formatSqlStatement(String sqlStatement) {
return sqlStatement + ";";
} | 3.26 |
morf_SqlDialect_getGreatestFunctionName_rdh | /**
*
* @return The name of the GREATEST function
*/
protected String getGreatestFunctionName() {
return "GREATEST";
} | 3.26 |
morf_SqlDialect_m4_rdh | /**
* Converts the isNull function into SQL.
*
* @param function
* the function to convert.
* @return a string representation of the SQL.
*/
protected String m4(Function function) {
return getSqlForCoalesce(function);
} | 3.26 |
morf_SqlDialect_selectStatementPreFieldDirectives_rdh | /**
* Returns any SQL code which should be added between a <code>SELECT</code> and the field
* list for dialect-specific reasons.
*
* @param selectStatement
* The select statement
* @return Any hint code required.
*/
protected String selectStatementPreFieldDirectives(@SuppressWarnings("unused")
SelectStatement... | 3.26 |
morf_SqlDialect_addCastsToSelect_rdh | /**
* For some dialects, this casting is required, as the type may not be inferred for every field in the select statement.
*
* @param table
* the table to add the casts.
* @param selectStatement
* select statements which the casts need adding to.
* @return SelectStatement with casts.
*/
protected SelectSta... | 3.26 |
morf_SqlDialect_withPrefix_rdh | /**
* Use this to create a temporary or non-temporary {@link IdTable} which is
* guaranteed to have a legal name for the dialect. The non-temporary idTables
* are necessary to enable access from many sessions/connections in case of some
* dialects.
*
* @param dialect
* {@link SqlDialect} that knows what temp t... | 3.26 |
morf_SqlDialect_likeEscapeSuffix_rdh | /**
*
* @return The string used to set the SQL LIKE escape character - specified after all LIKE expressions
*/
protected String likeEscapeSuffix() {
return " ESCAPE '\\'";
} | 3.26 |
morf_SqlDialect_nextIdValue_rdh | /**
* Creates a field reference to provide id column values.
*
* @param sourceTable
* the source table.
* @param sourceReference
* a reference lookup to add the ID to.
* @param autoNumberTable
* the name of the table to query over.
* @param nameColumn
* the name of the column holding the Autonumber na... | 3.26 |
morf_SqlDialect_getNonKeyFieldsFromMergeStatement_rdh | /**
* Returns the non key fields from a merge statement.
*
* @param statement
* a merge statement
* @return the non key fields
*/
protected Iterable<AliasedField> getNonKeyFieldsFromMergeStatement(MergeStatement statement) {
Set<String> tableUniqueKey = statement.getTableUniqueKey().stream().map(AliasedField... | 3.26 |
morf_SqlDialect_getDataTypeRepresentation_rdh | /**
* Gets the column representation for the datatype, etc.
*
* @param dataType
* the column datatype.
* @param width
* the column width.
* @param scale
* the column scale.
* @return a string representation of the column definition.
*/
protected String getDataTypeRepresentation(DataType dataType, int wi... | 3.26 |
morf_SchemaUtils_index_rdh | /**
* Build an index.
* <p>
* Use the methods on {@link IndexBuilder} to provide columns and optional
* properties.
* </p>
*
* @param name
* The name of the index.
* @return An {@link IndexBuilder} for the index.
*/
public static IndexBuilder index(String name) {
return new IndexBuilderImpl(name);
} | 3.26 |
morf_SchemaUtils_indexes_rdh | /**
*
* @see org.alfasoftware.morf.metadata.SchemaUtils.TableBuilder#indexes(java.lang.Iterable)
*/
@Overridepublic TableBuilder indexes(Iterable<? extends Index>
indexes) {
return new TableBuilderImpl(getName(), columns(), indexes, isTemporary()); } | 3.26 |
morf_SchemaUtils_columns_rdh | /**
*
* @see org.alfasoftware.morf.metadata.SchemaUtils.IndexBuilder#columns(java.lang.Iterable)
*/
@Override
public IndexBuilder columns(Iterable<String> columnNames) {
return new IndexBuilderImpl(getName(), isUnique(), columnNames);} | 3.26 |
morf_SchemaUtils_autoNumbersForTable_rdh | /**
* List auto-numbered columns for a given table.
*
* @param table
* The table
* @return The auto-numbered columns
*/
public static List<Column> autoNumbersForTable(Table table) {
return table.columns().stream().filter(Column::isAutoNumbered).collect(Collectors.toList());
} | 3.26 |
morf_SchemaUtils_notPrimaryKey_rdh | /**
*
* @see org.alfasoftware.morf.metadata.SchemaUtils.ColumnBuilder#notPrimaryKey()
*/
@Override
public ColumnBuilder notPrimaryKey() {
return new ColumnBuilderImpl(this, isNullable(), getDefaultValue(), false, isAutoNumbered(), getAutoNumberStart());
} | 3.26 |
morf_SchemaUtils_view_rdh | /**
* Create a view.
*
* @param viewName
* The name of the view.
* @param selectStatement
* The underlying {@link SelectStatement}. This can be null e.g. if loading from database metadata or in testing.
* @param dependencies
* names of any views that this view depends on (and therefore need to be deployed... | 3.26 |
morf_SchemaUtils_isMatching_rdh | /**
* Match table/view name against a list of exclusion regexs
*
* @param exclusionRegExes
* A list of tables/views to exclude
* @param name
* Table/View name
* @return boolean for filter
*/
private static boolean isMatching(Collection<String> exclusionRegExes, String name) {
return exclusionRegExes.st... | 3.26 |
morf_SchemaUtils_toUpperCase_rdh | /**
* Convert all the strings in a list to upper case.
*
* @param listOfStrings
* A list of strings
* @return A new list of strings, with each string converted to upper case
*/
public static List<String> toUpperCase(List<String> listOfStrings) {
return listOfStrings.stream().map(String::toUpperCase).collect(Col... | 3.26 |
morf_SchemaUtils_primaryKey_rdh | /**
*
* @see org.alfasoftware.morf.metadata.SchemaUtils.ColumnBuilder#primaryKey()
*/@Override
public ColumnBuilder primaryKey() {
return new ColumnBuilderImpl(this, isNullable(), getDefaultValue(), true, isAutoNumbered(), getAutoNumberStart());
} | 3.26 |
morf_SchemaUtils_namesOfColumns_rdh | /**
* Turn a list of columns into a list of the columns' names.
*
* @param columns
* The columns
* @return The columns' names.
*/
public static List<String> namesOfColumns(List<Column> columns) {
return Lists.transform(columns, new Function<Column, String>() {
@Override
public String apply(C... | 3.26 |
morf_SchemaUtils_primaryKeysForTable_rdh | /**
* List the primary key columns for a given table.
*
* @param table
* The table
* @return The primary key columns
*/
public static List<Column> primaryKeysForTable(Table table) {
return table.columns().stream().filter(Column::isPrimaryKey).collect(Collectors.toList());
} | 3.26 |
morf_SchemaUtils_nullable_rdh | /**
*
* @see org.alfasoftware.morf.metadata.SchemaUtils.ColumnBuilder#nullable()
*/
@Override
public ColumnBuilder nullable() {
return new ColumnBuilderImpl(this, true, getDefaultValue(), isPrimaryKey(), isAutoNumbered(), getAutoNumberStart());
} | 3.26 |
morf_SchemaUtils_copy_rdh | /**
* Create a copy of a view.
*
* @param view
* The {@link View} to copy.
* @return {@link View} implementation copied from the provided view.
*/
public static View copy(View view) {
return new ViewBean(view);
} | 3.26 |
morf_SchemaUtils_table_rdh | /**
* Build a {@link Table}.
* <p>
* Use {@link TableBuilder#columns(Column...)} to provide columns and
* {@link TableBuilder#indexes(Index...)} to provide indexes.
* </p>
*
* @param name
* The name of the table.
* @return A new {@link TableBuilder} for the table.
*/
public static TableBuilder table(String ... | 3.26 |
morf_SchemaUtils_type_rdh | /**
* Create a column type.
*
* @param type
* The {@link DataType} of the field.
* @param width
* The field width.
* @param scale
* The field scale.
* @param nullable
* Whether the field should be nullable.
* @return The {@link ColumnType}.
*/
public static ColumnType type(DataType type, int width, ... | 3.26 |
morf_SchemaUtils_schema_rdh | /**
* Build a {@link Schema} from a list of schema. The resulting schema is the
* superset of all elements.
*
* @param schema
* Schema to combine.
* @return A single schema representing all of {@code schema}.
*/
public static Schema schema(Schema... schema) {
return new CompositeSchema(schema);
}
/**
* C... | 3.26 |
morf_SchemaUtils_unique_rdh | /**
*
* @see org.alfasoftware.morf.metadata.SchemaUtils.IndexBuilder#unique()
*/
@Overridepublic IndexBuilder unique() {
return new IndexBuilderImpl(getName(), true,
columnNames());
} | 3.26 |
morf_SchemaUtils_versionColumn_rdh | /**
* Creates a Column that defines the standard version column.
*
* @return a version Column.
*/
public static Column versionColumn() {
return new ColumnBean("version", DataType.INTEGER, 0, 0, true, "0");
} | 3.26 |
morf_SchemaUtils_autoNumbered_rdh | /**
*
* @see org.alfasoftware.morf.metadata.SchemaUtils.ColumnBuilder#autoNumbered(int)
*/
@Override
public ColumnBuilder autoNumbered(int from) {
return new ColumnBuilderImpl(this, isNullable(), getDefaultValue(), isPrimaryKey(), true, from);
} | 3.26 |
morf_SchemaUtils_defaultValue_rdh | /**
*
* @see org.alfasoftware.morf.metadata.SchemaUtils.ColumnBuilder#defaultValue(java.lang.String)
*/
@Override
public ColumnBuilder defaultValue(String value) {
return new ColumnBuilderImpl(this, isNullable(), value, isPrimaryKey(), isAutoNumbered(), getAutoNumberStart());
} | 3.26 |
morf_SchemaUtils_temporary_rdh | /**
*
* @see org.alfasoftware.morf.metadata.SchemaUtils.TableBuilder#temporary()
*/
@Override
public TableBuilder temporary() {
return new TableBuilderImpl(getName(), columns(), indexes(), true);
} | 3.26 |
morf_SchemaUtils_column_rdh | /**
* Build a {@link Column}.
* <p>
* This method returns a {@link ColumnBuilder} whose properties are an exact copy of the passed in {@link Column}.
* </p>
* <p>
* Use the methods on {@link ColumnBuilder} to provide optional properties.
* </p>
*
* @param column
* The column to copy.
* @return A new {@link... | 3.26 |
morf_SchemaUtils_idColumn_rdh | /**
* Creates a Column that defines the standard ID column.
*
* @return an ID Column.
*/public static Column idColumn() {
return new ColumnBean("id", DataType.BIG_INTEGER, 0, 0, false, "", true);
} | 3.26 |
morf_SchemaUtils_autonumber_rdh | /**
* Build an auto-increment primary key column. Type defaults to a universally
* safe big integer. No further modification is possible.
*
* @param name
* The column name.
* @param startFrom
* The auto-increment start value.
* @return A new {@link Column}.
*/
public static Column autonumber(String name... | 3.26 |
morf_SqlUtils_when_rdh | /**
* Builder method for {@link WhenCondition}.
*
* <p>
* Example:
* </p>
*
* <pre>
* <code>
* caseStatement(when(eq(field("receiptType"), literal("R"))).then(literal("Receipt")),
* when(eq(field("receiptType"), literal("S"))).then(literal("Agreement Suspense")),
* when(eq(f... | 3.26 |
morf_SqlUtils_asString_rdh | /**
* Returns a SQL DSL expression to return the field CASTed to
* a string of the specified length
*
* @param length
* length of the string cast
* @return {@link Cast} as string of given length
*/
public Cast asString(int length) {
return asType(DataType.STRING, length);
} | 3.26 |
morf_SqlUtils_width_rdh | /**
* Specifies the width and scale of the parameter and
* returns the constructed parameter.
*
* @param width
* The width
* @param scale
* The scale
* @return the {@link SqlParameter}.
*/
public SqlParameter width(int width, int scale) {
return new SqlParameter(column(getMetadata().getName(), getMeta... | 3.26 |
morf_SqlUtils_otherwise_rdh | /**
*
* @param defaultValue
* If all the when conditions fail return this default value
* @return {@link CaseStatement}
*/
public CaseStatement otherwise(boolean defaultValue) {
return otherwise(literal(defaultValue));
} | 3.26 |
morf_SqlUtils_nullLiteralIfFieldIsZero_rdh | /**
* Returns null if field is zero, otherwise returns the expression.
*
* @param field
* expression to check for zero.
* @param expression
* expression to return if field is not zero.
* @return null or the expression
*/
public static AliasedField nullLiteralIfFieldIsZero(AliasedField field, AliasedField ex... | 3.26 |
morf_SqlUtils_m1_rdh | /**
* Constructs a new {@link BlobFieldLiteral} from given bytes.
*
* @param value
* the literal value to use
* @return {@link BlobFieldLiteral}
*/
public static BlobFieldLiteral m1(byte[] value) {
return new BlobFieldLiteral(value);
} | 3.26 |
morf_SqlUtils_caseStatement_rdh | /**
* Builder method for {@link CaseStatement}.
*
* <p>
* Example:
* </p>
*
* <pre>
* caseStatement(when(eq(field("receiptType"), literal("R"))).then(literal("Receipt")),
* when(eq(field("receiptType"), literal("S"))).then(literal("Agreement ... | 3.26 |
morf_SqlUtils_nullLiteralIfZero_rdh | /**
* Returns null if the supplied expression is zero,
* otherwise returns the expression.
*
* @param expression
* the expression to evaluate
* @return null or the expression
*/
public static AliasedField nullLiteralIfZero(AliasedField expression) {
return caseStatement(when(eq(expression, literal(0))).the... | 3.26 |
morf_SqlUtils_m4_rdh | /**
*
* @param defaultValue
* If all the when conditions fail return this default value
* @return {@link CaseStatement}
*/
public CaseStatement m4(String defaultValue) {return otherwise(literal(defaultValue));
} | 3.26 |
morf_SqlUtils_substring_rdh | /**
* Returns a SQL DSL expression to return the substring of <strong>field</strong>
* of <strong>length</strong> characters, starting from <strong>from</strong>.
*
* @param field
* The source expression.
* @param from
* The start character offset.
* @param length
* The length of the substring.
* @retur... | 3.26 |
morf_SqlUtils_parameter_rdh | /**
* Constructs a new SQL named parameter from a column.
*
* @param column
* the parameter column.
* @return {@link SqlParameter}
*/
public static SqlParameter parameter(Column column) {
return new SqlParameter(column);
}
/**
* Shortcut to "empty or null", where empty means spaces only.
*
* <p>Note tha... | 3.26 |
morf_SqlUtils_m0_rdh | /**
* Constructs an Insert Statement.
*
* <p>Usage is discouraged; this method will be deprecated at some point. Use
* {@link InsertStatement#insert()} for preference.</p>
*
* @return {@link InsertStatement}
*/
public static InsertStatement m0() {
return new InsertStatement();
} | 3.26 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.