bugfix
This commit is contained in:
parent
4c51403daa
commit
05fd209204
@ -77,7 +77,12 @@ class Parameter {
|
||||
public function getTypeName(): string {
|
||||
$typeName = Parameter::names[$this->type] ?? "INVALID";
|
||||
if ($this->choices) {
|
||||
$typeName .= ", choices: " . json_encode($this->choices);
|
||||
$typeName .= ", choices=" . json_encode($this->choices);
|
||||
}
|
||||
|
||||
$format = $this->getSwaggerFormat();
|
||||
if ($format && $this->type !== self::TYPE_EMAIL) {
|
||||
$typeName .= ", format='$format'";
|
||||
}
|
||||
|
||||
return $typeName;
|
||||
|
@ -12,7 +12,8 @@ use Core\Objects\DatabaseEntity\User;
|
||||
|
||||
trait Pagination {
|
||||
|
||||
static function getPaginationParameters(array $orderColumns, string $defaultOrderBy = "id", string $defaultSortOrder = "asc"): array {
|
||||
function getPaginationParameters(array $orderColumns, string $defaultOrderBy = "id", string $defaultSortOrder = "asc"): array {
|
||||
$this->paginationOrderColumns = $orderColumns;
|
||||
return [
|
||||
'page' => new Parameter('page', Parameter::TYPE_INT, true, 1),
|
||||
'count' => new Parameter('count', Parameter::TYPE_INT, true, 20),
|
||||
|
25
Core/Driver/SQL/Expression/Coalesce.class.php
Normal file
25
Core/Driver/SQL/Expression/Coalesce.class.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Core\Driver\SQL\Expression;
|
||||
|
||||
use Core\Driver\SQL\SQL;
|
||||
|
||||
class Coalesce extends Expression {
|
||||
|
||||
private array $values;
|
||||
|
||||
public function __construct(mixed ...$values) {
|
||||
$this->values = $values;
|
||||
}
|
||||
|
||||
function getExpression(SQL $sql, array &$params): string {
|
||||
$values = implode(",", array_map(function ($value) use ($sql, &$params) {
|
||||
if (is_string($value)) {
|
||||
return $sql->columnName($value);
|
||||
} else {
|
||||
return $sql->addValue($value, $params);
|
||||
}
|
||||
}, $this->values));
|
||||
return "COALESCE($values)";
|
||||
}
|
||||
}
|
22
Core/Driver/SQL/Expression/NullIf.class.php
Normal file
22
Core/Driver/SQL/Expression/NullIf.class.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Core\Driver\SQL\Expression;
|
||||
|
||||
use Core\Driver\SQL\SQL;
|
||||
|
||||
class NullIf extends Expression {
|
||||
|
||||
private mixed $lhs;
|
||||
private mixed $rhs;
|
||||
|
||||
public function __construct(mixed $lhs, mixed $rhs) {
|
||||
$this->lhs = $lhs;
|
||||
$this->rhs = $rhs;
|
||||
}
|
||||
|
||||
function getExpression(SQL $sql, array &$params): string {
|
||||
$lhs = $sql->addValue($this->lhs, $params);
|
||||
$rhs = $sql->addValue($this->rhs, $params);
|
||||
return "NULLIF($lhs, $rhs)";
|
||||
}
|
||||
}
|
@ -109,7 +109,7 @@ abstract class DatabaseEntity implements ArrayAccess, JsonSerializable {
|
||||
}
|
||||
}
|
||||
|
||||
if ($propertyNames === null) {
|
||||
if ($propertyNames === null && !empty($this->customData)) {
|
||||
$jsonArray = array_merge($jsonArray, $this->customData);
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,9 @@ class DatabaseEntityHandler implements Persistable {
|
||||
}
|
||||
|
||||
public function init() {
|
||||
$className = $this->entityClass->getName();
|
||||
|
||||
|
||||
$uniqueColumns = self::getAttribute($this->entityClass, Unique::class);
|
||||
if ($uniqueColumns) {
|
||||
$this->constraints[] = new \Core\Driver\SQL\Constraint\Unique($uniqueColumns->getColumns());
|
||||
|
@ -58,9 +58,9 @@ class NMRelation implements Persistable {
|
||||
|
||||
public function getOtherHandler(DatabaseEntityHandler $handler): DatabaseEntityHandler {
|
||||
if ($handler === $this->thisHandler) {
|
||||
return $this->thisHandler;
|
||||
} else {
|
||||
return $this->otherHandler;
|
||||
} else {
|
||||
return $this->thisHandler;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user