summaryrefslogtreecommitdiffstats
path: root/lib/private/DB
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-01-16 15:12:30 +0100
committerRobin Appelman <robin@icewind.nl>2017-03-30 11:09:22 +0200
commita65652fc1efe158bd097d573f012167cfcd26a62 (patch)
tree3dff9d54a80ceab4fff65590121c86bf7994992c /lib/private/DB
parent83f3990e069e466741b35ecc5ef730972d22f67d (diff)
downloadnextcloud-server-a65652fc1efe158bd097d573f012167cfcd26a62.tar.gz
nextcloud-server-a65652fc1efe158bd097d573f012167cfcd26a62.zip
add support for escaping like parameters 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/ExpressionBuilder/OCIExpressionBuilder.php7
-rw-r--r--lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php37
-rw-r--r--lib/private/DB/QueryBuilder/QueryBuilder.php6
3 files changed, 50 insertions, 0 deletions
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php
index 69c34947feb..179ce72e8e1 100644
--- a/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php
@@ -156,6 +156,13 @@ class OCIExpressionBuilder extends ExpressionBuilder {
/**
* @inheritdoc
*/
+ public function like($x, $y, $type = null) {
+ return parent::like($x, $y, $type) . " ESCAPE '\\'";
+ }
+
+ /**
+ * @inheritdoc
+ */
public function iLike($x, $y, $type = null) {
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php
new file mode 100644
index 00000000000..fa7c7fab6e5
--- /dev/null
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/SqliteExpressionBuilder.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * @author Robin Appelman <robin@icewind.nl>
+ *
+ * @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\ILiteral;
+use OCP\DB\QueryBuilder\IParameter;
+use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\DB\QueryBuilder\IQueryFunction;
+
+class SqliteExpressionBuilder extends ExpressionBuilder {
+ /**
+ * @inheritdoc
+ */
+ public function like($x, $y, $type = null) {
+ return parent::like($x, $y, $type) . " ESCAPE '\\'";
+ }
+}
diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php
index d5dd9cf0366..a434140806e 100644
--- a/lib/private/DB/QueryBuilder/QueryBuilder.php
+++ b/lib/private/DB/QueryBuilder/QueryBuilder.php
@@ -26,11 +26,15 @@ namespace OC\DB\QueryBuilder;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
+use Doctrine\DBAL\Platforms\SqlitePlatform;
use OC\DB\OracleConnection;
use OC\DB\QueryBuilder\ExpressionBuilder\ExpressionBuilder;
use OC\DB\QueryBuilder\ExpressionBuilder\MySqlExpressionBuilder;
use OC\DB\QueryBuilder\ExpressionBuilder\OCIExpressionBuilder;
use OC\DB\QueryBuilder\ExpressionBuilder\PgSqlExpressionBuilder;
+use OC\DB\QueryBuilder\ExpressionBuilder\SqliteExpressionBuilder;
+use OC\DB\QueryBuilder\FunctionBuilder\FunctionBuilder;
+use OC\DB\QueryBuilder\FunctionBuilder\SqliteFunctionBuilder;
use OC\SystemConfig;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\QueryBuilder\IQueryFunction;
@@ -110,6 +114,8 @@ class QueryBuilder implements IQueryBuilder {
return new PgSqlExpressionBuilder($this->connection);
} else if ($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
return new MySqlExpressionBuilder($this->connection);
+ } else if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
+ return new SqliteExpressionBuilder($this->connection);
} else {
return new ExpressionBuilder($this->connection);
}