Skip to content

Commit f8c64a1

Browse files
Merge pull request #53427 from nextcloud/shard-key-hint-partition
fix: allow hinting the shard keys for joined tables
2 parents acc2311 + 2690392 commit f8c64a1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/private/DB/QueryBuilder/Partitioned/PartitionedQueryBuilder.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,4 +444,19 @@ public function getSQL() {
444444
public function getPartitionCount(): int {
445445
return count($this->splitQueries) + 1;
446446
}
447+
448+
public function hintShardKey(string $column, mixed $value, bool $overwrite = false): self {
449+
if (str_contains($column, '.')) {
450+
[$alias, $column] = explode('.', $column);
451+
$partition = $this->getPartition($alias);
452+
if ($partition) {
453+
$this->splitQueries[$partition->name]->query->hintShardKey($column, $value, $overwrite);
454+
} else {
455+
parent::hintShardKey($column, $value, $overwrite);
456+
}
457+
} else {
458+
parent::hintShardKey($column, $value, $overwrite);
459+
}
460+
return $this;
461+
}
447462
}

0 commit comments

Comments
 (0)