Hi, is it possible to join on an association table...
# exposed
d
Hi, is it possible to join on an association table (many-to-many) with composite primary key? Trying to do a join and receiving: "as there is no matching primary key/foreign key pair and constraint missing"
Copy code
object CategoriesCoins: Table("categories_coins") {
    val category = reference("category_id", Categories)
    val coin = reference("coin_id", Coins)
    override val primaryKey = PrimaryKey(category, coin, name = "categories_coins_pkey")
}
Table def:
Copy code
Indexes:
    "categories_coins_pkey" PRIMARY KEY, btree (category_id, coin_id)
Foreign-key constraints:
    "fk_categories_coins_categories" FOREIGN KEY (category_id) REFERENCES categories(id) ON DELETE CASCADE
    "fk_categories_coins_coins" FOREIGN KEY (coin_id) REFERENCES coins(id) ON DELETE CASCADE
query:
Copy code
Coins.innerJoin(Categories).selectAll().withDistinct()
EDIT: managed to construct based on this comment using multiple `innerJoin`: https://github.com/JetBrains/Exposed/issues/177#issuecomment-335939897