[error] java.sql.SQLException: Operand should contain 1 column(s) (SQLError.java:1078)
val subQuery =
for {
uc <- UserContentTable.query if uc.userId === userId.toString && adoptedClause(uc) && !uc.deleted
c <- ContentTable.query if uc.contentId === c.id
} yield (uc, c)
val query =
UserTable.query.filter(_.id === userId.toString)
.joinLeft(subQuery).on { case (u, (uc, c)) => u.id === uc.userId}
.sortBy { case (u, subq) => subq.map { case (uc, c) => uc.created } }
.map { case (u, subq) => (u, subq.map { case (uc, c) => c }) }
select x2.x3, x2.x4, x2.x5, (case when (x6.`content_id` is null) then null else 1 end), x7.`id`, x7.`title`, x7.`source`, x7.`source_id`, x7.`content_type`, x7.`duration`, x7.`privacy_status`, x7.`thumbnail_url`, x7.`publisher`, x7.`default_language`
from (select `id` as x3, `email` as x4, `created` as x5 from `user` where `id` = 'b1455c42-e8e0-4b43-b738-17846fb85f22') x2
left outer join (`user_content` x6 inner join `content` x7
on (((x6.`user_id` = 'b1455c42-e8e0-4b43-b738-17846fb85f22')
and ((not (x6.`adopted` is not null)) or (not x6.`adopted`))) and (not x6.`deleted`))
and (x6.`content_id` = x7.`id`)) on x2.x3 = x6.`user_id`
order by ((case when (x6.`content_id` is null) then null else 1 end), x6.`created`)
CREATE TABLE `content` (
`id` varchar(255) NOT NULL,
`title` varchar(255) NOT NULL,
`source` varchar(255) NOT NULL,
`source_id` varchar(255) NOT NULL,
`content_type` varchar(255) NOT NULL,
`duration` int(11) NOT NULL,
`privacy_status` varchar(255) NOT NULL,
`thumbnail_url` varchar(255) DEFAULT NULL,
`publisher` varchar(255) DEFAULT NULL,
`default_language` varchar(255) DEFAULT NULL,
UNIQUE KEY `pk_content` (`id`),
UNIQUE KEY `unique_ck_source_source_id` (`source`,`source_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
CREATE TABLE `user_content` (
`user_id` varchar(255) NOT NULL,
`content_id` varchar(255) NOT NULL,
`adopted` tinyint(1) DEFAULT NULL,
`deleted` tinyint(1) NOT NULL DEFAULT '0',
`created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY `pk_user_content` (`user_id`,`content_id`),
KEY `fk_user_content_content` (`content_id`),
CONSTRAINT `fk_user_content_content` FOREIGN KEY (`content_id`) REFERENCES `content` (`id`),
CONSTRAINT `fk_user_content_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8