Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
1 change: 1 addition & 0 deletions src/Sql/Platform/Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function getTypeDecorator(
public function getDecorators(): array
{
$platformName = $this->resolvePlatformName($this->getDefaultPlatform());

return $this->decorators[$platformName];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Sql/Platform/PlatformDecoratorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use PhpDb\Sql\PreparableSqlInterface;
use PhpDb\Sql\SqlInterface;

interface PlatformDecoratorInterface
interface PlatformDecoratorInterface extends PreparableSqlInterface, SqlInterface
Comment thread
simon-mundy marked this conversation as resolved.
Outdated
{
public function setSubject(
SqlInterface|PreparableSqlInterface|null $subject
Expand Down
8 changes: 4 additions & 4 deletions src/Sql/Sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class Sql

protected TableIdentifier|string|array|null $table;

protected Platform\Platform $sqlPlatform;
protected Platform\PlatformDecoratorInterface $sqlPlatform;

public function __construct(
AdapterInterface $adapter,
array|string|TableIdentifier|null $table = null
) {
$this->adapter = $adapter;
$this->table = $table;
$this->sqlPlatform = new Platform\Platform($adapter->getPlatform());
$this->adapter = $adapter;
$this->sqlPlatform = $adapter->getPlatform()->getSqlPlatformDecorator();
}

public function getAdapter(): ?AdapterInterface
Expand Down Expand Up @@ -51,7 +51,7 @@ public function getTable(): array|string|TableIdentifier|null
return $this->table;
}

public function getSqlPlatform(): ?Platform\Platform
public function getSqlPlatform(): ?Platform\PlatformDecoratorInterface
{
return $this->sqlPlatform;
}
Expand Down
1 change: 1 addition & 0 deletions test/unit/Sql/AbstractSqlFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ public function test(PreparableSqlInterface|SqlInterface $sqlObject, string $pla

$platform = $sql->getSqlPlatform();
$this->assertNotNull($platform);
$this->assertInstanceOf(Sql\Platform\AbstractPlatform::class, $platform);
$platform->setTypeDecorator($type, $decorator);
}
}
Expand Down
4 changes: 4 additions & 0 deletions test/unit/TableGateway/AbstractTableGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ protected function setUp(): void
$mockResult->expects($this->any())->method('getAffectedRows')->willReturn(5);

$mockPlatform = $this->getMockBuilder(PlatformInterface::class)->getMock();
$mockPlatform->expects($this->any())->method('getName')->willReturn('sql92');
$mockPlatform->expects($this->any())
->method('getSqlPlatformDecorator')
->willReturn(new Sql\Platform\Platform($mockPlatform));

$mockResultSet = $this->getMockBuilder(ResultSetInterface::class)->getMock();

Expand Down