Search in sources :

Example 16 with QueryBuilder

use of com.raizlabs.android.dbflow.sql.QueryBuilder in project DBFlow by Raizlabs.

the class Update method getQuery.

@Override
public String getQuery() {
    QueryBuilder queryBuilder = new QueryBuilder("UPDATE ");
    if (conflictAction != null && !conflictAction.equals(ConflictAction.NONE)) {
        queryBuilder.append("OR").appendSpaceSeparated(conflictAction.name());
    }
    queryBuilder.append(FlowManager.getTableName(table)).appendSpace();
    return queryBuilder.getQuery();
}
Also used : QueryBuilder(com.raizlabs.android.dbflow.sql.QueryBuilder)

Example 17 with QueryBuilder

use of com.raizlabs.android.dbflow.sql.QueryBuilder in project DBFlow by Raizlabs.

the class AlterTableMigration method addForeignKeyColumn.

/**
     * Add a column to the DB. This does not necessarily need to be reflected in the {@link TModel},
     * but it is recommended.
     *
     * @param sqLiteType      The type of column that pertains to an {@link SQLiteType}
     * @param columnName      The name of the column to add. Use the "$Table" class for the specified table.
     * @param referenceClause The clause of the references that this foreign key points to.
     * @return This instance
     */
public AlterTableMigration<TModel> addForeignKeyColumn(SQLiteType sqLiteType, String columnName, String referenceClause) {
    if (columnDefinitions == null) {
        columnDefinitions = new ArrayList<>();
        columnNames = new ArrayList<>();
    }
    QueryBuilder queryBuilder = new QueryBuilder().append(QueryBuilder.quoteIfNeeded(columnName)).appendSpace().appendSQLiteType(sqLiteType).appendSpace().append("REFERENCES ").append(referenceClause);
    columnDefinitions.add(queryBuilder);
    columnNames.add(columnName);
    return this;
}
Also used : QueryBuilder(com.raizlabs.android.dbflow.sql.QueryBuilder)

Example 18 with QueryBuilder

use of com.raizlabs.android.dbflow.sql.QueryBuilder in project DBFlow by Raizlabs.

the class AlterTableMigration method renameFrom.

/**
     * Call this to rename a table to a new name, such as changing either the {@link com.raizlabs.android.dbflow.structure.Model} class name
     * or by changing the name through a {@link com.raizlabs.android.dbflow.annotation.Table}
     *
     * @param oldName The new name to call the table.
     * @return This instance
     */
public AlterTableMigration<TModel> renameFrom(@NonNull String oldName) {
    oldTableName = oldName;
    renameQuery = new QueryBuilder().append(" RENAME").appendSpaceSeparated("TO");
    return this;
}
Also used : QueryBuilder(com.raizlabs.android.dbflow.sql.QueryBuilder)

Example 19 with QueryBuilder

use of com.raizlabs.android.dbflow.sql.QueryBuilder in project DBFlow by Raizlabs.

the class CompletedTrigger method getQuery.

@Override
public String getQuery() {
    QueryBuilder queryBuilder = new QueryBuilder(triggerMethod.getQuery());
    queryBuilder.append("\nBEGIN").append("\n").append(triggerLogicQuery.getQuery()).append(";").append("\nEND");
    return queryBuilder.getQuery();
}
Also used : QueryBuilder(com.raizlabs.android.dbflow.sql.QueryBuilder)

Aggregations

QueryBuilder (com.raizlabs.android.dbflow.sql.QueryBuilder)19 Cursor (android.database.Cursor)1 SQLiteException (android.database.sqlite.SQLiteException)1 TypeConverter (com.raizlabs.android.dbflow.converter.TypeConverter)1 ModelAdapter (com.raizlabs.android.dbflow.structure.ModelAdapter)1 ModelViewAdapter (com.raizlabs.android.dbflow.structure.ModelViewAdapter)1 ArrayList (java.util.ArrayList)1