diff --git c/core/includes/database.inc w/core/includes/database.inc
index 26cdcc0..0424714 100644
--- c/core/includes/database.inc
+++ w/core/includes/database.inc
@@ -534,6 +534,8 @@ function db_next_id($existing_id = 0) {
  *
  * @return \Drupal\Core\Database\Query\Condition
  *   A new Condition object, set to "OR" all conditions together.
+ *
+ * @deprecated use $query->orConditionGroup()
  */
 function db_or() {
   return new Condition('OR');
@@ -544,6 +546,8 @@ function db_or() {
  *
  * @return \Drupal\Core\Database\Query\Condition
  *   A new Condition object, set to "AND" all conditions together.
+ *
+ * @deprecated use $query->andConditionGroup()
  */
 function db_and() {
   return new Condition('AND');
@@ -562,9 +566,6 @@ function db_xor() {
 /**
  * Returns a new DatabaseCondition, set to the specified conjunction.
  *
- * Internal API function call.  The db_and(), db_or(), and db_xor()
- * functions are preferred.
- *
  * @param $conjunction
  *   The conjunction to use for query conditions (AND, OR or XOR).
  *
diff --git c/core/modules/comment/lib/Drupal/comment/Plugin/views/argument/UserUid.php w/core/modules/comment/lib/Drupal/comment/Plugin/views/argument/UserUid.php
index a852c58..ed69412 100644
--- c/core/modules/comment/lib/Drupal/comment/Plugin/views/argument/UserUid.php
+++ w/core/modules/comment/lib/Drupal/comment/Plugin/views/argument/UserUid.php
@@ -96,7 +96,7 @@ public function query($group_by = FALSE) {
       $subselect->where("c.entity_id = $this->tableAlias.$entity_id");
       $subselect->condition('c.entity_type', $entity_type);
 
-      $condition = db_or()
+      $condition = $this->query->orConditionGroup()
         ->condition("$this->tableAlias.uid", $this->argument, '=')
         ->exists($subselect);
 
diff --git c/core/modules/comment/lib/Drupal/comment/Plugin/views/filter/UserUid.php w/core/modules/comment/lib/Drupal/comment/Plugin/views/filter/UserUid.php
index a2713df..00d2d5a 100644
--- c/core/modules/comment/lib/Drupal/comment/Plugin/views/filter/UserUid.php
+++ w/core/modules/comment/lib/Drupal/comment/Plugin/views/filter/UserUid.php
@@ -32,7 +32,7 @@ public function query() {
     $subselect->where("c.entity_id = $this->tableAlias.$entity_id");
     $subselect->condition('c.entity_type', $entity_type);
 
-    $condition = db_or()
+    $condition = $this->query->orConditionGroup()
       ->condition("$this->tableAlias.uid", $this->value, $this->operator)
       ->exists($subselect);
 
diff --git c/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/views/display/EntityReference.php w/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/views/display/EntityReference.php
index 496b5ea..05b4d61 100644
--- c/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/views/display/EntityReference.php
+++ w/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/views/display/EntityReference.php
@@ -136,7 +136,7 @@ public function query() {
       }
 
       // Multiple search fields are OR'd together.
-      $conditions = db_or();
+      $conditions = $this->view->query->orConditionGroup();
 
       // Build the condition using the selected search fields.
       foreach ($style_options['options']['search_fields'] as $field_alias) {
diff --git c/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php w/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php
index 458e1b9..73e0f95 100644
--- c/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php
+++ w/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php
@@ -418,7 +418,7 @@ protected function dbStringSelect(array $conditions, array $options = array()) {
       elseif ($table_alias == 't' && $join === 'leftJoin') {
         // Conditions for target fields when doing an outer join only make
         // sense if we add also OR field IS NULL.
-        $query->condition(db_or()
+        $query->condition($query->orConditionGroup()
             ->condition($field_alias, $value)
             ->isNull($field_alias)
         );
@@ -431,7 +431,7 @@ protected function dbStringSelect(array $conditions, array $options = array()) {
     // Process other options, string filter, query limit, etc...
     if (!empty($options['filters'])) {
       if (count($options['filters']) > 1) {
-        $filter = db_or();
+        $filter = $query->orConditionGroup();
         $query->condition($filter);
       }
       else {
diff --git c/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php w/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php
index c7ef831..36cb019 100644
--- c/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php
+++ w/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php
@@ -232,9 +232,9 @@ public function getPreventReparenting() {
   public function loadUpdatedCustomized(array $router_paths) {
     $query = parent::buildQuery(NULL);
     $query
-      ->condition(db_or()
+      ->condition($query->orConditionGroup()
       ->condition('updated', 1)
-      ->condition(db_and()
+      ->condition($query->andConditionGroup()
         ->condition('router_path', $router_paths, 'NOT IN')
         ->condition('external', 0)
         ->condition('customized', 1)
diff --git c/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php w/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php
index 8dcc8f3..443ad9c 100644
--- c/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php
+++ w/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php
@@ -83,7 +83,7 @@ public function access(EntityInterface $node, $operation, $langcode, AccountInte
     $grants = $query->orConditionGroup();
     foreach (node_access_grants($operation, $account) as $realm => $gids) {
       foreach ($gids as $gid) {
-        $grants->condition(db_and()
+        $grants->condition($grants->andConditionGroup()
             ->condition('gid', $gid)
             ->condition('realm', $realm));
       }
@@ -106,10 +106,10 @@ public function checkAll(AccountInterface $account) {
       ->condition('nid', 0)
       ->condition('grant_view', 1, '>=');
 
-    $grants = db_or();
+    $grants = $query->orConditionGroup();
     foreach (node_access_grants('view', $account) as $realm => $gids) {
       foreach ($gids as $gid) {
-        $grants->condition(db_and()
+        $grants->condition($grants->andConditionGroup()
             ->condition('gid', $gid)
             ->condition('realm', $realm)
         );
@@ -140,12 +140,12 @@ public function alterQuery($query, array $tables, $op, AccountInterface $account
         $subquery = $this->database->select('node_access', 'na')
           ->fields('na', array('nid'));
 
-        $grant_conditions = db_or();
+        $grant_conditions = $subquery->orConditionGroup();
         // If any grant exists for the specified user, then user has access to the
         // node for the specified operation.
         foreach ($grants as $realm => $gids) {
           foreach ($gids as $gid) {
-            $grant_conditions->condition(db_and()
+            $grant_conditions->condition($grant_conditions->andConditionGroup()
                 ->condition('na.gid', $gid)
                 ->condition('na.realm', $realm)
             );
diff --git c/core/modules/node/lib/Drupal/node/Plugin/views/filter/Access.php w/core/modules/node/lib/Drupal/node/Plugin/views/filter/Access.php
index b5bf773..81d4502 100644
--- c/core/modules/node/lib/Drupal/node/Plugin/views/filter/Access.php
+++ w/core/modules/node/lib/Drupal/node/Plugin/views/filter/Access.php
@@ -31,10 +31,10 @@ public function canExpose() {
   public function query() {
     if (!user_access('administer nodes')) {
       $table = $this->ensureMyTable();
-      $grants = db_or();
+      $grants = $this->query->orConditionGroup();
       foreach (node_access_grants('view') as $realm => $gids) {
         foreach ($gids as $gid) {
-          $grants->condition(db_and()
+          $grants->condition($grants->andConditionGroup()
             ->condition($table . '.gid', $gid)
             ->condition($table . '.realm', $realm)
           );
diff --git c/core/modules/node/node.admin.inc w/core/modules/node/node.admin.inc
index 03387f8..f3776db 100644
--- c/core/modules/node/node.admin.inc
+++ w/core/modules/node/node.admin.inc
@@ -207,7 +207,7 @@ function node_admin_nodes() {
     // to see these in addition to published nodes. Check that they actually
     // have some unpublished nodes to view before adding the condition.
     if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT DISTINCT nid FROM {node_field_data} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->id(), ':status' => 0))->fetchCol()) {
-      $query->condition(db_or()
+      $query->condition($query->orConditionGroup()
         ->condition('n.status', 1)
         ->condition('n.nid', $own_unpublished, 'IN')
       );
diff --git c/core/modules/node/node.module w/core/modules/node/node.module
index 511a494..3f25ca4 100644
--- c/core/modules/node/node.module
+++ w/core/modules/node/node.module
@@ -1110,7 +1110,7 @@ function node_get_recent($number = 10) {
     // to see these in addition to published nodes. Check that they actually
     // have some unpublished nodes to view before adding the condition.
     if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT DISTINCT nid FROM {node_field_data} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->id(), ':status' => NODE_NOT_PUBLISHED))->fetchCol()) {
-      $query->condition(db_or()
+      $query->condition($query->orConditionGroup()
         ->condition('n.status', NODE_PUBLISHED)
         ->condition('n.nid', $own_unpublished, 'IN')
       );
diff --git c/core/modules/search/lib/Drupal/search/Plugin/views/argument/Search.php w/core/modules/search/lib/Drupal/search/Plugin/views/argument/Search.php
index 96810a6..ded5653 100644
--- c/core/modules/search/lib/Drupal/search/Plugin/views/argument/Search.php
+++ w/core/modules/search/lib/Drupal/search/Plugin/views/argument/Search.php
@@ -56,7 +56,7 @@ public function query($group_by = FALSE) {
     else {
       $search_index = $this->ensureMyTable();
 
-      $search_condition = db_and();
+      $search_condition = $this->query->andConditionGroup();
 
       // Create a new join to relate the 'search_total' table to our current 'search_index' table.
       $definition = array(
@@ -94,7 +94,7 @@ public function query($group_by = FALSE) {
       }
       else {
         // Stores each condition, so and/or on the filter level will still work.
-        $or = db_or();
+        $or = $this->query->orConditionGroup();
         foreach ($words as $word) {
           $or->condition("$search_index.word", $word);
         }
diff --git c/core/modules/search/lib/Drupal/search/Plugin/views/filter/Search.php w/core/modules/search/lib/Drupal/search/Plugin/views/filter/Search.php
index 7d9f6cc..fc90172 100644
--- c/core/modules/search/lib/Drupal/search/Plugin/views/filter/Search.php
+++ w/core/modules/search/lib/Drupal/search/Plugin/views/filter/Search.php
@@ -136,7 +136,7 @@ public function query() {
     else {
       $search_index = $this->ensureMyTable();
 
-      $search_condition = db_and();
+      $search_condition = $this->query->andConditionGroup();
 
       // Create a new join to relate the 'serach_total' table to our current 'search_index' table.
       $definition = array(
@@ -174,7 +174,7 @@ public function query() {
       }
       else {
         // Stores each condition, so and/or on the filter level will still work.
-        $or = db_or();
+        $or = $this->query->orConditionGroup();
         foreach ($words as $word) {
           $or->condition("$search_index.word", $word);
         }
diff --git c/core/modules/search/lib/Drupal/search/SearchQuery.php w/core/modules/search/lib/Drupal/search/SearchQuery.php
index a331a4a..66b9c11 100644
--- c/core/modules/search/lib/Drupal/search/SearchQuery.php
+++ w/core/modules/search/lib/Drupal/search/SearchQuery.php
@@ -242,7 +242,7 @@ protected function parseSearchExpression() {
     }
 
     // Convert keywords into SQL statements.
-    $this->conditions = db_and();
+    $this->conditions = $this->query->andConditionGroup();
     $simple_and = FALSE;
     $simple_or = FALSE;
     // Positive matches.
@@ -251,7 +251,7 @@ protected function parseSearchExpression() {
       if (is_array($key) && count($key)) {
         $simple_or = TRUE;
         $any = FALSE;
-        $queryor = db_or();
+        $queryor = $this->query->orConditionGroup();
         foreach ($key as $or) {
           list($num_new_scores) = $this->parseWord($or);
           $any |= $num_new_scores;
@@ -334,7 +334,7 @@ public function executeFirstPass() {
     $this->executedFirstPass = TRUE;
 
     if (!empty($this->words)) {
-      $or = db_or();
+      $or = $this->query->orConditionGroup();
       foreach ($this->words as $word) {
         $or->condition('i.word', $word);
       }
diff --git c/core/modules/search/lib/Drupal/search/ViewsSearchQuery.php w/core/modules/search/lib/Drupal/search/ViewsSearchQuery.php
index 0690551..5b0bbd9 100644
--- c/core/modules/search/lib/Drupal/search/ViewsSearchQuery.php
+++ w/core/modules/search/lib/Drupal/search/ViewsSearchQuery.php
@@ -72,8 +72,9 @@ function condition_replace_string($search, $replace, &$condition) {
       $conditions =& $condition['field']->conditions();
       foreach ($conditions as $key => &$subcondition) {
         if (is_numeric($key)) {
-          // As conditions can have subconditions, for example db_or(), the
-          // function has to be called recursively.
+          // As conditions can have subconditions, for example
+          // $this->view->orConditionGroup, the function has to be called
+          // recursively.
           $this->condition_replace_string($search, $replace, $subcondition);
         }
       }
diff --git c/core/modules/search/search.module w/core/modules/search/search.module
index c7bed06..d4e9913 100644
--- c/core/modules/search/search.module
+++ w/core/modules/search/search.module
@@ -317,7 +317,7 @@ function search_update_totals() {
   // search_total. We use a LEFT JOIN between the two tables and keep only the
   // rows which fail to join.
   $result = db_query("SELECT t.word AS realword, i.word FROM {search_total} t LEFT JOIN {search_index} i ON t.word = i.word WHERE i.word IS NULL", array(), array('target' => 'slave'));
-  $or = db_or();
+  $or = $result->orConditionGroup();
   foreach ($result as $word) {
     $or->condition('word', $word->realword);
   }
diff --git c/core/modules/system/lib/Drupal/system/Tests/Database/SelectComplexTest.php w/core/modules/system/lib/Drupal/system/Tests/Database/SelectComplexTest.php
index d764696..cb9fccf 100644
--- c/core/modules/system/lib/Drupal/system/Tests/Database/SelectComplexTest.php
+++ w/core/modules/system/lib/Drupal/system/Tests/Database/SelectComplexTest.php
@@ -302,7 +302,7 @@ function testNestedConditions() {
     $query = db_select('test');
     $query->addField('test', 'job');
     $query->condition('name', 'Paul');
-    $query->condition(db_or()->condition('age', 26)->condition('age', 27));
+    $query->condition($query->orConditionGroup()->condition('age', 26)->condition('age', 27));
 
     $job = $query->execute()->fetchField();
     $this->assertEqual($job, 'Songwriter', 'Correct data retrieved.');
diff --git c/core/modules/system/lib/Drupal/system/Tests/Database/UpdateComplexTest.php w/core/modules/system/lib/Drupal/system/Tests/Database/UpdateComplexTest.php
index 99bd178..c00838d 100644
--- c/core/modules/system/lib/Drupal/system/Tests/Database/UpdateComplexTest.php
+++ w/core/modules/system/lib/Drupal/system/Tests/Database/UpdateComplexTest.php
@@ -26,7 +26,7 @@ public static function getInfo() {
   function testOrConditionUpdate() {
     $update = db_update('test')
       ->fields(array('job' => 'Musician'))
-      ->condition(db_or()
+      ->condition($update->orConditionGroup()
         ->condition('name', 'John')
         ->condition('name', 'Paul')
       );
diff --git c/core/modules/system/system.api.php w/core/modules/system/system.api.php
index 0d9b5be..9fa51b6 100644
--- c/core/modules/system/system.api.php
+++ w/core/modules/system/system.api.php
@@ -2137,11 +2137,11 @@ function hook_query_TAG_alter(Drupal\Core\Database\Query\AlterableInterface $que
     if (!user_access('bypass node access')) {
       // The node_access table has the access grants for any given node.
       $access_alias = $query->join('node_access', 'na', '%alias.nid = n.nid');
-      $or = db_or();
+      $or = $query->orConditionGroup();
       // If any grant exists for the specified user, then user has access to the node for the specified operation.
       foreach (node_access_grants($op, $query->getMetaData('account')) as $realm => $gids) {
         foreach ($gids as $gid) {
-          $or->condition(db_and()
+          $or->condition($query->andConditionGroup()
             ->condition($access_alias . '.gid', $gid)
             ->condition($access_alias . '.realm', $realm)
           );
diff --git c/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTidDepth.php w/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTidDepth.php
index 46b8086..cb568bd 100644
--- c/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTidDepth.php
+++ w/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument/IndexTidDepth.php
@@ -122,7 +122,7 @@ public function query($group_by = FALSE) {
     // Now build the subqueries.
     $subquery = db_select('taxonomy_index', 'tn');
     $subquery->addField('tn', 'nid');
-    $where = db_or()->condition('tn.tid', $tids, $operator);
+    $where = $subquery->orConditionGroup()->condition('tn.tid', $tids, $operator);
     $last = "tn";
 
     if ($this->options['depth'] > 0) {
diff --git c/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/filter/TaxonomyIndexTidDepth.php w/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/filter/TaxonomyIndexTidDepth.php
index 3bae73d..7b87d71 100644
--- c/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/filter/TaxonomyIndexTidDepth.php
+++ w/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/filter/TaxonomyIndexTidDepth.php
@@ -81,7 +81,7 @@ public function query() {
     // Now build the subqueries.
     $subquery = db_select('taxonomy_index', 'tn');
     $subquery->addField('tn', 'nid');
-    $where = db_or()->condition('tn.tid', $this->value, $operator);
+    $where = $subquery->orConditionGroup()->condition('tn.tid', $this->value, $operator);
     $last = "tn";
 
     if ($this->options['depth'] > 0) {
diff --git c/core/modules/user/lib/Drupal/user/Plugin/entity_reference/selection/UserSelection.php w/core/modules/user/lib/Drupal/user/Plugin/entity_reference/selection/UserSelection.php
index e921c1c..8e08bcf 100644
--- c/core/modules/user/lib/Drupal/user/Plugin/entity_reference/selection/UserSelection.php
+++ w/core/modules/user/lib/Drupal/user/Plugin/entity_reference/selection/UserSelection.php
@@ -115,17 +115,17 @@ public function entityQueryAlter(SelectInterface $query) {
           // Re-add the condition and a condition on uid = 0 so that we end up
           // with a query in the form:
           // WHERE (name LIKE :name) OR (:anonymous_name LIKE :name AND uid = 0)
-          $or = db_or();
+          $or = $query->orConditionGroup();
           $or->condition($condition['field'], $condition['value'], $condition['operator']);
           // Sadly, the Database layer doesn't allow us to build a condition
           // in the form ':placeholder = :placeholder2', because the 'field'
           // part of a condition is always escaped.
           // As a (cheap) workaround, we separately build a condition with no
           // field, and concatenate the field and the condition separately.
-          $value_part = db_and();
+          $value_part = $query->andConditionGroup();
           $value_part->condition('anonymous_name', $condition['value'], $condition['operator']);
           $value_part->compile(Database::getConnection(), $query);
-          $or->condition(db_and()
+          $or->condition($query->andConditionGroup()
             ->where(str_replace('anonymous_name', ':anonymous_name', (string) $value_part), $value_part->arguments() + array(':anonymous_name' => user_format_name(user_load(0))))
             ->condition('users.uid', 0)
           );
diff --git c/core/modules/user/lib/Drupal/user/Plugin/views/filter/Current.php w/core/modules/user/lib/Drupal/user/Plugin/views/filter/Current.php
index ce9d26e..94fd829 100644
--- c/core/modules/user/lib/Drupal/user/Plugin/views/filter/Current.php
+++ w/core/modules/user/lib/Drupal/user/Plugin/views/filter/Current.php
@@ -34,7 +34,7 @@ public function query() {
     $this->ensureMyTable();
 
     $field = $this->tableAlias . '.' . $this->realField . ' ';
-    $or = db_or();
+    $or = $this->query->orConditionGroup();
 
     if (empty($this->value)) {
       $or->condition($field, '***CURRENT_USER***', '<>');
diff --git c/core/modules/views/lib/Drupal/views/ManyToOneHelper.php w/core/modules/views/lib/Drupal/views/ManyToOneHelper.php
index 08c8cd9..e66c903 100644
--- c/core/modules/views/lib/Drupal/views/ManyToOneHelper.php
+++ w/core/modules/views/lib/Drupal/views/ManyToOneHelper.php
@@ -274,7 +274,7 @@ public function addFilter() {
     }
 
     // add_condition determines whether a single expression is enough(FALSE) or the
-    // conditions should be added via an db_or()/db_and() (TRUE).
+    // conditions should be added via andConditionGroup/orConditionGroup (TRUE).
     $add_condition = TRUE;
     if ($operator == 'not') {
       $value = NULL;
@@ -319,7 +319,7 @@ public function addFilter() {
 
     if ($add_condition) {
       $field = $this->handler->realField;
-      $clause = $operator == 'or' ? db_or() : db_and();
+      $clause = $operator == 'or' ? $this->handler->query->orConditionGroup() : $this->handler->query->andConditionGroup();
       foreach ($this->handler->tableAliases as $value => $alias) {
         $clause->condition("$alias.$field", $value);
       }
diff --git c/core/modules/views/lib/Drupal/views/Plugin/views/filter/BooleanOperator.php w/core/modules/views/lib/Drupal/views/Plugin/views/filter/BooleanOperator.php
index 045edd5..d4a14e9 100644
--- c/core/modules/views/lib/Drupal/views/Plugin/views/filter/BooleanOperator.php
+++ w/core/modules/views/lib/Drupal/views/Plugin/views/filter/BooleanOperator.php
@@ -215,7 +215,7 @@ public function query() {
   protected function queryOpBoolean($field) {
     if (empty($this->value)) {
       if ($this->accept_null) {
-        $or = db_or()
+        $or = $this->query->orConditionGroup()
           ->condition($field, 0, '=')
           ->condition($field, NULL, 'IS NULL');
         $this->query->addWhere($this->options['group'], $or);
diff --git c/core/modules/views/lib/Drupal/views/Plugin/views/filter/Numeric.php w/core/modules/views/lib/Drupal/views/Plugin/views/filter/Numeric.php
index a257058..40a5246 100644
--- c/core/modules/views/lib/Drupal/views/Plugin/views/filter/Numeric.php
+++ w/core/modules/views/lib/Drupal/views/Plugin/views/filter/Numeric.php
@@ -250,7 +250,7 @@ protected function opBetween($field) {
       $this->query->addWhere($this->options['group'], $field, array($this->value['min'], $this->value['max']), 'BETWEEN');
     }
     else {
-      $this->query->addWhere($this->options['group'], db_or()->condition($field, $this->value['min'], '<=')->condition($field, $this->value['max'], '>='));
+      $this->query->addWhere($this->options['group'], $this->query->orConditionGroup()->condition($field, $this->value['min'], '<=')->condition($field, $this->value['max'], '>='));
     }
   }
 
diff --git c/core/modules/views/lib/Drupal/views/Plugin/views/filter/String.php w/core/modules/views/lib/Drupal/views/Plugin/views/filter/String.php
index 90acd1b..09531df 100644
--- c/core/modules/views/lib/Drupal/views/Plugin/views/filter/String.php
+++ w/core/modules/views/lib/Drupal/views/Plugin/views/filter/String.php
@@ -264,7 +264,7 @@ protected function opContains($field) {
   }
 
   protected function opContainsWord($field) {
-    $where = $this->operator == 'word' ? db_or() : db_and();
+    $where = $this->operator == 'word' ? $this->query->orConditionGroup() : $this->query->andConditionGroup();
 
     // Don't filter on empty strings.
     if (empty($this->value)) {
diff --git c/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php w/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php
index db08a61..f3a46c2 100644
--- c/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php
+++ w/core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php
@@ -810,7 +810,7 @@ public function clearFields() {
    * @code
    *   $this->query->addWhere(
    *     $this->options['group'],
-   *     db_or()
+   *     $this->query->orConditionGroup()
    *       ->condition($field, $value, 'NOT IN')
    *       ->condition($field, $value, 'IS NULL')
    *   );
@@ -1021,13 +1021,13 @@ protected function buildCondition($where = 'where') {
     $has_arguments = FALSE;
     $has_filter = FALSE;
 
-    $main_group = db_and();
-    $filter_group = $this->group_operator == 'OR' ? db_or() : db_and();
+    $main_group = $this->query->andConditionGroup();
+    $filter_group = $this->group_operator == 'OR' ? $this->query->orConditionGroup() : $this->query->andConditionGroup();
 
     foreach ($this->$where as $group => $info) {
 
       if (!empty($info['conditions'])) {
-        $sub_group = $info['type'] == 'OR' ? db_or() : db_and();
+        $sub_group = $info['type'] == 'OR' ? $this->query->orConditionGroup() : $this->query->andConditionGroup();
         foreach ($info['conditions'] as $clause) {
           // DBTNG doesn't support to add the same subquery twice to the main
           // query and the count query, so clone the subquery to have two instances
