Revert "Issue #2527064 by tstoeckler: Nested condition groups in entity queries are broken"
This reverts commit f57b659dc3
.
8.0.x
parent
99aa535dc9
commit
3f5d48181f
|
@ -43,7 +43,7 @@ class Condition extends ConditionBase {
|
||||||
// Add the SQL query to the object before calling this method again.
|
// Add the SQL query to the object before calling this method again.
|
||||||
$sql_condition->sqlQuery = $sql_query;
|
$sql_condition->sqlQuery = $sql_query;
|
||||||
$condition['field']->compile($sql_condition);
|
$condition['field']->compile($sql_condition);
|
||||||
$conditionContainer->condition($sql_condition);
|
$sql_query->condition($sql_condition);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$type = strtoupper($this->conjunction) == 'OR' || $condition['operator'] == 'IS NULL' ? 'LEFT' : 'INNER';
|
$type = strtoupper($this->conjunction) == 'OR' || $condition['operator'] == 'IS NULL' ? 'LEFT' : 'INNER';
|
||||||
|
|
|
@ -40,13 +40,6 @@ class EntityQueryTest extends EntityUnitTestBase {
|
||||||
*/
|
*/
|
||||||
protected $factory;
|
protected $factory;
|
||||||
|
|
||||||
/**
|
|
||||||
* A list of bundle machine names created for this test.
|
|
||||||
*
|
|
||||||
* @var string[]
|
|
||||||
*/
|
|
||||||
protected $bundles;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Field name for the greetings field.
|
* Field name for the greetings field.
|
||||||
*
|
*
|
||||||
|
@ -140,7 +133,6 @@ class EntityQueryTest extends EntityUnitTestBase {
|
||||||
}
|
}
|
||||||
$entity->save();
|
$entity->save();
|
||||||
}
|
}
|
||||||
$this->bundles = $bundles;
|
|
||||||
$this->figures = $figures;
|
$this->figures = $figures;
|
||||||
$this->greetings = $greetings;
|
$this->greetings = $greetings;
|
||||||
$this->factory = \Drupal::service('entity.query');
|
$this->factory = \Drupal::service('entity.query');
|
||||||
|
@ -488,34 +480,6 @@ class EntityQueryTest extends EntityUnitTestBase {
|
||||||
$this->assertFalse($count);
|
$this->assertFalse($count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests that nested condition groups work as expected.
|
|
||||||
*/
|
|
||||||
public function testNestedConditionGroups() {
|
|
||||||
// Query for all entities of the first bundle that have either a red
|
|
||||||
// triangle as a figure or the Turkish greeting as a greeting.
|
|
||||||
$query = $this->factory->get('entity_test_mulrev');
|
|
||||||
|
|
||||||
$first_and = $query->andConditionGroup()
|
|
||||||
->condition($this->figures . '.color', 'red')
|
|
||||||
->condition($this->figures . '.shape', 'triangle');
|
|
||||||
$second_and = $query->andConditionGroup()
|
|
||||||
->condition($this->greetings . '.value', 'merhaba')
|
|
||||||
->condition($this->greetings . '.format', 'format-tr');
|
|
||||||
|
|
||||||
$or = $query->orConditionGroup()
|
|
||||||
->condition($first_and)
|
|
||||||
->condition($second_and);
|
|
||||||
|
|
||||||
$this->queryResults = $query
|
|
||||||
->condition($or)
|
|
||||||
->condition('type', reset($this->bundles))
|
|
||||||
->sort('id')
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
$this->assertResult(6, 14);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function assertResult() {
|
protected function assertResult() {
|
||||||
$assert = array();
|
$assert = array();
|
||||||
$expected = func_get_args();
|
$expected = func_get_args();
|
||||||
|
|
Loading…
Reference in New Issue