Skip to content

Commit 466566c

Browse files
committed
Selection: removed create*() methods
1 parent 8ac3980 commit 466566c

3 files changed

Lines changed: 9 additions & 22 deletions

File tree

src/Database/Table/GroupedSelection.php

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

104-
$selection = $this->createSelectionInstance();
104+
$selection = $this->explorer->table($this->name);
105105
$selection->getSqlBuilder()->importConditions($this->getSqlBuilder());
106106

107107
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
@@ -447,7 +447,7 @@ public function alias(string $tableChain, string $alias): static
447447
*/
448448
public function aggregation(string $function, ?string $groupFunction = null): mixed
449449
{
450-
$selection = $this->createSelectionInstance();
450+
$selection = $this->explorer->table($this->name);
451451
$selection->getSqlBuilder()->importConditions($this->getSqlBuilder());
452452
if ($groupFunction && $selection->getSqlBuilder()->importGroupConditions($this->getSqlBuilder())) {
453453
$selection->select("$function AS aggregate");
@@ -536,7 +536,7 @@ protected function execute(): void
536536
$this->rows = [];
537537
$usedPrimary = true;
538538
while ($row = @$result->fetchAssoc()) { // @ may contain duplicate columns
539-
$row = $this->createRow($row);
539+
$row = $this->explorer->createActiveRow($this, $row);
540540
$usedPrimary = $usedPrimary && ($primary = $row->getSignature(throw: false)) !== '';
541541
$this->rows[$usedPrimary ? $primary : $key++] = $row;
542542
}
@@ -551,24 +551,11 @@ protected function execute(): void
551551
}
552552

553553

554-
/** @deprecated */
555-
protected function createRow(array $row): ActiveRow
556-
{
557-
return $this->explorer->createActiveRow($row, $this);
558-
}
559-
560-
561554
/** @deprecated */
562555
public function createSelectionInstance(?string $table = null): self
563556
{
564-
return $this->explorer->table($table ?: $this->name);
565-
}
566-
567-
568-
/** @deprecated */
569-
protected function createGroupedSelectionInstance(string $table, string $column): GroupedSelection
570-
{
571-
return $this->explorer->createGroupedSelection($this, $table, $column);
557+
// DELETE
558+
return $this->explorer->table($table ?? $this->name);
572559
}
573560

574561

@@ -830,7 +817,7 @@ public function insert(iterable $data): ActiveRow|array|int|bool
830817
return $return->getRowCount();
831818
}
832819

833-
$row = $this->createSelectionInstance()
820+
$row = $this->explorer->table($this->name)
834821
->select('*')
835822
->wherePrimary($primaryKey)
836823
->fetch();
@@ -918,7 +905,7 @@ public function getReferencedTable(ActiveRow $row, ?string $table, ?string $colu
918905
}
919906

920907
if ($cacheKeys) {
921-
$selection = $this->createSelectionInstance($table);
908+
$selection = $this->explorer->table($table);
922909
$selection->where($selection->getPrimary(), array_keys($cacheKeys));
923910
} else {
924911
$selection = [];
@@ -951,7 +938,7 @@ public function getReferencingTable(
951938

952939
$prototype = &$this->refCache['referencingPrototype'][$this->getSpecificCacheKey()]["$table.$column"];
953940
if (!$prototype) {
954-
$prototype = $this->createGroupedSelectionInstance($table, $column);
941+
$prototype = $this->explorer->createGroupedSelectionInstance($this, $table, $column);
955942
$prototype->where("$table.$column", array_keys((array) $this->rows));
956943
$prototype->getSpecificCacheKey();
957944
}

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)