- WIP on search request handling of operators

This commit is contained in:
Dave Mc Nicoll 2025-11-11 18:22:17 +00:00
parent 2271b0b034
commit cb125545c7
6 changed files with 60 additions and 29 deletions

View File

@ -47,7 +47,8 @@ class SqlFieldMapper
break;
case "array":
$this->type = "JSON";
# Was set at JSON, but for now LONGTEXT is an alias of it (with additional constraints)
$this->type = "LONGTEXT";
break;
case "string":

View File

@ -0,0 +1,14 @@
<?php
namespace Ulmus\Entity\Mariadb;
use Ulmus\Attribute\Property\Field;
class Column extends \Ulmus\Entity\Mysql\Column
{
#[Field\Id]
public ? id $srs_id;
#[Field(name: "GENERATION_EXPRESSION", type: "longtext")]
public ? string $generationExpression;
}

View File

@ -6,8 +6,8 @@ use Ulmus\Attribute\Property\Field;
class Column extends \Ulmus\Entity\InformationSchema\Column
{
#[Field\Id]
public ? id $srs_id;
##[Field\Id]
#public ? id $srs_id;
#[Field(name: "COLUMN_KEY", length: 3)]
public string $key;
@ -21,8 +21,8 @@ class Column extends \Ulmus\Entity\InformationSchema\Column
#[Field(name: "COLUMN_COMMENT", length: 1024)]
public string $comment;
#[Field(name: "GENERATION_EXPRESSION", type: "longtext")]
public ? string $generationExpression;
##[Field(name: "GENERATION_EXPRESSION", type: "longtext")]
#public ? string $generationExpression;
# TODO ! Handle FUNCTIONAL default value
protected function canHaveDefaultValue(): bool

View File

@ -14,28 +14,4 @@ class SearchRequest implements SearchRequestInterface
return $repository;
}
public function wheres() : iterable
{
return array_filter($this->wheres + [
], fn($i) => ! is_null($i) ) + [ ];
}
public function likes(): iterable
{
return array_filter($this->likes + [
], fn($i) => ! is_null($i) ) + [];
}
public function groups(): iterable
{
return array_filter($this->groups + [
], fn($e) => ! is_null($e) && $e !== "" );
}
public function orders(): iterable
{
return array_filter($this->orders + [
], fn($e) => ! is_null($e) && $e !== "" );
}
}

View File

@ -199,6 +199,36 @@ trait SearchRequestFromRequestTrait
return $this;
}
/* [[ Boilerplates which are ready to be copied */
public function wheres() : iterable
{
return array_filter($this->wheres + [
], fn($i) => ! is_null($i) ) + [ ];
}
public function likes(): iterable
{
return array_filter($this->likes + [
], fn($i) => ! is_null($i) ) + [];
}
public function groups(): iterable
{
return array_filter($this->groups + [
], fn($e) => ! is_null($e) && $e !== "" );
}
public function orders(): iterable
{
return array_filter($this->orders + [
], fn($e) => ! is_null($e) && $e !== "" );
}
/* ]] */
protected function getValueFromSource(RequestInterface $request, string $propertyName, SearchParameter $attribute) : mixed
{
$queryParamName = $attribute->getParameters() ?: [ $propertyName ];

View File

@ -5,6 +5,16 @@ namespace Ulmus\SearchRequest;
use Ulmus\Repository;
interface SearchRequestInterface {
/* HOW TO IMPLEMENT THIS !!? */
public const SEARCH_REQUEST_OPERATORS = "searchRequest:operators";
public const SEARCH_REQUEST_OPERATOR_EQUAL = "=";
public const SEARCH_REQUEST_OPERATOR_NOT_EQUAL = "!=";
public const SEARCH_REQUEST_OPERATOR_GREATER_THAN = ">";
public const SEARCH_REQUEST_OPERATOR_GREATER_OR_EQUAL_THAN = ">=";
public const SEARCH_REQUEST_OPERATOR_SMALLER_THAN = "<";
public const SEARCH_REQUEST_OPERATOR_SMALLER_OR_EQUAL_THAN = "<=";
public function filter(Repository $repository) : Repository;
public function wheres() : iterable;