Change record status: 
Project: 
Introduced in branch: 
9.1.x
Introduced in version: 
9.1.0
Description: 

Creating an instance of the class Drupal\Core\Database\Query\Condition with the keyword new is deprecated. A Condition instance should be created by calling the method Drupal\Core\Database\Connection::condition(). This change is necessary because the class Condition is not the same for all databases. Therefore having a generic Condition class for all databases is no longer possible.

Before:

  use Drupal\Core\Database\Query\Condition;

  $condition = new Condition('OR');

After:

  use Drupal\Core\Database\Database;

  $condition = Database::getConnection()->condition('OR');

API addition:
Add the method Drupal\Core\Database\Query\Query::getConnection(). It will return the database connection to be used for the query. The class Drupal\Core\Database\Query\Query is the base class for: Drupal\Core\Database\Query\Delete, Drupal\Core\Database\Query\Insert, Drupal\Core\Database\Query\Merge, Drupal\Core\Database\Query\Select, Drupal\Core\Database\Query\Truncate, Drupal\Core\Database\Query\Update and Drupal\Core\Database\Query\Upsert.

Impacts: 
Module developers