S.
04/29/2024, 10:17 PM.apply
result in missing FROM-clause entry for table "deck_tags"
?
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 ...
Toshihiro Nakamura
04/30/2024, 7:32 AMinnerJoin
function.
Try the following 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.
04/30/2024, 9:31 AM