https://kotlinlang.org logo
#exposed
Title
# exposed
d

danielm

05/30/2018, 9:49 AM
what am I missing?
t

tapac

05/30/2018, 11:31 AM
Please share your tables mapping and join condition
d

danielm

05/30/2018, 11:52 AM
Already the following code stitched together from the wiki does throw the exception:
Copy code
import org.jetbrains.exposed.dao.IntIdTable
import org.jetbrains.exposed.sql.Column
import org.jetbrains.exposed.sql.Table
import org.jetbrains.exposed.sql.count
import org.jetbrains.exposed.sql.select

fun main(args: Array<String>) {
    (Players innerJoin StarWarsFilms)
            .slice(Players.name.count(), StarWarsFilms.name)
            .select { StarWarsFilms.sequelId eq Players.sequelId }
            .groupBy(StarWarsFilms.name)
}


object StarWarsFilms : IntIdTable() {
    val sequelId: Column<Int> = integer("sequel_id").uniqueIndex()
    val name: Column<String> = varchar("name", 50)
    val director: Column<String> = varchar("director", 50)
}


object Players : Table() {
    val sequelId: Column<Int> = integer("sequel_id").uniqueIndex()
    val name: Column<String> = varchar("name", 50)
}
t

tapac

05/30/2018, 2:48 PM
I see, there is a bug in wiki. When you use innerJoin without specifying columns, you should create reference between tables. ATM StarWarsFilms and Players are unrelated to each other. Try to replace
Players innerJoin StarWarsFilms
with
Players.innerJoin(StarWarsFilms, { Players.sequeld}. { StarWarsFilms.sequelId })
d

danielm

05/31/2018, 4:45 AM
Thank you for the info.
Just for reference there were 2 typos in your code. It should be:
Copy code
Players.innerJoin(StarWarsFilms, { Players.sequelId}, { StarWarsFilms.sequelId })
t

tapac

05/31/2018, 10:02 AM
I wrote it right in the slack:D Without verification, but I hope you understand the main idea.
d

danielm

05/31/2018, 2:02 PM
Yeah, it's working, thanks