How can I dynamically join tables in SQLDelight???...
# squarelibraries
v
How can I dynamically join tables in SQLDelight??? For Example, if i have a table like
Copy code
| id | referenceId | referenceType |
And according to the referenceType, i have to join on some specific table, Also making sure, that any change in that child table emits the change when i query this table using
asFlow()
or return
PagingData
k
Copy code
if (someCondition) {
  queryTableJoinedOnTable1()
} else {
  queryTableJoinedOnTable2()
}
SQLDelight registers change listeners for every table possibly involved in a query, so even though they'd be two separate queries they would each still emit changes when something has potentially changed in the table
v
Thanks, I'll try this out
@kevin.cianfarini any way to do it via kotlin and not
JOIN
in SQL The problem with join is that, there are too many columns returned and mapping it correctly to a sealed class is becoming a pain
137 Views