Skip to content

Commit

Permalink
Fix DoctrineSubscriptionStore compatibility with SQLite and PostgreSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
bwaidelich committed Dec 10, 2024
1 parent caa70bf commit 79d4ec7
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use DateTimeImmutable;
use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Schema;
Expand Down Expand Up @@ -44,11 +45,11 @@ public function setup(): void
'charset' => 'utf8mb4'
]);
$tableSchema = new Table($this->tableName, [
(new Column('id', Type::getType(Types::STRING)))->setNotnull(true)->setLength(SubscriptionId::MAX_LENGTH)->setPlatformOption('charset', 'ascii')->setPlatformOption('collation', 'ascii_general_ci'),
(new Column('id', Type::getType(Types::STRING)))->setNotnull(true)->setLength(SubscriptionId::MAX_LENGTH),
(new Column('position', Type::getType(Types::INTEGER)))->setNotnull(true),
(new Column('status', Type::getType(Types::STRING)))->setNotnull(true)->setLength(32)->setPlatformOption('charset', 'ascii')->setPlatformOption('collation', 'ascii_general_ci'),
(new Column('status', Type::getType(Types::STRING)))->setNotnull(true)->setLength(32),
(new Column('error_message', Type::getType(Types::TEXT)))->setNotnull(false),
(new Column('error_previous_status', Type::getType(Types::STRING)))->setNotnull(false)->setLength(32)->setPlatformOption('charset', 'ascii')->setPlatformOption('collation', 'ascii_general_ci'),
(new Column('error_previous_status', Type::getType(Types::STRING)))->setNotnull(false)->setLength(32),
(new Column('error_trace', Type::getType(Types::TEXT)))->setNotnull(false),
(new Column('last_saved_at', Type::getType(Types::DATETIME_IMMUTABLE)))->setNotnull(true),
]);
Expand All @@ -70,7 +71,9 @@ public function findByCriteriaForUpdate(SubscriptionCriteria $criteria): Subscri
->select('*')
->from($this->tableName)
->orderBy('id');
$queryBuilder->forUpdate();
if (!$this->dbal->getDatabasePlatform() instanceof SqlitePlatform) {
$queryBuilder->forUpdate();
}
if ($criteria->ids !== null) {
$queryBuilder->andWhere('id IN (:ids)')
->setParameter(
Expand Down

0 comments on commit 79d4ec7

Please sign in to comment.