Merge pull request #19281 from nextcloud/fix/noid/get-unread-comments-with-indexes

for the DB ot pick an index specify the object_type
This commit is contained in:
Roeland Jago Douma 2020-02-03 21:23:35 +01:00 committed by GitHub
commit 4503cff51a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -601,11 +601,13 @@ class Manager implements ICommentsManager {
$query = $qb->select('f.fileid')
->addSelect($qb->func()->count('c.id', 'num_ids'))
->from('filecache', 'f')
->leftJoin('f', 'comments', 'c', $qb->expr()->eq(
'f.fileid', $qb->expr()->castColumn('c.object_id', IQueryBuilder::PARAM_INT)
->leftJoin('f', 'comments', 'c', $qb->expr()->andX(
$qb->expr()->eq('f.fileid', $qb->expr()->castColumn('c.object_id', IQueryBuilder::PARAM_INT)),
$qb->expr()->eq('c.object_type', $qb->createNamedParameter('files'))
))
->leftJoin('c', 'comments_read_markers', 'm', $qb->expr()->eq(
'c.object_id', 'm.object_id'
->leftJoin('c', 'comments_read_markers', 'm', $qb->expr()->andX(
$qb->expr()->eq('c.object_id', 'm.object_id'),
$qb->expr()->eq('m.object_type', $qb->createNamedParameter('files'))
))
->where(
$qb->expr()->andX(