use of com.raizlabs.android.dbflow.sql.QueryBuilder in project DBFlow by Raizlabs.
the class TriggerMethod method getQuery.
@Override
public String getQuery() {
QueryBuilder queryBuilder = new QueryBuilder(trigger.getQuery()).append(methodName);
if (properties != null && properties.length > 0) {
queryBuilder.appendSpaceSeparated("OF").appendArray((Object[]) properties);
}
queryBuilder.appendSpaceSeparated("ON").append(FlowManager.getTableName(onTable));
if (forEachRow) {
queryBuilder.appendSpaceSeparated("FOR EACH ROW");
}
if (whenCondition != null) {
queryBuilder.append(" WHEN ");
whenCondition.appendConditionToQuery(queryBuilder);
queryBuilder.appendSpace();
}
queryBuilder.appendSpace();
return queryBuilder.getQuery();
}
use of com.raizlabs.android.dbflow.sql.QueryBuilder in project DBFlow by Raizlabs.
the class Join method getQuery.
@Override
public String getQuery() {
QueryBuilder queryBuilder = new QueryBuilder();
if (isNatural) {
queryBuilder.append("NATURAL ");
}
queryBuilder.append(type.name().replace("_", " ")).appendSpace();
queryBuilder.append("JOIN").appendSpace().append(alias.getFullQuery()).appendSpace();
if (onGroup != null) {
queryBuilder.append("ON").appendSpace().append(onGroup.getQuery()).appendSpace();
} else if (!using.isEmpty()) {
queryBuilder.append("USING (").appendArray(using).append(")").appendSpace();
}
return queryBuilder.getQuery();
}
use of com.raizlabs.android.dbflow.sql.QueryBuilder in project DBFlow by Raizlabs.
the class Where method getQuery.
@Override
public String getQuery() {
String fromQuery = whereBase.getQuery().trim();
QueryBuilder queryBuilder = new QueryBuilder().append(fromQuery).appendSpace().appendQualifier("WHERE", conditionGroup.getQuery()).appendQualifier("GROUP BY", QueryBuilder.join(",", groupByList)).appendQualifier("HAVING", havingGroup.getQuery()).appendQualifier("ORDER BY", QueryBuilder.join(",", orderByList));
if (limit > VALUE_UNSET) {
queryBuilder.appendQualifier("LIMIT", String.valueOf(limit));
}
if (offset > VALUE_UNSET) {
queryBuilder.appendQualifier("OFFSET", String.valueOf(offset));
}
return queryBuilder.getQuery();
}
use of com.raizlabs.android.dbflow.sql.QueryBuilder in project DBFlow by Raizlabs.
the class Case method getQuery.
@Override
public String getQuery() {
QueryBuilder queryBuilder = new QueryBuilder(" CASE");
if (isEfficientCase()) {
queryBuilder.append(" " + BaseCondition.convertValueToString(caseColumn, false));
}
queryBuilder.append(QueryBuilder.join(" ", caseConditions));
if (elseSpecified) {
queryBuilder.append(" ELSE ").append(BaseCondition.convertValueToString(elseValue, false));
}
if (endSpecified) {
queryBuilder.append(" END " + (columnName != null ? columnName : ""));
}
return queryBuilder.getQuery();
}
use of com.raizlabs.android.dbflow.sql.QueryBuilder in project DBFlow by Raizlabs.
the class BaseDatabaseHelper method executeCreations.
/**
* This method executes CREATE TABLE statements as well as CREATE VIEW on the database passed.
*/
protected void executeCreations(final DatabaseWrapper database) {
try {
database.beginTransaction();
List<ModelAdapter> modelAdapters = databaseDefinition.getModelAdapters();
for (ModelAdapter modelAdapter : modelAdapters) {
try {
database.execSQL(modelAdapter.getCreationQuery());
} catch (SQLiteException e) {
FlowLog.logError(e);
}
}
// create our model views
List<ModelViewAdapter> modelViews = databaseDefinition.getModelViewAdapters();
for (ModelViewAdapter modelView : modelViews) {
QueryBuilder queryBuilder = new QueryBuilder().append("CREATE VIEW IF NOT EXISTS").appendSpaceSeparated(modelView.getViewName()).append("AS ").append(modelView.getCreationQuery());
try {
database.execSQL(queryBuilder.getQuery());
} catch (SQLiteException e) {
FlowLog.logError(e);
}
}
database.setTransactionSuccessful();
} finally {
database.endTransaction();
}
}
Aggregations