/** * Query the database * * @param modelClass the type to parameterize the cursor by. If the query does not contain a FROM clause, the table * or view corresponding to this model class will be used. * @param query the query to execute * @return a {@link SquidCursor} containing the query results */ public <TYPE extends AbstractModel> SquidCursor<TYPE> query(Class<TYPE> modelClass, Query query) { query = inferTableForQuery(modelClass, query); CompiledStatement compiled = query.compile(getCompileContext()); if (compiled.needsValidation) { String validateSql = query.sqlForValidation(getCompileContext()); ensureSqlCompiles(validateSql); // throws if the statement fails to compile } ICursor cursor = rawQuery(compiled.sql, compiled.sqlArgs); return new SquidCursor<>(cursor, modelClass, query.getFields()); }
/** * Query the database * * @param modelClass the type to parameterize the cursor by. If the query does not contain a FROM clause, the table * or view corresponding to this model class will be used. * @param query the query to execute * @return a {@link SquidCursor} containing the query results */ public <TYPE extends AbstractModel> SquidCursor<TYPE> query(Class<TYPE> modelClass, Query query) { query = inferTableForQuery(modelClass, query); CompiledStatement compiled = query.compile(getCompileContext()); if (compiled.needsValidation) { String validateSql = query.sqlForValidation(getCompileContext()); ensureSqlCompiles(validateSql); // throws if the statement fails to compile } ICursor cursor = rawQuery(compiled.sql, compiled.sqlArgs); return new SquidCursor<>(cursor, modelClass, query.getFields()); }