Skip to content

Commit

Permalink
Fix repositories script & remove fetchOne limit
Browse files Browse the repository at this point in the history
  • Loading branch information
iquito committed Apr 28, 2019
1 parent 64d5354 commit 81bb0df
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 97 deletions.
4 changes: 2 additions & 2 deletions bin/squirrel_repositories_generate
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;

foreach ([
__DIR__ . '/../autoload.php',
__DIR__ . '/../../autoload.php',
__DIR__ . '/vendor/autoload.php',
__DIR__ . '/../../../autoload.php',
__DIR__ . '/../vendor/autoload.php',
] as $file) {
if (file_exists($file)) {
/**
Expand Down
88 changes: 0 additions & 88 deletions src/Generate/RepositoriesGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,94 +211,6 @@ public function clear()
$this->iteratorInstance->clear();
}
}
class SelectIterator implements \Squirrel\Entities\Action\ActionInterface, \Iterator
{
/**
* @var \Squirrel\Entities\Action\SelectEntries
*/
private $selectImplementation;
public function __construct(\Squirrel\Entities\RepositoryReadOnlyInterface $repository)
{
$this->selectImplementation = new \Squirrel\Entities\Action\SelectEntries($repository);
}
public function field(string $onlyGetThisField): self
{
$this->selectImplementation->field($onlyGetThisField);
return $this;
}
public function fields(array $onlyGetTheseFields): self
{
$this->selectImplementation->fields($onlyGetTheseFields);
return $this;
}
public function where(array $whereClauses): self
{
$this->selectImplementation->where($whereClauses);
return $this;
}
/**
* @param array|string $orderByClauses
* @return SelectEntries
*/
public function orderBy($orderByClauses): self
{
$this->selectImplementation->orderBy($orderByClauses);
return $this;
}
public function startAt(int $startAtNumber): self
{
$this->selectImplementation->startAt($startAtNumber);
return $this;
}
public function limitTo(int $numberOfEntries): self
{
$this->selectImplementation->limitTo($numberOfEntries);
return $this;
}
public function blocking(bool $active = true): self
{
$this->selectImplementation->blocking($active);
return $this;
}
/**
* @return \{namespaceOfEntity}\{classOfEntity}[]
*/
public function getAllEntries(): array
{
return $this->selectImplementation->getAllEntries();
}
public function getOneEntry(): ?\{namespaceOfEntity}\{classOfEntity}
{
return $this->selectImplementation->getOneEntry();
}
/**
* @return string[]|int[]|float[]|bool[]|null[]
*/
public function getFlattenedFields(): array
{
return $this->selectImplementation->getFlattenedFields();
}
/**
* @return string[]|int[]|float[]|bool[]|null[]
*/
public function getIterator(): array
{
return $this->selectImplementation->getFlattenedFields();
}
}
}

EOD;
Expand Down
6 changes: 1 addition & 5 deletions src/MultiRepositoryReadOnly.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ public function count(array $query): int
}

// Use our internal functions to not repeat ourselves
$selectQuery = $this->select($sanitizedQuery);
$result = $this->fetch($selectQuery);
$this->clear($selectQuery);
$result = $this->fetchOne($sanitizedQuery);

return $result['num'];
}
Expand Down Expand Up @@ -118,8 +116,6 @@ public function fetchOne(array $query): ?array
);
}

$query['limit'] = 1;

// Use our internal functions to not repeat ourselves
$selectQuery = $this->select($query);
$result = $this->fetch($selectQuery);
Expand Down
2 changes: 0 additions & 2 deletions tests/MultiRepositoryReadOnlyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ public function testFetchOne()
'ticket.ticket_id' => [77, 88, 193],
'ticket.ticket_open' => 1,
],
'limit' => 1,
];

// What the database returns
Expand Down Expand Up @@ -433,7 +432,6 @@ public function testFetchOneNoResult()
'ticket.ticket_id' => [77, 88, 193],
'ticket.ticket_open' => 1,
],
'limit' => 1,
];

// What the database returns
Expand Down

0 comments on commit 81bb0df

Please sign in to comment.