clarify entity attr init value, generated insert sql query does not include cols if value is equal to initial attr one

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
This commit is contained in:
Julien Veyssier
2024-09-30 02:28:37 +02:00
parent 5f5611f6e3
commit a54eee7335
5 changed files with 13 additions and 26 deletions

View File

@@ -48,10 +48,10 @@ use OCP\AppFramework\Db\Entity;
* @method void setDeleted(int $deleted) */
class Bill extends Entity implements \JsonSerializable {
protected string $what = '';
protected string $what = '...';
protected ?string $comment = null;
protected int $payerId = 0;
protected float $amount = 0;
protected float $amount = -1;
protected int $timestamp = 0;
protected string $repeat = 'n';
protected int $repeatAllActive = 0;

View File

@@ -13,15 +13,15 @@ use OCP\AppFramework\Db\Entity;
/**
* @method void setProjectId(string $projectId)
* @method string getProjectId()
* @method void setName(string|null $name)
* @method string|null getName()
* @method void setExchangeRate(float|null $exchangeRate)
* @method float|null getExchangeRate()
* @method void setName(string $name)
* @method string getName()
* @method void setExchangeRate(float $exchangeRate)
* @method float getExchangeRate()
*/
class Currency extends Entity implements \JsonSerializable {
protected string $projectId = '';
protected ?string $name = null;
protected ?float $exchangeRate = null;
protected string $name = '';
protected float $exchangeRate = -999;
public function __construct() {
$this->addType('project_id', 'string');

View File

@@ -36,7 +36,7 @@ class Invitation extends Entity implements \JsonSerializable {
protected int $state = self::STATE_PENDING;
protected string $accessToken = '';
protected string $remoteProjectId = '';
protected string $remoteProjectName = '';
protected string $remoteProjectName = '...';
protected string $remoteServerUrl = '';
protected string $inviterCloudId = '';
protected string $inviterDisplayName = '';

View File

@@ -29,8 +29,8 @@ use OCP\IAvatarManager;
* @method void setActivated(int $activated)
* @method int getLastChanged()
* @method void setLastChanged(int $lastChanged)
* @method string getColor()
* @method void setColor(string $color)
* @method string|null getColor()
* @method void setColor(string|null $color)
* @method string|null getUserId()
* @method void setUserId(string|null $userId)
*/
@@ -38,7 +38,7 @@ class Member extends Entity implements \JsonSerializable {
protected string $projectId = '';
protected string $name = '';
protected float $weight = 0;
protected float $weight = -1;
protected int $activated = 1;
protected int $lastChanged = 0;
protected ?string $color = null;

View File

@@ -980,14 +980,7 @@ class LocalProjectService implements IProjectService {
$newBill->setComment($comment);
}
$newBill->setTimestamp($dateTs);
// TODO figure out why it is problematic to insert a bill with an amount of 0
// this does not happen when inserting a currency with a 0 exchange rate
// it is apparently related with the fact that the methods accept null (even if the db column is set to NOTNULL)
if ($amount === 0.0) {
$newBill->setAmount(1);
} else {
$newBill->setAmount($amount);
}
$newBill->setAmount($amount);
$newBill->setPayerId($payer);
$newBill->setRepeat($repeat);
$newBill->setRepeatAllActive($repeatAllActive);
@@ -1003,12 +996,6 @@ class LocalProjectService implements IProjectService {
$insertedBillId = $createdBill->getId();
// TODO remove this after figuring it out
if ($amount === 0.0) {
$createdBill->setAmount(0);
$this->billMapper->update($createdBill);
}
// insert bill owers
foreach ($owerIds as $owerId) {
$billOwer = new BillOwer();