diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-09-17 13:47:33 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-09-17 13:47:33 +0200 |
commit | 60587e9dcda4e4c9d7a04c201024124964008f36 (patch) | |
tree | 2b9216dbc1371e4559b89815ca24a591b74ea5a3 /lib/private/db | |
parent | 95815c0b57c0d255a1ad5dd71d8f925fc5cc4588 (diff) | |
download | nextcloud-server-60587e9dcda4e4c9d7a04c201024124964008f36.tar.gz nextcloud-server-60587e9dcda4e4c9d7a04c201024124964008f36.zip |
Make sqlite LIKE case sensitive on default
Diffstat (limited to 'lib/private/db')
-rw-r--r-- | lib/private/db/connectionfactory.php | 3 | ||||
-rw-r--r-- | lib/private/db/sqlitesessioninit.php | 42 |
2 files changed, 45 insertions, 0 deletions
diff --git a/lib/private/db/connectionfactory.php b/lib/private/db/connectionfactory.php index 8fd26bdc947..589a1c0affd 100644 --- a/lib/private/db/connectionfactory.php +++ b/lib/private/db/connectionfactory.php @@ -89,6 +89,9 @@ class ConnectionFactory { case 'oci': $eventManager->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\OracleSessionInit); break; + case 'sqlite3': + $eventManager->addEventSubscriber(new SQLiteSessionInit); + break; } $connection = \Doctrine\DBAL\DriverManager::getConnection( array_merge($this->getDefaultConnectionParams($type), $additionalConnectionParams), diff --git a/lib/private/db/sqlitesessioninit.php b/lib/private/db/sqlitesessioninit.php new file mode 100644 index 00000000000..7e1166be95b --- /dev/null +++ b/lib/private/db/sqlitesessioninit.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\DB; + +use Doctrine\DBAL\Event\ConnectionEventArgs; +use Doctrine\DBAL\Events; +use Doctrine\Common\EventSubscriber; + +class SQLiteSessionInit implements EventSubscriber { + /** + * @var bool + */ + private $caseSensitiveLike; + + /** + * Configure case sensitive like for each connection + * + * @param bool $caseSensitiveLike + */ + public function __construct($caseSensitiveLike = true) { + $this->caseSensitiveLike = $caseSensitiveLike; + } + + /** + * @param ConnectionEventArgs $args + * @return void + */ + public function postConnect(ConnectionEventArgs $args) { + $sensitive = ($this->caseSensitiveLike) ? 'true' : 'false'; + $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive); + } + + public function getSubscribedEvents() { + return array(Events::postConnect); + } +} |