diff options
author | Joas Schilling <coding@schilljs.com> | 2017-07-20 20:14:31 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-08-02 09:48:15 +0200 |
commit | 8ec6c1f259147e5b9c065b1be4ad3c794d32e381 (patch) | |
tree | 40287018a6209d8079d7acb771acf1f2963ac9e5 /lib/private/DB/QueryBuilder | |
parent | b29baababdbc56b1633eca2d8357dd6b87268050 (diff) | |
download | nextcloud-server-8ec6c1f259147e5b9c065b1be4ad3c794d32e381.tar.gz nextcloud-server-8ec6c1f259147e5b9c065b1be4ad3c794d32e381.zip |
Quote aliases as well
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/DB/QueryBuilder')
-rw-r--r-- | lib/private/DB/QueryBuilder/QueryBuilder.php | 32 | ||||
-rw-r--r-- | lib/private/DB/QueryBuilder/QuoteHelper.php | 2 |
2 files changed, 24 insertions, 10 deletions
diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php index 217789ce728..3fc827c9680 100644 --- a/lib/private/DB/QueryBuilder/QueryBuilder.php +++ b/lib/private/DB/QueryBuilder/QueryBuilder.php @@ -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); + } } diff --git a/lib/private/DB/QueryBuilder/QuoteHelper.php b/lib/private/DB/QueryBuilder/QuoteHelper.php index 705c3a89712..8821863ed07 100644 --- a/lib/private/DB/QueryBuilder/QuoteHelper.php +++ b/lib/private/DB/QueryBuilder/QuoteHelper.php @@ -70,7 +70,7 @@ class QuoteHelper { list($alias, $columnName) = explode('.', $string, 2); if ($columnName === '*') { - return $string; + return '`' . $alias . '`.*'; } return '`' . $alias . '`.`' . $columnName . '`'; |