Source:
<code>public void run() { AndroidUtilities.sleepDeep(500L); String groupedQuery; if (query.get().contains("ORDER BY")) groupedQuery = query.get().replace("ORDER BY", "GROUP BY " + Task.ID + " ORDER BY"); else groupedQuery = query.get() + " GROUP BY " + Task.ID; Query q = Query.select(Task.ID, Task.TITLE, Task.NOTES, Task.COMPLETION_DATE, new LongProperty(Metadata.TABLE, Metadata.ID.name, METADATA_JOIN + "." + Metadata.ID.name).as(FILE_COLUMN)) .join(Join.left(Metadata.TABLE.as(METADATA_JOIN), Criterion.and(Field.field(METADATA_JOIN + "." + Metadata.KEY.name).eq(FileMetadata.METADATA_KEY), <START> Task.ID.eq(Field.field(METADATA_JOIN + "." + Metadata.TASK.name))))).withQueryTemplate(groupedQuery); <END> final TodorooCursor<Task> fetchCursor = taskService.query(q); try { Task task = new Task(); LinkActionExposer linkActionExposer = new LinkActionExposer(); int filesIndex = fetchCursor.getColumnIndex(FILE_COLUMN); for(fetchCursor.moveToFirst(); !fetchCursor.isAfterLast(); fetchCursor.moveToNext()) { task.clear(); task.readFromCursor(fetchCursor); if(task.isCompleted()) continue; boolean hasAttachments = (filesIndex > 0 && fetchCursor.getLong(filesIndex) > 0); List<TaskAction> actions = linkActionExposer. getActionsForTask(ContextManager.getContext(), task, hasAttachments); if (actions.size() > 0) taskActionLoader.put(task.getId(), actions.get(0)); } } finally { fetchCursor.close(); } final Activity activity = fragment.getActivity(); if (activity != null) { activity.runOnUiThread(new Runnable() { @Override public void run() { if(taskActionLoader.size() > 0) { notifyDataSetChanged(); } } }); } }</code><technical_language>if FILE_COLUMN property a static field of this class. fetching out of cursor. If do this, change CursorReadingVisitor.columnIndex property.toString() instead of property.name</technical_language>

Target:
public void run() { AndroidUtilities.sleepDeep(500L); String groupedQuery; if (query.get().contains("ORDER BY")) groupedQuery = query.get().replace("ORDER BY", "GROUP BY " + Task.ID + " ORDER BY"); else groupedQuery = query.get() + " GROUP BY " + Task.ID; Query q = Query.select(Task.ID, Task.TITLE, Task.NOTES, Task.COMPLETION_DATE, fileIdProperty.as(FILE_COLUMN)) .join(Join.left(Metadata.TABLE.as(METADATA_JOIN), Criterion.and(Field.field(METADATA_JOIN + "." + Metadata.KEY.name).eq(FileMetadata.METADATA_KEY), Task.ID.eq(Field.field(METADATA_JOIN + "." + Metadata.TASK.name))))).withQueryTemplate(groupedQuery); final TodorooCursor<Task> fetchCursor = taskService.query(q); try { Task task = new Task(); LinkActionExposer linkActionExposer = new LinkActionExposer(); for(fetchCursor.moveToFirst(); !fetchCursor.isAfterLast(); fetchCursor.moveToNext()) { task.clear(); task.readFromCursor(fetchCursor); if(task.isCompleted()) continue; boolean hasAttachments = (fetchCursor.get(fileIdProperty) > 0); List<TaskAction> actions = linkActionExposer. getActionsForTask(ContextManager.getContext(), task, hasAttachments); if (actions.size() > 0) taskActionLoader.put(task.getId(), actions.get(0)); } } finally { fetchCursor.close(); } final Activity activity = fragment.getActivity(); if (activity != null) { activity.runOnUiThread(new Runnable() { @Override public void run() { if(taskActionLoader.size() > 0) { notifyDataSetChanged(); } } }); } }