Connection::$postgresqlConditionOperatorMap

Same name and namespace in other branches
  1. 11.x core/modules/pgsql/src/Driver/Database/pgsql/Connection.php \Drupal\pgsql\Driver\Database\pgsql\Connection::postgresqlConditionOperatorMap
  2. 10 core/modules/pgsql/src/Driver/Database/pgsql/Connection.php \Drupal\pgsql\Driver\Database\pgsql\Connection::postgresqlConditionOperatorMap
  3. 9 core/modules/pgsql/src/Driver/Database/pgsql/Connection.php \Drupal\pgsql\Driver\Database\pgsql\Connection::postgresqlConditionOperatorMap
  4. 8.9.x core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php \Drupal\Core\Database\Driver\pgsql\Connection::postgresqlConditionOperatorMap

A map of condition operators to PostgreSQL operators.

In PostgreSQL, 'LIKE' is case-sensitive. ILIKE should be used for case-insensitive statements. PostgreSQL doesn't automatically cast fields to the right type for these operators, so the fields are cast to text.

Type: string[][]

File

core/modules/pgsql/src/Driver/Database/pgsql/Connection.php, line 61

Class

Connection
PostgreSQL implementation of \Drupal\Core\Database\Connection.

Namespace

Drupal\pgsql\Driver\Database\pgsql

Code

protected static $postgresqlConditionOperatorMap = [
  'LIKE' => [
    'operator' => 'ILIKE',
    'field_suffix' => '::text',
  ],
  'LIKE BINARY' => [
    'operator' => 'LIKE',
    'field_suffix' => '::text',
  ],
  'NOT LIKE' => [
    'operator' => 'NOT ILIKE',
    'field_suffix' => '::text',
  ],
  'REGEXP' => [
    'operator' => '~*',
    'field_suffix' => '::text',
  ],
  'NOT REGEXP' => [
    'operator' => '!~*',
    'field_suffix' => '::text',
  ],
  // Identity entries, so that conditions built with PostgreSQL operators
  // directly also get the field cast. For example, Views' StringFilter
  // maps 'LIKE' to 'ILIKE' itself before adding the condition.
'ILIKE' => [
    'operator' => 'ILIKE',
    'field_suffix' => '::text',
  ],
  'NOT ILIKE' => [
    'operator' => 'NOT ILIKE',
    'field_suffix' => '::text',
  ],
  '~*' => [
    'operator' => '~*',
    'field_suffix' => '::text',
  ],
  '!~*' => [
    'operator' => '!~*',
    'field_suffix' => '::text',
  ],
];

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.