summaryrefslogtreecommitdiffstats
path: root/lib/private/DB
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2016-11-17 14:04:07 +0100
committerRobin Appelman <robin@icewind.nl>2016-11-17 18:48:35 +0100
commit07e51a719a29e8ab9110b31d85f57031f6c66c77 (patch)
tree220290091877380438ecd888bc2c896694699c5c /lib/private/DB
parent02bfd915534d5dfaee3c5c873b84cc14657bed15 (diff)
downloadnextcloud-server-07e51a719a29e8ab9110b31d85f57031f6c66c77.tar.gz
nextcloud-server-07e51a719a29e8ab9110b31d85f57031f6c66c77.zip
Allow aliasing columns when using the query builder
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/DB')
-rw-r--r--lib/private/DB/QueryBuilder/QuoteHelper.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/private/DB/QueryBuilder/QuoteHelper.php b/lib/private/DB/QueryBuilder/QuoteHelper.php
index 6d15cec5a05..041718bce5a 100644
--- a/lib/private/DB/QueryBuilder/QuoteHelper.php
+++ b/lib/private/DB/QueryBuilder/QuoteHelper.php
@@ -61,6 +61,11 @@ class QuoteHelper {
throw new \InvalidArgumentException('Only strings, Literals and Parameters are allowed');
}
+ $string = str_replace(' AS ', ' as ', $string);
+ if (substr_count($string, ' as ')) {
+ return implode(' as ', array_map([$this, 'quoteColumnName'], explode(' as ', $string, 2)));
+ }
+
if (substr_count($string, '.')) {
list($alias, $columnName) = explode('.', $string, 2);