@@ -337,11 +337,13 @@ public function getDocument(string $collection, string $id, array $queries = [],
337337
338338 $ forUpdate = $ forUpdate ? 'FOR UPDATE ' : '' ;
339339
340+ $ alias = Query::DEFAULT_ALIAS ;
341+
340342 $ sql = "
341- SELECT {$ this ->getAttributeProjection ($ selections )}
342- FROM {$ this ->getSQLTable ($ name )}
343- WHERE _uid = :_uid
344- {$ this ->getTenantQuery ($ collection )}
343+ SELECT {$ this ->getAttributeProjection ($ selections, $ alias )}
344+ FROM {$ this ->getSQLTable ($ name )} AS { $ this -> quote ( $ alias )}
345+ WHERE { $ this -> quote ( $ alias )} . { $ this -> quote ( ' _uid ' )} = :_uid
346+ {$ this ->getTenantQuery ($ collection, $ alias )}
345347 " ;
346348
347349 if ($ this ->getSupportForUpdateLock ()) {
@@ -1680,13 +1682,10 @@ public function getTenantQuery(
16801682 * @return mixed
16811683 * @throws Exception
16821684 */
1683- protected function getAttributeProjection (array $ selections , string $ prefix = '' ): mixed
1685+ protected function getAttributeProjection (array $ selections , string $ prefix ): mixed
16841686 {
16851687 if (empty ($ selections ) || \in_array ('* ' , $ selections )) {
1686- if (!empty ($ prefix )) {
1687- return "{$ this ->quote ($ prefix )}.* " ;
1688- }
1689- return '* ' ;
1688+ return "{$ this ->quote ($ prefix )}.* " ;
16901689 }
16911690
16921691 $ internalKeys = [
@@ -1703,14 +1702,8 @@ protected function getAttributeProjection(array $selections, string $prefix = ''
17031702 $ selections [] = $ this ->getInternalKeyForAttribute ($ internalKey );
17041703 }
17051704
1706- if (!empty ($ prefix )) {
1707- foreach ($ selections as &$ selection ) {
1708- $ selection = "{$ this ->quote ($ prefix )}. {$ this ->quote ($ this ->filter ($ selection ))}" ;
1709- }
1710- } else {
1711- foreach ($ selections as &$ selection ) {
1712- $ selection = "{$ this ->quote ($ this ->filter ($ selection ))}" ;
1713- }
1705+ foreach ($ selections as &$ selection ) {
1706+ $ selection = "{$ this ->quote ($ prefix )}. {$ this ->quote ($ this ->filter ($ selection ))}" ;
17141707 }
17151708
17161709 return \implode (', ' , $ selections );
0 commit comments