Make sqlite LIKE case sensitive on default
This commit is contained in:
parent
95815c0b57
commit
60587e9dcd
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue