fix: フォロワー一覧取得のSQL修正

This commit is contained in:
usbharu 2023-03-30 16:24:06 +09:00
parent 7e77d8c631
commit 00fd7f4624
1 changed files with 6 additions and 3 deletions

View File

@ -80,15 +80,18 @@ class UserRepository(private val database: Database) : IUserRepository {
override suspend fun findFollowersById(id: Long): List<UserEntity> { override suspend fun findFollowersById(id: Long): List<UserEntity> {
return query { return query {
val followers = Users.alias("followers") val followers = Users.alias("FOLLOWERS")
Users.leftJoin( Users.innerJoin(
otherTable = UsersFollowers, otherTable = UsersFollowers,
onColumn = { Users.id }, onColumn = { Users.id },
otherColumn = { UsersFollowers.userId }) otherColumn = { UsersFollowers.userId })
.leftJoin(
.innerJoin(
otherTable = followers, otherTable = followers,
onColumn = { UsersFollowers.followerId }, onColumn = { UsersFollowers.followerId },
otherColumn = { followers[Users.id] }) otherColumn = { followers[Users.id] })
.slice(followers.get(Users.id), followers.get(Users.name), followers.get(Users.domain), followers.get(Users.screenName), followers.get(Users.description))
.select { Users.id eq id } .select { Users.id eq id }
.map { .map {
UserEntity( UserEntity(