- WIP on Migration of MsSQL
This commit is contained in:
1 parent
c54de30069
commit
fb4985160a
17 files changed
+252
-175
No files matched your search
@@ -2,19 +2,35 @@
|
||||
|
||||
namespace Ulmus\Repository;
|
||||
|
||||
use Ulmus\{Repository, Query, Ulmus, Common};
|
||||
use Ulmus\{EntityCollection, Repository, Query, Entity, Ulmus, Common};
|
||||
|
||||
class MssqlRepository extends Repository {
|
||||
|
||||
protected function finalizeQuery() : void
|
||||
{
|
||||
if ( $this->queryBuilder->getFragment(Query\MsSQL\Offset::class) ) {
|
||||
if (null === $order = $this->queryBuilder->getFragment(Query\OrderBy::class)) {
|
||||
$delete = $this->queryBuilder->getFragment(Query\Delete::class);
|
||||
$offset = $this->queryBuilder->getFragment(Query\MsSQL\Offset::class);
|
||||
|
||||
if ($offset) {
|
||||
if ( $delete ) {
|
||||
$delete->top = $offset->limit;
|
||||
|
||||
$this->queryBuilder->removeFragment(Query\MsSQL\Offset::class);
|
||||
}
|
||||
elseif (null === $this->queryBuilder->getFragment(Query\OrderBy::class)) {
|
||||
$this->orderBy("(SELECT 0)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function listColumns(? string $table = null) : EntityCollection
|
||||
{
|
||||
$table ??= $this->entityResolver->tableName();
|
||||
$this->showColumnsSqlQuery($table);
|
||||
|
||||
return $this->collectionFromQuery(Entity\Mssql\Column::class)->iterate(fn($e) => $e->tableName = $table);
|
||||
}
|
||||
|
||||
protected function serverRequestCountRepository() : Repository
|
||||
{
|
||||
return new static($this->entityClass, $this->alias, $this->adapter);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Ulmus\Repository;
|
||||
|
||||
use Ulmus\{ Repository, Query, Ulmus};
|
||||
use Ulmus\{EntityCollection, Repository, Query, Entity, Ulmus};
|
||||
|
||||
class MysqlRepository extends Repository {
|
||||
use JsonConditionTrait;
|
||||
@@ -14,6 +14,14 @@ class MysqlRepository extends Repository {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function listColumns(? string $table = null) : EntityCollection
|
||||
{
|
||||
$table ??= $this->entityResolver->tableName();
|
||||
$this->showColumnsSqlQuery($table);
|
||||
|
||||
return $this->collectionFromQuery(Entity\Mysql\Column::class)->iterate(fn($e) => $e->tableName = $table);
|
||||
}
|
||||
|
||||
public function createSqlQuery() : self
|
||||
{
|
||||
if ( null === $this->queryBuilder->getFragment(Query\Engine::class) ) {
|
||||
|
||||
@@ -262,9 +262,9 @@ class RelationBuilder
|
||||
|
||||
public function oneToMany(string $name, Relation $relation) : Repository
|
||||
{
|
||||
$baseEntity = $relation->entity ?? $this->resolver->reflectedClass->getProperties()[$name]->getTypes()[0]->type;
|
||||
$relation->entity ??= $this->resolver->reflectedClass->getProperties()[$name]->getTypes()[0]->type;
|
||||
|
||||
$this->repository = $baseEntity::repository();
|
||||
$this->repository = $relation->entity::repository();
|
||||
|
||||
$this->applyWhere();
|
||||
|
||||
@@ -281,7 +281,8 @@ class RelationBuilder
|
||||
}
|
||||
|
||||
if (isset($value)) {
|
||||
$this->repository->where( is_object($relation->foreignKey) ? $relation->foreignKey : $baseEntity::field($relation->foreignKey), $value );
|
||||
#$this->repository->where( is_object($relation->foreignKey) ? $relation->foreignKey : $relation->entity::field($relation->foreignKey), $value );
|
||||
$this->repository->where( $relation->foreignKey($this->repository), $value );
|
||||
}
|
||||
else {
|
||||
$this->repository->where(Sql::raw('TRUE'), Sql::raw('FALSE'));
|
||||
|
||||
@@ -27,7 +27,6 @@ class SqliteRepository extends Repository {
|
||||
return $this->collectionFromQuery(Entity\Sqlite\Column::class)->iterate(fn($e) => $e->tableName = $table);
|
||||
}
|
||||
|
||||
|
||||
protected function serverRequestCountRepository() : Repository
|
||||
{
|
||||
return new static($this->entityClass, $this->alias, $this->adapter);
|
||||
|
||||
Reference in new issue
Block a user