Skip to content

Commit

Permalink
Merge pull request #85 from prooph/load_save
Browse files Browse the repository at this point in the history
fix for load/save within same transaction
  • Loading branch information
prolic committed Jun 18, 2017
2 parents b615a0f + a537144 commit 1dc8f35
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -18,7 +18,7 @@
"prefer-stable": true,
"require": {
"php": "^7.1",
"prooph/event-store": "^7.1.0"
"prooph/event-store": "^7.1.1"
},
"require-dev": {
"sandrokeil/interop-config": "^2.0.1",
Expand Down
12 changes: 10 additions & 2 deletions src/PostgresEventStore.php
Expand Up @@ -219,6 +219,16 @@ public function load(
int $count = null,
MetadataMatcher $metadataMatcher = null
): Iterator {
$tableName = $this->persistenceStrategy->generateTableName($streamName);

$query = "SELECT stream_name FROM $this->eventStreamsTable WHERE stream_name = ?";

$statement = $this->connection->prepare($query);
$statement->execute([$tableName]);

if ($statement->rowCount() === 0) {
throw StreamNotFound::with($streamName);
}
[$where, $values] = $this->createWhereClause($metadataMatcher);
$where[] = 'no >= :fromNumber';

Expand All @@ -230,8 +240,6 @@ public function load(
$limit = min($count, $this->loadBatchSize);
}

$tableName = $this->persistenceStrategy->generateTableName($streamName);

$query = <<<EOT
SELECT * FROM $tableName
$whereCondition
Expand Down

0 comments on commit 1dc8f35

Please sign in to comment.