Skip to content

Commit 2aed9dc

Browse files
committed
fix getAttributeProjection
1 parent 7849c6c commit 2aed9dc

File tree

3 files changed

+9
-46
lines changed

3 files changed

+9
-46
lines changed

src/Database/Adapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,9 +1153,9 @@ abstract public function getKeywords(): array;
11531153
*
11541154
* @param array<string> $selections
11551155
* @param string $prefix
1156-
* @return mixed
1156+
* @return string
11571157
*/
1158-
abstract protected function getAttributeProjection(array $selections, string $prefix): mixed;
1158+
abstract protected function getAttributeProjection(array $selections, string $prefix): string;
11591159

11601160
/**
11611161
* Get all selected attributes from queries

src/Database/Adapter/Pool.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -470,13 +470,7 @@ public function getKeywords(): array
470470
return $this->delegate(__FUNCTION__, \func_get_args());
471471
}
472472

473-
/**
474-
* @param array<string,mixed> $selections
475-
* @param string $prefix
476-
* @param array<string,mixed> $spatialAttributes
477-
* @return mixed
478-
*/
479-
protected function getAttributeProjection(array $selections, string $prefix, array $spatialAttributes = []): mixed
473+
protected function getAttributeProjection(array $selections, string $prefix): string
480474
{
481475
return $this->delegate(__FUNCTION__, \func_get_args());
482476
}

src/Database/Adapter/SQL.php

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ public function deleteAttribute(string $collection, string $id, bool $array = fa
350350
*/
351351
public function getDocument(Document $collection, string $id, array $queries = [], bool $forUpdate = false): Document
352352
{
353-
$spatialAttributes = $this->getSpatialAttributes($collection);
354353
$collection = $collection->getId();
355354

356355
$name = $this->filter($collection);
@@ -359,9 +358,9 @@ public function getDocument(Document $collection, string $id, array $queries = [
359358
$forUpdate = $forUpdate ? 'FOR UPDATE' : '';
360359

361360
$alias = Query::DEFAULT_ALIAS;
362-
$spatialAttributes = [];
361+
363362
$sql = "
364-
SELECT {$this->getAttributeProjection($selections, $alias, $spatialAttributes)}
363+
SELECT {$this->getAttributeProjection($selections, $alias)}
365364
FROM {$this->getSQLTable($name)} AS {$this->quote($alias)}
366365
WHERE {$this->quote($alias)}.{$this->quote('_uid')} = :_uid
367366
{$this->getTenantQuery($collection, $alias)}
@@ -1877,37 +1876,13 @@ public function getTenantQuery(
18771876
*
18781877
* @param array<string> $selections
18791878
* @param string $prefix
1880-
* @param array<string> $spatialAttributes
1881-
* @return mixed
1879+
* @return string
18821880
* @throws Exception
18831881
*/
1884-
protected function getAttributeProjection(array $selections, string $prefix, array $spatialAttributes = []): mixed
1882+
protected function getAttributeProjection(array $selections, string $prefix): string
18851883
{
18861884
if (empty($selections) || \in_array('*', $selections)) {
1887-
if (empty($spatialAttributes)) {
1888-
return "{$this->quote($prefix)}.*";
1889-
}
1890-
1891-
$projections = [];
1892-
$projections[] = "{$this->quote($prefix)}.*";
1893-
1894-
$internalColumns = ['_id', '_uid', '_createdAt', '_updatedAt', '_permissions'];
1895-
if ($this->sharedTables) {
1896-
$internalColumns[] = '_tenant';
1897-
}
1898-
foreach ($internalColumns as $col) {
1899-
$projections[] = "{$this->quote($prefix)}.{$this->quote($col)}";
1900-
}
1901-
1902-
foreach ($spatialAttributes as $spatialAttr) {
1903-
$filteredAttr = $this->filter($spatialAttr);
1904-
$quotedAttr = $this->quote($filteredAttr);
1905-
$axisOrder = $this->getSupportForSpatialAxisOrder() ? ', ' . $this->getSpatialAxisOrderSpec() : '';
1906-
$projections[] = "ST_AsText({$this->quote($prefix)}.{$quotedAttr} {$axisOrder} ) AS {$quotedAttr}";
1907-
}
1908-
1909-
1910-
return implode(', ', $projections);
1885+
return "{$this->quote($prefix)}.*";
19111886
}
19121887

19131888
// Handle specific selections with spatial conversion where needed
@@ -1929,13 +1904,7 @@ protected function getAttributeProjection(array $selections, string $prefix, arr
19291904
foreach ($selections as $selection) {
19301905
$filteredSelection = $this->filter($selection);
19311906
$quotedSelection = $this->quote($filteredSelection);
1932-
1933-
if (in_array($selection, $spatialAttributes)) {
1934-
$axisOrder = $this->getSupportForSpatialAxisOrder() ? ', ' . $this->getSpatialAxisOrderSpec() : '';
1935-
$projections[] = "ST_AsText({$this->quote($prefix)}.{$quotedSelection} {$axisOrder}) AS {$quotedSelection}";
1936-
} else {
1937-
$projections[] = "{$this->quote($prefix)}.{$quotedSelection}";
1938-
}
1907+
$projections[] = "{$this->quote($prefix)}.{$quotedSelection}";
19391908
}
19401909

19411910
return \implode(',', $projections);

0 commit comments

Comments
 (0)