String sql = SQLiteQueryBuilder.buildQueryString(false, "notes", proj, selection, null, null, order, null); return col.getDb().getDatabase().query(sql, selectionArgs); if ((noteIds != null) && (!noteIds.isEmpty())) { String sel = String.format("id in (%s)", TextUtils.join(",", noteIds)); String sql = SQLiteQueryBuilder.buildQueryString(false, "notes", proj, sel, null, null, order, null); return col.getDb().getDatabase().query(sql); } else { String sql = SQLiteQueryBuilder.buildQueryString(false, "notes", proj, "id=?", null, null, order, null); return col.getDb().getDatabase().query(sql, new String[]{noteId});
@NonNull public Cursor query(Schema<?> schema, String[] columns, String whereClause, String[] bindArgs, String groupBy, String having, String orderBy, String limit) { String sql = SQLiteQueryBuilder.buildQueryString( false, schema.getSelectFromTableClause(), columns, whereClause, groupBy, having, orderBy, limit); return rawQuery(sql, bindArgs); }
/** * @param columns SQL result columns for the {@code SELECT} statement * @return A {@code SELECT} statement the selector represents */ @NonNull public String buildQueryWithColumns(@NonNull String... columns) { return SQLiteQueryBuilder.buildQueryString( false, getSchema().getSelectFromTableClause(), columns, getWhereClause(), groupBy, having, orderBy, getLimitClause()); }
@Implementation public Cursor query(boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) { String where = selection; if (selection != null && selectionArgs != null) { where = buildWhereClause(selection, selectionArgs); } String sql = SQLiteQueryBuilder.buildQueryString(distinct, table, columns, where, groupBy, having, orderBy, limit); ResultSet resultSet; try { Statement statement = connection.createStatement(DatabaseConfig.getResultSetType(), ResultSet.CONCUR_READ_ONLY); resultSet = statement.executeQuery(sql); } catch (SQLException e) { throw new RuntimeException("SQL exception in query", e); } SQLiteCursor cursor = new SQLiteCursor(null, null, null, null); shadowOf(cursor).setResultSet(resultSet,sql); return cursor; }
@IntRange(from = 0) public int count() { String sql = SQLiteQueryBuilder.buildQueryString( false, getSchema().getSelectFromTableClause(), countSelections, getWhereClause(), groupBy, null, null, null); return (int) conn.rawQueryForLong(sql, getBindArgs()); }