Hi everyone, is it possible to filter relation bef...
# exposed
g
Hi everyone, is it possible to filter relation before fetching them with the DAO api?
r
Try to join the required tables and filter with select{}. Then use the wrapRows-function to convert the result into your entity. https://github.com/JetBrains/Exposed/wiki/DAO#read-entity-with-a-join-to-another-table
g
My query includes the filter and relations. But when I do
with
, it does select all relations.
Oh... It works without
with
, but then I have ton of selects instead.
So filter related entities with eager loading does not work I guess?
r
Might well be. There are quite some limitations with the DAO as it is by far no complete ORM library. This might be a related issue ticket. https://github.com/JetBrains/Exposed/issues/1492
I decided to mainly not use the DAO library because it is too inflexible.
👍 1
g
Yeah, seems like it's not possible. Thanks!
Might be OT, but you do not use the DAO for the creation of model objects, but rather take the row and map the entity and the relations by yourself?
r
Sorry, I don't know what OT stands for. Regarding your question: Yes, in my project I am iterating over the result rows and building the model myself by checking the ids of the tables involved. That way, you also have to consider taht there is duplicate information since you have many-joins.