- Fixed MsSQL entity and searchRequest which caused buggy searchs
This commit is contained in:
parent
1e4a528d39
commit
5d32d9f635
@ -20,8 +20,9 @@ class Table extends \Ulmus\Entity\InformationSchema\Table
|
|||||||
$adapter = Ulmus::$registeredAdapters[$this->loadedFromAdapter];
|
$adapter = Ulmus::$registeredAdapters[$this->loadedFromAdapter];
|
||||||
|
|
||||||
return Column::repository(Repository\MssqlRepository::DEFAULT_ALIAS, $adapter)
|
return Column::repository(Repository\MssqlRepository::DEFAULT_ALIAS, $adapter)
|
||||||
->where(Column::field('tableName'), $this->name )
|
->select('*')
|
||||||
->and(Column::field('tableSchema'), $this->schema )
|
->where('TABLE_NAME', $this->name )
|
||||||
|
->and('TABLE_SCHEMA', $this->schema )
|
||||||
->loadAll();
|
->loadAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
107
src/SearchRequest/DeprecatedSearchRequestFormatTrait.php
Normal file
107
src/SearchRequest/DeprecatedSearchRequestFormatTrait.php
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Ulmus\SearchRequest;
|
||||||
|
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Ulmus\Repository;
|
||||||
|
|
||||||
|
trait DeprecatedSearchRequestFormatTrait
|
||||||
|
{
|
||||||
|
protected array $wheres = [];
|
||||||
|
|
||||||
|
protected array $wheresConditions = [];
|
||||||
|
|
||||||
|
protected array $wheresOperators = [];
|
||||||
|
|
||||||
|
protected array $likes = [];
|
||||||
|
|
||||||
|
protected array $likesOperators = [];
|
||||||
|
|
||||||
|
protected array $likesConditions = [];
|
||||||
|
|
||||||
|
protected array $groups = [];
|
||||||
|
|
||||||
|
protected array $orders = [];
|
||||||
|
|
||||||
|
/* [[ Boilerplates which are ready to be copied */
|
||||||
|
public function wheres() : iterable
|
||||||
|
{
|
||||||
|
return array_filter($this->wheres + [
|
||||||
|
|
||||||
|
], fn($i) => ! is_null($i) ) + [ ];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function wheresConditions() : iterable
|
||||||
|
{
|
||||||
|
return array_filter($this->wheresConditions + [
|
||||||
|
|
||||||
|
], fn($i) => ! is_null($i) ) + [ ];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function wheresOperators() : iterable
|
||||||
|
{
|
||||||
|
return array_filter($this->wheresOperators + [
|
||||||
|
|
||||||
|
], fn($i) => ! is_null($i) ) + [ ];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function likes(): iterable
|
||||||
|
{
|
||||||
|
return array_filter($this->likes + [
|
||||||
|
|
||||||
|
], fn($i) => ! is_null($i) ) + [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function likesConditions() : iterable
|
||||||
|
{
|
||||||
|
return array_filter($this->likesConditions + [
|
||||||
|
|
||||||
|
], fn($i) => ! is_null($i) ) + [ ];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function likesOperators() : iterable
|
||||||
|
{
|
||||||
|
return array_filter($this->likesOperators + [
|
||||||
|
|
||||||
|
], 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 !== "" );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyCount(Repository\RepositoryInterface $repository): SearchRequestInterface
|
||||||
|
{
|
||||||
|
$this->count = $this->filter($repository)
|
||||||
|
->wheres($this->wheres(), $this->wheresOperators(), $this->wheresConditions())
|
||||||
|
->likes($this->likes(), $this->likesConditions())
|
||||||
|
->groups($this->groups())
|
||||||
|
->count();
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function apply(Repository\RepositoryInterface $repository): SearchRequestInterface
|
||||||
|
{
|
||||||
|
$this->filter($repository)
|
||||||
|
->wheres($this->wheres(), $this->wheresOperators(), $this->wheresConditions())
|
||||||
|
->likes($this->likes(), $this->likesConditions())
|
||||||
|
->orders($this->orders())
|
||||||
|
->groups($this->groups())
|
||||||
|
->offset($this->offset())
|
||||||
|
->limit($this->limit());
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
/* ]] */
|
||||||
|
}
|
||||||
@ -5,6 +5,7 @@ namespace Ulmus\SearchRequest;
|
|||||||
use Ulmus\Repository;
|
use Ulmus\Repository;
|
||||||
|
|
||||||
trait SearchRequestPaginationTrait {
|
trait SearchRequestPaginationTrait {
|
||||||
|
use DeprecatedSearchRequestFormatTrait;
|
||||||
|
|
||||||
public int $count = 0;
|
public int $count = 0;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user