From dd3fa45674f380b1771327cdda36e54a91496e1d Mon Sep 17 00:00:00 2001 From: Sascha Nowak Date: Thu, 29 Apr 2021 09:02:04 +0200 Subject: [PATCH] Guaranty order of sequencenumber When not setting the order by the sorting of the query is not always the primary key depending on the order in the index. For me as simple category stream query retuned the following order and thats why the projector not getting all events in the correct order: +--------------+ |sequencenumber| +--------------+ |83 | |63 | |1018 | |209 | |161 | |1 | |71 | |623 | |59 | |67 | |922 | |178 | |225 | +--------------+ --- Classes/EventStore/Storage/Doctrine/DoctrineEventStorage.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Classes/EventStore/Storage/Doctrine/DoctrineEventStorage.php b/Classes/EventStore/Storage/Doctrine/DoctrineEventStorage.php index 05aebff..b85b12d 100644 --- a/Classes/EventStore/Storage/Doctrine/DoctrineEventStorage.php +++ b/Classes/EventStore/Storage/Doctrine/DoctrineEventStorage.php @@ -85,7 +85,8 @@ public function load(StreamName $streamName, int $minimumSequenceNumber = 0): Ev $this->reconnectDatabaseConnection(); $query = $this->connection->createQueryBuilder() ->select('*') - ->from($this->eventTableName); + ->from($this->eventTableName) + ->orderBy('sequencenumber', 'ASC'); if (!$streamName->isVirtualStream()) { $query->andWhere('stream = :streamName');