Question: FlowQueryList over joined dataset
See original GitHub issueDBFlow Version: 3.0.1 Issue Kind (Bug, Question, Feature): Question
Description:
I have the following problem. I have a table, lets call it Contact
and another one referencing it via ForeignKey, lets call it Phone
. So one Contact can have multiple Phone numbers.
I need to display a list of contacts in RecyclerView showing all phones separated by comma for each contact in a row.
To make this I create ModelView in which I query contacts, left join them with phones. I load this ModelView with CursorLoader and display its data in RecyclerView. Now I end up creating ModelView for every list in my applications and this bothers me much.
The question is, can I achieve the same behaviour without ModelView?
-
I was trying to use .queryCustomList() to get list of BaseQueryModel, but I extract all data in memory instanly this way and this is generally bad for performance. So I’m against this method.
-
I was trying to use FlowQursorList but it can’t handle joins and cannot be used to get list of BaseQueryModel:
SQLite.select(extendedContactColumns)
.from(Contact.class)
.leftOuterJoin(Phone.class)
.on(Phone_Table.contact_id.eq(1L))
.where(Contact_Table.id.is(1L))
.flowQueryList() <--- converts to FlowQueryList<Contact>
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
in
develop
. Use thenew FlowQueryList.Builder<>(joinClass.class).cursor(cursor).build()
if you specify a
FlowCursorList
orFlowQueryList
with aCursor
, you cannotrefresh()
the list. I have updated the class to throw an exception. You must construct a new instance in that scenario once theCursor
has been closed.