]> source.dussan.org Git - nextcloud-server.git/commitdiff
Quote aliases as well
authorJoas Schilling <coding@schilljs.com>
Thu, 20 Jul 2017 18:14:31 +0000 (20:14 +0200)
committerJoas Schilling <coding@schilljs.com>
Thu, 3 Aug 2017 14:39:21 +0000 (16:39 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/DB/QueryBuilder/QueryBuilder.php
lib/private/DB/QueryBuilder/QuoteHelper.php

index eac13b452ac0a948dd220501f53a42d4495754b1..99109c6a51b3cdc9076befcf507d598946ca707f 100644 (file)
@@ -560,7 +560,7 @@ class QueryBuilder implements IQueryBuilder {
        public function from($from, $alias = null) {
                $this->queryBuilder->from(
                        $this->getTableName($from),
-                       $alias
+                       $this->quoteAlias($alias)
                );
 
                return $this;
@@ -585,9 +585,9 @@ class QueryBuilder implements IQueryBuilder {
         */
        public function join($fromAlias, $join, $alias, $condition = null) {
                $this->queryBuilder->join(
-                       $fromAlias,
+                       $this->quoteAlias($fromAlias),
                        $this->getTableName($join),
-                       $alias,
+                       $this->quoteAlias($alias),
                        $condition
                );
 
@@ -613,9 +613,9 @@ class QueryBuilder implements IQueryBuilder {
         */
        public function innerJoin($fromAlias, $join, $alias, $condition = null) {
                $this->queryBuilder->innerJoin(
-                       $fromAlias,
+                       $this->quoteAlias($fromAlias),
                        $this->getTableName($join),
-                       $alias,
+                       $this->quoteAlias($alias),
                        $condition
                );
 
@@ -641,9 +641,9 @@ class QueryBuilder implements IQueryBuilder {
         */
        public function leftJoin($fromAlias, $join, $alias, $condition = null) {
                $this->queryBuilder->leftJoin(
-                       $fromAlias,
+                       $this->quoteAlias($fromAlias),
                        $this->getTableName($join),
-                       $alias,
+                       $this->quoteAlias($alias),
                        $condition
                );
 
@@ -669,9 +669,9 @@ class QueryBuilder implements IQueryBuilder {
         */
        public function rightJoin($fromAlias, $join, $alias, $condition = null) {
                $this->queryBuilder->rightJoin(
-                       $fromAlias,
+                       $this->quoteAlias($fromAlias),
                        $this->getTableName($join),
-                       $alias,
+                       $this->quoteAlias($alias),
                        $condition
                );
 
@@ -1193,4 +1193,18 @@ class QueryBuilder implements IQueryBuilder {
 
                return $this->helper->quoteColumnName($tableAlias . $column);
        }
+
+       /**
+        * Returns the column name quoted and with table alias prefix as needed by the implementation
+        *
+        * @param string $alias
+        * @return string
+        */
+       public function quoteAlias($alias) {
+               if ($alias === '' || $alias === null) {
+                       return $alias;
+               }
+
+               return $this->helper->quoteColumnName($alias);
+       }
 }
index 705c3a89712aa443e8d84ee0dd9bd96e0117d7f2..8821863ed07f173a9309af8d862073a3ef8142f2 100644 (file)
@@ -70,7 +70,7 @@ class QuoteHelper {
                        list($alias, $columnName) = explode('.', $string, 2);
 
                        if ($columnName === '*') {
-                               return $string;
+                               return '`' . $alias . '`.*';
                        }
 
                        return '`' . $alias . '`.`' . $columnName . '`';