Search in sources :

Example 11 with QueryBuilder

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

the class Condition method concatenate.

@SuppressWarnings("unchecked")
@Override
public Condition concatenate(Object value) {
    operation = new QueryBuilder(Operation.EQUALS).append(columnName()).toString();
    TypeConverter typeConverter = this.typeConverter;
    if (typeConverter == null && value != null) {
        typeConverter = FlowManager.getTypeConverterForClass(value.getClass());
    }
    if (typeConverter != null && convertToDB) {
        value = typeConverter.getDBValue(value);
    }
    if (value instanceof String || value instanceof ITypeConditional) {
        operation = String.format("%1s %1s ", operation, Operation.CONCATENATE);
    } else if (value instanceof Number) {
        operation = String.format("%1s %1s ", operation, Operation.PLUS);
    } else {
        throw new IllegalArgumentException(String.format("Cannot concatenate the %1s", value != null ? value.getClass() : "null"));
    }
    this.value = value;
    isValueSet = true;
    return this;
}
Also used : TypeConverter(com.raizlabs.android.dbflow.converter.TypeConverter) QueryBuilder(com.raizlabs.android.dbflow.sql.QueryBuilder)

Example 12 with QueryBuilder

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

the class Condition method getQuery.

@Override
public String getQuery() {
    QueryBuilder queryBuilder = new QueryBuilder();
    appendConditionToQuery(queryBuilder);
    return queryBuilder.getQuery();
}
Also used : QueryBuilder(com.raizlabs.android.dbflow.sql.QueryBuilder)

Example 13 with QueryBuilder

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

the class ConditionGroup method getQuerySafe.

private QueryBuilder getQuerySafe() {
    QueryBuilder query = new QueryBuilder();
    int count = 0;
    int size = conditionsList.size();
    for (int i = 0; i < size; i++) {
        SQLCondition condition = conditionsList.get(i);
        if (condition != null) {
            condition.appendConditionToQuery(query);
            if (count < size - 1) {
                if (!allCommaSeparated) {
                    query.appendSpace().append(condition.hasSeparator() ? condition.separator() : separator);
                } else {
                    query.append(",");
                }
                query.appendSpace();
            }
        }
        count++;
    }
    return query;
}
Also used : QueryBuilder(com.raizlabs.android.dbflow.sql.QueryBuilder)

Example 14 with QueryBuilder

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

the class From method getQuery.

@Override
public String getQuery() {
    QueryBuilder queryBuilder = new QueryBuilder().append(queryBase.getQuery());
    if (!(queryBase instanceof Update)) {
        queryBuilder.append("FROM ");
    }
    queryBuilder.append(tableAlias);
    if (queryBase instanceof Select) {
        for (Join join : joins) {
            queryBuilder.appendSpace();
            queryBuilder.append(join.getQuery());
        }
    } else {
        queryBuilder.appendSpace();
    }
    return queryBuilder.getQuery();
}
Also used : QueryBuilder(com.raizlabs.android.dbflow.sql.QueryBuilder)

Example 15 with QueryBuilder

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

the class Select method getQuery.

@Override
public String getQuery() {
    QueryBuilder queryBuilder = new QueryBuilder("SELECT ");
    if (mSelectQualifier != NONE) {
        if (mSelectQualifier == DISTINCT) {
            queryBuilder.append("DISTINCT");
        } else if (mSelectQualifier == ALL) {
            queryBuilder.append("ALL");
        }
        queryBuilder.appendSpace();
    }
    queryBuilder.append(QueryBuilder.join(",", propertyList));
    queryBuilder.appendSpace();
    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