After upgrading to Nextcloud 34.0.3.2, Preview Generator background jobs and manual preview generation fail with:SQLSTATE\\\[23000\\\]: Integrity constraint violation:
1052 Column ‘file_id’ in WHERE is ambiguous
Env:
Nextcloud: 34.0.3.2
Database: MariaDB
PHP: 8.5
Preview Generator app: 5.14.0
Affected commands:
Manual:
sudo -u www-data php /var/www/nextcloud/occ preview:pre-generate -vvv
Cron:
php -d memory_limit=2G /var/www/nextcloud/occ preview:pre-generate
Background job:
OCA\PreviewGenerator\BackgroundJob\PreviewJob
Actual result:
Generating previews for/XXXXX/files/SofortUpload/WhatsApp Images/2025/06/IMG-20250601-WA0024.jpg
SQLSTATE[23000]:
Integrity constraint violation:
1052 Column ‘file_id’ in WHERE is ambiguous
Log output:
OC\Preview\Db\PreviewMapper->getPreviewForSpecification()/var/www/nextcloud/lib/private/Preview/Db/PreviewMapper.php:250
Stack trace:
OC\Preview\Db\PreviewMapper->getPreviewForSpecification()
OC\Preview\Generator->savePreview()
OC\Preview\Generator->generatePreview()
OC\PreviewManager->generatePreviews()
OCA\PreviewGenerator\Service\PreGenerateService->processFile()
OCA\PreviewGenerator\Service\PreGenerateService->preGenerate()
OCA\PreviewGenerator\BackgroundJob\PreviewJob->run()
Exeption:
Doctrine\DBAL\Exception\NonUniqueFieldNameException
SQLSTATE[23000]:
Integrity constraint violation:
1052 Column ‘file_id’ in WHERE is ambiguous
The problem appears to originate from a query generated in:
lib/private/Preview/Db/PreviewMapper.php
specifically inside:
PreviewMapper::getPreviewForSpecification()
where an unqualified file_id column is used in a query containing joins with multiple tables exposing the same column name.