Skip to content

Commit

Permalink
Merge pull request #48089 from nextcloud/backport/48008/stable28
Browse files Browse the repository at this point in the history
  • Loading branch information
provokateurin committed Sep 16, 2024
2 parents b968029 + 1b5a56d commit c10a980
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 2 additions & 3 deletions lib/public/AppFramework/Db/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ public static function fromRow(array $row): static {
$instance = new static();

foreach ($row as $key => $value) {
$prop = ucfirst($instance->columnToProperty($key));
$setter = 'set' . $prop;
$instance->$setter($value);
$prop = $instance->columnToProperty($key);
$instance->setter($prop, [$value]);
}

$instance->resetUpdatedFields();
Expand Down
9 changes: 7 additions & 2 deletions tests/lib/AppFramework/Db/EntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
* @method void setTrueOrFalse(bool $trueOrFalse)
* @method bool getAnotherBool()
* @method bool isAnotherBool()
* @method void setAnotherBool(bool $anotherBool)
* @method string getLongText()
* @method void setLongText(string $longText)
*/
Expand All @@ -62,6 +61,10 @@ public function __construct($name = null) {
$this->addType('longText', 'blob');
$this->name = $name;
}

public function setAnotherBool(bool $anotherBool): void {
parent::setAnotherBool($anotherBool);
}
}


Expand All @@ -86,12 +89,14 @@ public function testResetUpdatedFields() {
public function testFromRow() {
$row = [
'pre_name' => 'john',
'email' => 'john@something.com'
'email' => 'john@something.com',
'another_bool' => 1,
];
$this->entity = TestEntity::fromRow($row);

$this->assertEquals($row['pre_name'], $this->entity->getPreName());
$this->assertEquals($row['email'], $this->entity->getEmail());
$this->assertEquals($row['another_bool'], $this->entity->getAnotherBool());
}


Expand Down

0 comments on commit c10a980

Please sign in to comment.