Skip to content

Instantly share code, notes, and snippets.

@DjangoFR
Last active December 22, 2021 10:45
Show Gist options
  • Save DjangoFR/79678a0492f305b3a63f800faeca26a1 to your computer and use it in GitHub Desktop.
Save DjangoFR/79678a0492f305b3a63f800faeca26a1 to your computer and use it in GitHub Desktop.
[Kotlin][Exposed] How to use asterisk in Exposed-Query
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