Skip to content
Snippets Groups Projects
Commit 7786d91c authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2451749 by amateescu, bzrudi71, jaredsmith: PostgreSQL: Fix views\src\Tests\GlossaryTest.php

parent b15e4ffb
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\argument;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Database\Database;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\ViewExecutable;
......@@ -179,11 +180,19 @@ protected function summaryQuery() {
public function getFormula() {
$formula = "SUBSTRING($this->tableAlias.$this->realField, 1, " . intval($this->options['limit']) . ")";
// Support case-insensitive substring comparisons for SQLite by using the
// 'NOCASE_UTF8' collation.
// @see Drupal\Core\Database\Driver\sqlite\Connection::open()
if (Database::getConnection()->databaseType() == 'sqlite' && $this->options['case'] != 'none') {
$formula .= ' COLLATE NOCASE_UTF8';
if ($this->options['case'] != 'none') {
// Support case-insensitive substring comparisons for SQLite by using the
// 'NOCASE_UTF8' collation.
// @see Drupal\Core\Database\Driver\sqlite\Connection::open()
if (Database::getConnection()->databaseType() == 'sqlite') {
$formula .= ' COLLATE NOCASE_UTF8';
}
// Support case-insensitive substring comparisons for PostgreSQL by
// converting the formula to lowercase.
if (Database::getConnection()->databaseType() == 'pgsql') {
$formula = 'LOWER(' . $formula . ')';
}
}
return $formula;
}
......@@ -205,6 +214,14 @@ public function query($group_by = FALSE) {
$this->operator = 'or';
}
// Support case-insensitive substring comparisons for PostgreSQL by
// converting the arguments to lowercase.
if ($this->options['case'] != 'none' && Database::getConnection()->databaseType() == 'pgsql') {
foreach ($this->value as $key => $value) {
$this->value[$key] = Unicode::strtolower($value);
}
}
if (!empty($this->definition['many to one'])) {
if (!empty($this->options['glossary'])) {
$this->helper->formula = TRUE;
......@@ -266,6 +283,12 @@ public function getSortName() {
}
function title() {
// Support case-insensitive title comparisons for PostgreSQL by converting
// the title to lowercase.
if ($this->options['case'] != 'none' && Database::getConnection()->databaseType() == 'pgsql') {
$this->options['case'] = 'lower';
}
$this->argument = $this->caseTransform($this->argument, $this->options['case']);
if (!empty($this->options['transform_dash'])) {
$this->argument = strtr($this->argument, '-', ' ');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment