summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-02-06 13:26:00 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-02-06 13:26:00 +0100
commit5832178f591f1efca48e06c78dfb7a0405a7cce4 (patch)
tree5e162879b81a4a8d182090bcf3f9440305aeb249 /lib
parent72974081505dbf2eb6c5f00a03f8690235cb037b (diff)
parent065141f6f4212dbbca4633b0138f6e5ac3ec4f7a (diff)
downloadnextcloud-server-5832178f591f1efca48e06c78dfb7a0405a7cce4.tar.gz
nextcloud-server-5832178f591f1efca48e06c78dfb7a0405a7cce4.zip
Merge pull request #22139 from owncloud/comments-files-cleanup
cleanup jobs for comments and comment read marks
Diffstat (limited to 'lib')
-rw-r--r--lib/private/db/querybuilder/expressionbuilder/expressionbuilder.php (renamed from lib/private/db/querybuilder/expressionbuilder.php)19
-rw-r--r--lib/private/db/querybuilder/expressionbuilder/ociexpressionbuilder.php (renamed from lib/private/db/querybuilder/ociexpressionbuilder.php)25
-rw-r--r--lib/private/db/querybuilder/expressionbuilder/pgsqlexpressionbuilder.php45
-rw-r--r--lib/private/db/querybuilder/querybuilder.php6
-rw-r--r--lib/private/repair/dropoldjobs.php1
-rw-r--r--lib/public/db/querybuilder/iexpressionbuilder.php10
6 files changed, 101 insertions, 5 deletions
diff --git a/lib/private/db/querybuilder/expressionbuilder.php b/lib/private/db/querybuilder/expressionbuilder/expressionbuilder.php
index b688ebfabbe..7ab4c03d97c 100644
--- a/lib/private/db/querybuilder/expressionbuilder.php
+++ b/lib/private/db/querybuilder/expressionbuilder/expressionbuilder.php
@@ -19,9 +19,13 @@
*
*/
-namespace OC\DB\QueryBuilder;
+namespace OC\DB\QueryBuilder\ExpressionBuilder;
use Doctrine\DBAL\Query\Expression\ExpressionBuilder as DoctrineExpressionBuilder;
+use OC\DB\QueryBuilder\CompositeExpression;
+use OC\DB\QueryBuilder\Literal;
+use OC\DB\QueryBuilder\QueryFunction;
+use OC\DB\QueryBuilder\QuoteHelper;
use OCP\DB\QueryBuilder\IExpressionBuilder;
use OCP\IDBConnection;
@@ -331,4 +335,17 @@ class ExpressionBuilder implements IExpressionBuilder {
public function literal($input, $type = null) {
return new Literal($this->expressionBuilder->literal($input, $type));
}
+
+ /**
+ * Returns a IQueryFunction that casts the column to the given type
+ *
+ * @param string $column
+ * @param mixed $type One of IQueryBuilder::PARAM_*
+ * @return string
+ */
+ public function castColumn($column, $type) {
+ return new QueryFunction(
+ $this->helper->quoteColumnName($column)
+ );
+ }
}
diff --git a/lib/private/db/querybuilder/ociexpressionbuilder.php b/lib/private/db/querybuilder/expressionbuilder/ociexpressionbuilder.php
index 4c127bd752d..6a6d0f455f6 100644
--- a/lib/private/db/querybuilder/ociexpressionbuilder.php
+++ b/lib/private/db/querybuilder/expressionbuilder/ociexpressionbuilder.php
@@ -19,24 +19,25 @@
*
*/
-namespace OC\DB\QueryBuilder;
+namespace OC\DB\QueryBuilder\ExpressionBuilder;
+use OC\DB\QueryBuilder\QueryFunction;
use OCP\DB\QueryBuilder\ILiteral;
use OCP\DB\QueryBuilder\IParameter;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\DB\QueryBuilder\IQueryFunction;
class OCIExpressionBuilder extends ExpressionBuilder {
/**
* @param mixed $column
* @param mixed|null $type
- * @return array|QueryFunction|string
+ * @return array|IQueryFunction|string
*/
protected function prepareColumn($column, $type) {
if ($type === IQueryBuilder::PARAM_STR && !is_array($column) && !($column instanceof IParameter) && !($column instanceof ILiteral)) {
- $column = $this->helper->quoteColumnName($column);
- $column = new QueryFunction('to_char(' . $column . ')');
+ $column = $this->castColumn($column, $type);
} else {
$column = $this->helper->quoteColumnNames($column);
}
@@ -132,4 +133,20 @@ class OCIExpressionBuilder extends ExpressionBuilder {
return $this->expressionBuilder->notIn($x, $y);
}
+
+ /**
+ * Returns a IQueryFunction that casts the column to the given type
+ *
+ * @param string $column
+ * @param mixed $type One of IQueryBuilder::PARAM_*
+ * @return IQueryFunction
+ */
+ public function castColumn($column, $type) {
+ if ($type === IQueryBuilder::PARAM_STR) {
+ $column = $this->helper->quoteColumnName($column);
+ return new QueryFunction('to_char(' . $column . ')');
+ }
+
+ return parent::castColumn($column, $type);
+ }
}
diff --git a/lib/private/db/querybuilder/expressionbuilder/pgsqlexpressionbuilder.php b/lib/private/db/querybuilder/expressionbuilder/pgsqlexpressionbuilder.php
new file mode 100644
index 00000000000..8a0b68db998
--- /dev/null
+++ b/lib/private/db/querybuilder/expressionbuilder/pgsqlexpressionbuilder.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * @author Joas Schilling <nickvergessen@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OC\DB\QueryBuilder\ExpressionBuilder;
+
+
+use OC\DB\QueryBuilder\QueryFunction;
+use OCP\DB\QueryBuilder\IQueryBuilder;
+
+class PgSqlExpressionBuilder extends ExpressionBuilder {
+
+ /**
+ * Returns a IQueryFunction that casts the column to the given type
+ *
+ * @param string $column
+ * @param mixed $type One of IQueryBuilder::PARAM_*
+ * @return string
+ */
+ public function castColumn($column, $type) {
+ if ($type === IQueryBuilder::PARAM_INT) {
+ $column = $this->helper->quoteColumnName($column);
+ return new QueryFunction('CAST(' . $column . ' AS INT)');
+ }
+
+ return parent::castColumn($column, $type);
+ }
+}
diff --git a/lib/private/db/querybuilder/querybuilder.php b/lib/private/db/querybuilder/querybuilder.php
index 42b290b90e7..ff31ffbc043 100644
--- a/lib/private/db/querybuilder/querybuilder.php
+++ b/lib/private/db/querybuilder/querybuilder.php
@@ -21,7 +21,11 @@
namespace OC\DB\QueryBuilder;
+use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use OC\DB\OracleConnection;
+use OC\DB\QueryBuilder\ExpressionBuilder\ExpressionBuilder;
+use OC\DB\QueryBuilder\ExpressionBuilder\OCIExpressionBuilder;
+use OC\DB\QueryBuilder\ExpressionBuilder\PgSqlExpressionBuilder;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\QueryBuilder\IQueryFunction;
use OCP\DB\QueryBuilder\IParameter;
@@ -85,6 +89,8 @@ class QueryBuilder implements IQueryBuilder {
public function expr() {
if ($this->connection instanceof OracleConnection) {
return new OCIExpressionBuilder($this->connection);
+ } else if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
+ return new PgSqlExpressionBuilder($this->connection);
} else {
return new ExpressionBuilder($this->connection);
}
diff --git a/lib/private/repair/dropoldjobs.php b/lib/private/repair/dropoldjobs.php
index 2d6172047c2..b2e9b05caa2 100644
--- a/lib/private/repair/dropoldjobs.php
+++ b/lib/private/repair/dropoldjobs.php
@@ -71,6 +71,7 @@ class DropOldJobs extends BasicEmitter implements RepairStep {
return [
['class' => 'OC_Cache_FileGlobalGC', 'arguments' => null],
['class' => 'OC\Cache\FileGlobalGC', 'arguments' => null],
+ ['class' => 'OCA\Files\BackgroundJob\DeleteOrphanedTagsJob', 'arguments' => null],
];
}
diff --git a/lib/public/db/querybuilder/iexpressionbuilder.php b/lib/public/db/querybuilder/iexpressionbuilder.php
index a53ae3846c2..4b53a0e0b8b 100644
--- a/lib/public/db/querybuilder/iexpressionbuilder.php
+++ b/lib/public/db/querybuilder/iexpressionbuilder.php
@@ -299,4 +299,14 @@ interface IExpressionBuilder {
* @since 8.2.0
*/
public function literal($input, $type = null);
+
+ /**
+ * Returns a IQueryFunction that casts the column to the given type
+ *
+ * @param string $column
+ * @param mixed $type One of IQueryBuilder::PARAM_*
+ * @return string
+ * @since 9.0.0
+ */
+ public function castColumn($column, $type);
}