Skip to content

Commit

Permalink
Make sure identifer column always has the empty value doctrine expects
Browse files Browse the repository at this point in the history
  • Loading branch information
flack committed Jun 13, 2024
1 parent d1d0552 commit 5134540
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/api/dbobject.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public function __set($field, $value)
$value = (string) $value;
} elseif ($mapping['type'] === 'integer') {
$value = (int) $value;
if ($value === 0 && $this->cm->isIdentifier($field)) {
$value = null;
}
} elseif ($mapping['type'] === 'boolean') {
$value = (boolean) $value;
} elseif ($mapping['type'] === 'float') {
Expand Down
1 change: 1 addition & 0 deletions test/api/mgdobjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ public function test_create()
$this->assertEquals($topic->id + 1, $topic2->id);

$topic3 = $this->make_object('midgard_topic');
$topic3->id = 0;
$topic3->up = $topic->id;
$topic3->name = __FUNCTION__ . '-3';
$stat = $topic3->create();
Expand Down

0 comments on commit 5134540

Please sign in to comment.