Skip to content

Commit 9dc391a

Browse files
committed
Selection: removed create*() methods
1 parent 7896ee0 commit 9dc391a

File tree

3 files changed

+9
-22
lines changed

3 files changed

+9
-22
lines changed

src/Database/Table/GroupedSelection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function aggregation(string $function, ?string $groupFunction = null): mi
9595
if ($aggregation === null) {
9696
$aggregation = [];
9797

98-
$selection = $this->createSelectionInstance();
98+
$selection = $this->explorer->table($this->name);
9999
$selection->getSqlBuilder()->importConditions($this->getSqlBuilder());
100100

101101
if ($groupFunction && $selection->getSqlBuilder()->importGroupConditions($this->getSqlBuilder())) {

src/Database/Table/Selection.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ public function alias(string $tableChain, string $alias): static
453453
*/
454454
public function aggregation(string $function, ?string $groupFunction = null): mixed
455455
{
456-
$selection = $this->createSelectionInstance();
456+
$selection = $this->explorer->table($this->name);
457457
$selection->getSqlBuilder()->importConditions($this->getSqlBuilder());
458458
if ($groupFunction && $selection->getSqlBuilder()->importGroupConditions($this->getSqlBuilder())) {
459459
$selection->select("$function AS aggregate");
@@ -542,7 +542,7 @@ protected function execute(): void
542542
$this->rows = [];
543543
$usedPrimary = true;
544544
while ($row = @$result->fetchAssoc()) { // @ may contain duplicate columns
545-
$row = $this->createRow($row);
545+
$row = $this->explorer->createActiveRow($this, $row);
546546
$usedPrimary = $usedPrimary && ($primary = $row->getSignature(throw: false)) !== '';
547547
$this->rows[$usedPrimary ? $primary : $key++] = $row;
548548
}
@@ -557,24 +557,11 @@ protected function execute(): void
557557
}
558558

559559

560-
/** @deprecated */
561-
protected function createRow(array $row): ActiveRow
562-
{
563-
return $this->explorer->createActiveRow($row, $this);
564-
}
565-
566-
567560
/** @deprecated */
568561
public function createSelectionInstance(?string $table = null): self
569562
{
570-
return $this->explorer->table($table ?: $this->name);
571-
}
572-
573-
574-
/** @deprecated */
575-
protected function createGroupedSelectionInstance(string $table, string $column): GroupedSelection
576-
{
577-
return $this->explorer->createGroupedSelection($this, $table, $column);
563+
// DELETE
564+
return $this->explorer->table($table ?? $this->name);
578565
}
579566

580567

@@ -835,7 +822,7 @@ public function insert(iterable $data): ActiveRow|array|int|bool
835822
return $return->getRowCount();
836823
}
837824

838-
$row = $this->createSelectionInstance()
825+
$row = $this->explorer->table($this->name)
839826
->select('*')
840827
->wherePrimary($primaryKey)
841828
->fetch();
@@ -924,7 +911,7 @@ public function getReferencedTable(ActiveRow $row, ?string $table, ?string $colu
924911
}
925912

926913
if ($cacheKeys) {
927-
$selection = $this->createSelectionInstance($table);
914+
$selection = $this->explorer->table($table);
928915
$selection->where($selection->getPrimary(), array_keys($cacheKeys));
929916
} else {
930917
$selection = [];
@@ -957,7 +944,7 @@ public function getReferencingTable(
957944

958945
$prototype = &$this->refCache['referencingPrototype'][$this->getSpecificCacheKey()]["$table.$column"];
959946
if (!$prototype) {
960-
$prototype = $this->createGroupedSelectionInstance($table, $column);
947+
$prototype = $this->explorer->createGroupedSelectionInstance($this, $table, $column);
961948
$prototype->where("$table.$column", array_keys((array) $this->rows));
962949
$prototype->getSpecificCacheKey();
963950
}

tests/Database/Explorer/bugs/deleteCacheBug.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test('', function () use ($explorer) {
4040
$book->id;
4141

4242
if ($i === 1) {
43-
$book->getTable()->createSelectionInstance()
43+
$explorer->table('book')
4444
->wherePrimary($book->id)
4545
->delete();
4646

0 commit comments

Comments
 (0)