```QueryDsl.from(decks).where(declaration).orderBy...
# komapper
s
Copy code
QueryDsl.from(decks).where(declaration).orderBy(decks.id.asc()).limit(pageSize)
            .leftJoin(deckWords) { decks.id eq deckWords.deck }
            .leftJoin(deckTags) { decks.id eq deckTags.deck }
            .include(decks, deckWords, deckTags)
the issue here is that it also limits joined tables. is it possible to add subqueries with the dsl to circumvent this?
t
Yes, it is possible.
Copy code
val decks2 = decks.clone()
val subquery = QueryDsl.from(decks2).where(declaration).orderBy(decks2.id.asc()).limit(pageSize).select(decks2.id)

QueryDsl.from(decks).where { decks.id inList subquery }.orderBy(decks.id.asc())
            .leftJoin(deckWords) { decks.id eq deckWords.deck }
            .leftJoin(deckTags) { decks.id eq deckTags.deck }
            .include(decks, deckWords, deckTags)
You can also define
decks2
using aliases instead of cloning
decks
. Please refer to the documentation for more information about aliases: https://www.komapper.org/docs/reference/entity-class/#metamodel-aliases
s
works like a charm, thank you!