Allan Wang
11/10/2018, 7:27 AMtapac
11/10/2018, 9:39 AMwrapAsExpression()
function and write something like:
address.cityId eq wrapAsExpression<Int>(cities.slice(cities.id.max()).selectAll())
Allan Wang
11/11/2018, 6:33 AMtapac
11/11/2018, 8:44 AMwrapAsExpression
in a select condition.Allan Wang
11/18/2018, 3:39 AMobject PrinterTable : IdTable<String>("printer") {
override val id = varchar("id", ID_SIZE).entityId()
val name = varchar("name", NAME_SIZE).uniqueIndex()
val group = varchar("group", ID_SIZE)
}
object PrinterStatusTable : IdTable<String>("printer_status") {
override val id = varchar("id", ID_SIZE).primaryKey(0).entityId().references(PrinterTable.id, ReferenceOption.CASCADE)
val date = datetime("date").primaryKey(1).clientDefault(DateTime::now)
val user = varchar("user", USER_SIZE)
val flag = varchar("flag", FLAG_SIZE)
val message = varchar("message", MESSAGE_SIZE)
}
I want to left join a printer to the latest printer status where the id matches.
From what I see online, it feels like I should be approaching it with something like
(PrinterTable leftJoin ***).select { PrinterTable.id eq PrinterStatusTable.id }
where * represents the status table with only the latest entry for every id.
Following your example above, I can write something like
PrinterTable.id eq wrapAsExpression(PrinterStatusTable.slice(PrinterStatusTable.date.max()).selectAll())
But I don’t think that makes sense
(@tapac)