Last active
December 22, 2021 10:45
-
-
Save DjangoFR/79678a0492f305b3a63f800faeca26a1 to your computer and use it in GitHub Desktop.
[Kotlin][Exposed] How to use asterisk in Exposed-Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun queryUsingAsterisk(clientId: Long): Query { | |
val tableAlias = InvoiceTable.alias("i") | |
val asterisk = object : Expression<String>() { | |
override fun toQueryBuilder(queryBuilder: QueryBuilder) { | |
queryBuilder { +"*" } | |
} | |
} | |
return InvoiceTable.alias("i") | |
.slice(asterisk) | |
.select { tableAlias[InvoiceTable.client].eq(clientId) } | |
.andWhere { tableAlias[InvoiceTable.id] eq InvoiceTable.id } | |
.andWhere { tableAlias[InvoiceTable.origin].eqSubQuery(subQuery(clientId)) } | |
.andWhere { tableAlias[InvoiceTable.invoiceType] eq InvoiceTypeEnum.TR.value } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment