Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8eaddbc
feat: track expected output columns in query builder
icewind1991 Jul 31, 2024
b1744e7
fix: don't make ICacheFactory depend on database
icewind1991 Aug 8, 2024
8f57d46
fix: delay calculating global cache prefix untill a cache is created
icewind1991 Aug 20, 2024
4ec53e7
feat: add option to automatically partition queries by specific tables
icewind1991 Jun 13, 2024
82d7eaf
feat: implement distributing partitioned queries over multiple shards
icewind1991 Jul 31, 2024
ecf1cc2
test: mark share test cleanup as running across all shards
icewind1991 Jul 16, 2024
3e51939
fix: only allow pre-defined shards
icewind1991 Jul 18, 2024
22f76fc
test: run sharding tests in ci
icewind1991 Jul 18, 2024
693ee5e
fix: hint storage id in more places
icewind1991 Jul 19, 2024
0e40fa4
fix: run mimetype repair query across all shards
icewind1991 Jul 19, 2024
1b6d76a
test: fix share provider tests for sharding
icewind1991 Jul 19, 2024
5500723
fix: make background scan job compatible with sharding
icewind1991 Jul 25, 2024
ddecae8
fix: adjust systemtag orphan cleanup query to work with sharding
icewind1991 Jul 31, 2024
dc5f0f5
fix: fix share cleanup for deleted groups with sharding
icewind1991 Aug 6, 2024
b264559
fix: implement sharding compatible cleanup for various bits
icewind1991 Aug 15, 2024
57ffbb7
fix: make preload custom proterties sharding compatible
icewind1991 Aug 21, 2024
e2bff39
fix: mark systemconfig value as not being tainted because they are im…
icewind1991 Aug 22, 2024
e5a8f99
chore: Apply php:cs recommendations
artonge Aug 28, 2024
140b36f
fix: Backport to 30
artonge Aug 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: track expected output columns in query builder
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 authored and artonge committed Aug 28, 2024
commit 8eaddbc0380f0b33f099250bd195ffea77b9ed35
4 changes: 4 additions & 0 deletions lib/private/DB/QueryBuilder/ExtendedQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,8 @@ public function executeQuery(?IDBConnection $connection = null): IResult {
public function executeStatement(?IDBConnection $connection = null): int {
return $this->builder->executeStatement($connection);
}

public function getOutputColumns(): array {
return $this->builder->getOutputColumns();
}
}
29 changes: 29 additions & 0 deletions lib/private/DB/QueryBuilder/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class QueryBuilder implements IQueryBuilder {

/** @var string */
protected $lastInsertedTable;
private array $selectedColumns = [];

/**
* Initializes a new QueryBuilder.
Expand Down Expand Up @@ -470,6 +471,7 @@ public function select(...$selects) {
if (count($selects) === 1 && is_array($selects[0])) {
$selects = $selects[0];
}
$this->addOutputColumns($selects);

$this->queryBuilder->select(
$this->helper->quoteColumnNames($selects)
Expand Down Expand Up @@ -497,6 +499,7 @@ public function selectAlias($select, $alias) {
$this->queryBuilder->addSelect(
$this->helper->quoteColumnName($select) . ' AS ' . $this->helper->quoteColumnName($alias)
);
$this->addOutputColumns([$alias]);

return $this;
}
Expand All @@ -518,6 +521,7 @@ public function selectDistinct($select) {
if (!is_array($select)) {
$select = [$select];
}
$this->addOutputColumns($select);

$quotedSelect = $this->helper->quoteColumnNames($select);

Expand Down Expand Up @@ -547,6 +551,7 @@ public function addSelect(...$selects) {
if (count($selects) === 1 && is_array($selects[0])) {
$selects = $selects[0];
}
$this->addOutputColumns($selects);

$this->queryBuilder->addSelect(
$this->helper->quoteColumnNames($selects)
Expand All @@ -555,6 +560,30 @@ public function addSelect(...$selects) {
return $this;
}

private function addOutputColumns(array $columns) {
foreach ($columns as $column) {
if (is_array($column)) {
$this->addOutputColumns($column);
} elseif (is_string($column) && !str_contains($column, '*')) {
if (str_contains($column, '.')) {
[, $column] = explode('.', $column);
}
$this->selectedColumns[] = $column;
}
}
}

public function getOutputColumns(): array {
return array_unique(array_map(function (string $column) {
if (str_contains($column, '.')) {
[, $column] = explode('.', $column);
return $column;
} else {
return $column;
}
}, $this->selectedColumns));
}

/**
* Turns the query being built into a bulk delete query that ranges over
* a certain table.
Expand Down
8 changes: 8 additions & 0 deletions lib/public/DB/QueryBuilder/IQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1018,4 +1018,12 @@ public function getTableName($table);
* @since 9.0.0
*/
public function getColumnName($column, $tableAlias = '');

/**
* Get a list of column names that are expected in the query output
*
* @return array
* @since 30.0.0
*/
public function getOutputColumns(): array;
}