why does the chain with `.apply` result in `missi...
# komapper
s
why does the chain with
.apply
result in
missing FROM-clause entry for table "deck_tags"
?
Copy code
QueryDsl.from(decks).apply {
    tags.onSome {
        w = w.and { deckTags.tagId inList tags.getOrNull()!! }
        innerJoin(deckTags) { decks.id eq deckTags.deckId }
    }
    favouriteByUserId.onSome {
        w = w.and { bookmarkedDecks.userId eq it }
        innerJoin(bookmarkedDecks) { decks.id eq bookmarkedDecks.deckId }
    }
}.where(w)
the resulting sql statement is
... from decks as t0_ where t0_.public = $1 and (deck_tags.tag_id in ($2, $3)) order by ...
t
Because it discards the result of the
innerJoin
function. Try the following code:
Copy code
QueryDsl.from(decks)
.run {
    if (someCondition) {
        where { ... }
        .innerJoin(deckTags) { decks.id eq deckTags.deckId }
    } else this
}.run {
    if (anotherCondition) {
        where { ... }
        .innerJoin(bookmarkedDecks) { decks.id eq bookmarkedDecks.deckId }
    } else this
}
s
oh yes I see now. this works, thank you
👍 1