Skip to content

Commit

Permalink
fix tuple changes calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
nekufa committed May 4, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 9f7edc7 commit 87cca4e
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Entity.php
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ public function getTupleChanges()
{
$changes = [];
foreach ($this->toTuple() as $k => $v) {
if (!array_key_exists($k, $this->originalTuple) || $this->originalTuple[$k] != $v) {
if (!array_key_exists($k, $this->originalTuple) || $this->originalTuple[$k] !== $v) {
$changes[$k] = $v;
}
}
23 changes: 23 additions & 0 deletions tests/MapperTest.php
Original file line number Diff line number Diff line change
@@ -17,6 +17,29 @@

class MapperTest extends TestCase
{
public function testEmptyStringPersistence()
{
$mapper = $this->createMapper();
$space = $mapper->getSchema()->createSpace('actor', [
'id' => 'integer',
'note' => 'string'
])->addIndex('id');

$this->assertTrue($space->getProperty('note')->isNullable);
$actor = $mapper->create('actor', ['id' => 1]);
$this->assertNull($actor->note);

$actor = $mapper->findOrFail('actor', $actor->id);
$this->assertNull($actor->note);
$this->assertCount(0, $actor->getTupleChanges());
$actor->note = "";
$this->assertCount(1, $actor->getTupleChanges());
$actor->save();

$actor = $mapper->findOrFail('actor', $actor->id);
$this->assertSame("", $actor->note);
}

public function testTupleGetterAfterCleanup()
{
$mapper = $this->createMapper();

0 comments on commit 87cca4e

Please sign in to comment.