Skip to content

Commit

Permalink
fix: bug in where condition when persisting entity
Browse files Browse the repository at this point in the history
  • Loading branch information
williarin committed Dec 5, 2023
1 parent 1b8e4c6 commit a7466e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Bridge/Repository/AbstractEntityRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function persist(mixed $entity): void
$queryBuilder = $this->entityManager->getConnection()
->createQueryBuilder()
->update($this->entityManager->getTablesPrefix() . static::TABLE_NAME)
->where(static::TABLE_IDENTIFIER, ':' . static::TABLE_IDENTIFIER)
->where(static::TABLE_IDENTIFIER . ' = :' . static::TABLE_IDENTIFIER)
->setParameter(static::TABLE_IDENTIFIER, $entity->{static::TABLE_IDENTIFIER})
;

Expand Down
4 changes: 4 additions & 0 deletions test/Test/Bridge/Repository/PostRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ public function testPersistExistingPost(): void

self::assertSame('Another post with a new title', $post->postTitle);
self::assertSame('publish', $post->postStatus);

// Assert no collateral damages
$anotherPost = $this->repository->find(10);
self::assertSame('A post', $anotherPost->postTitle);
}

public function testDynamicSetter(): void
Expand Down

0 comments on commit a7466e9

Please sign in to comment.