- 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; break;
case "array": 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; break;
case "string": 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 class Column extends \Ulmus\Entity\InformationSchema\Column
{ {
#[Field\Id] ##[Field\Id]
public ? id $srs_id; #public ? id $srs_id;
#[Field(name: "COLUMN_KEY", length: 3)] #[Field(name: "COLUMN_KEY", length: 3)]
public string $key; public string $key;
@ -21,8 +21,8 @@ class Column extends \Ulmus\Entity\InformationSchema\Column
#[Field(name: "COLUMN_COMMENT", length: 1024)] #[Field(name: "COLUMN_COMMENT", length: 1024)]
public string $comment; public string $comment;
#[Field(name: "GENERATION_EXPRESSION", type: "longtext")] ##[Field(name: "GENERATION_EXPRESSION", type: "longtext")]
public ? string $generationExpression; #public ? string $generationExpression;
# TODO ! Handle FUNCTIONAL default value # TODO ! Handle FUNCTIONAL default value
protected function canHaveDefaultValue(): bool protected function canHaveDefaultValue(): bool

View File

@ -14,28 +14,4 @@ class SearchRequest implements SearchRequestInterface
return $repository; 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; 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 protected function getValueFromSource(RequestInterface $request, string $propertyName, SearchParameter $attribute) : mixed
{ {
$queryParamName = $attribute->getParameters() ?: [ $propertyName ]; $queryParamName = $attribute->getParameters() ?: [ $propertyName ];

View File

@ -5,6 +5,16 @@ namespace Ulmus\SearchRequest;
use Ulmus\Repository; use Ulmus\Repository;
interface SearchRequestInterface { 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 filter(Repository $repository) : Repository;
public function wheres() : iterable; public function wheres() : iterable;