blob: 1b750155693ffb3f6f740a729d9b17d4dc1b5088 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?php
namespace Drupal\pgsql\EntityQuery;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Core\Entity\Query\Sql\Condition as BaseCondition;
/**
* Implements entity query conditions for PostgreSQL databases.
*/
class Condition extends BaseCondition {
/**
* {@inheritdoc}
*/
public static function translateCondition(&$condition, SelectInterface $sql_query, $case_sensitive): void {
if (is_array($condition['value']) && $case_sensitive === FALSE) {
$condition['where'] = 'LOWER(' . $sql_query->escapeField($condition['real_field']) . ') ' . $condition['operator'] . ' (';
$condition['where_args'] = [];
// Only use the array values in case an associative array is passed as an
// argument following similar pattern in
// \Drupal\Core\Database\Connection::expandArguments().
$where_prefix = str_replace('.', '_', $condition['real_field']);
foreach ($condition['value'] as $key => $value) {
$where_id = $where_prefix . $key;
$condition['where'] .= 'LOWER(:' . $where_id . '),';
$condition['where_args'][':' . $where_id] = $value;
}
$condition['where'] = trim($condition['where'], ',');
$condition['where'] .= ')';
}
parent::translateCondition($condition, $sql_query, $case_sensitive);
}
}
|