Skip to content

Commit

Permalink
Merge pull request #46644 from nextcloud/cast-bigint
Browse files Browse the repository at this point in the history
fix: cast to bigint on postgresql
  • Loading branch information
susnux authored Jul 24, 2024
2 parents 2ddfbf3 + 5ea9729 commit 57ed738
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PgSqlExpressionBuilder extends ExpressionBuilder {
public function castColumn($column, $type): IQueryFunction {
switch ($type) {
case IQueryBuilder::PARAM_INT:
return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS INT)');
return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS BIGINT)');
case IQueryBuilder::PARAM_STR:
return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS TEXT)');
default:
Expand Down
2 changes: 2 additions & 0 deletions lib/private/Preview/BackgroundCleanupJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ private function getOldPreviewLocations(): \Iterator {
))
->where(
$qb->expr()->isNull('b.fileid')
)->andWhere(
$qb->expr()->eq('a.storage', $qb->createNamedParameter($this->previewFolder->getStorageId()))
)->andWhere(
$qb->expr()->eq('a.parent', $qb->createNamedParameter($this->previewFolder->getId()))
)->andWhere(
Expand Down
4 changes: 3 additions & 1 deletion tests/lib/Preview/BackgroundCleanupJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,11 @@ public function testOldPreviews() {
$f1->newFile('foo.jpg', 'foo');
$f2 = $appdata->newFolder('123456782');
$f2->newFile('foo.jpg', 'foo');
$f2 = $appdata->newFolder((string)PHP_INT_MAX - 1);
$f2->newFile('foo.jpg', 'foo');

$appdata = \OC::$server->getAppDataDir('preview');
$this->assertSame(2, count($appdata->getDirectoryListing()));
$this->assertSame(3, count($appdata->getDirectoryListing()));

$job = new BackgroundCleanupJob($this->timeFactory, $this->connection, $this->getRoot(), $this->mimeTypeLoader, true);
$job->run([]);
Expand Down

0 comments on commit 57ed738

Please sign in to comment.