Skip to content
Snippets Groups Projects
Commit b083e407 authored by catch's avatar catch
Browse files

Revert "Issue #3311562 by Berdir, andypost: Set sqlQuery in Entity\Query\Sql...

Revert "Issue #3311562 by Berdir, andypost: Set sqlQuery in Entity\Query\Sql Condition classes on own class"

This reverts commit 075c6914.
parent 6dfe9bf4
No related branches found
No related tags found
No related merge requests found
...@@ -25,13 +25,6 @@ class Condition extends ConditionBase { ...@@ -25,13 +25,6 @@ class Condition extends ConditionBase {
*/ */
protected $query; protected $query;
/**
* The current SQL query, set by parent condition compile() method calls.
*
* @var \Drupal\Core\Database\Query\SelectInterface
*/
protected SelectInterface $sqlQuery;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -42,13 +35,13 @@ public function compile($conditionContainer) { ...@@ -42,13 +35,13 @@ public function compile($conditionContainer) {
// SQL query object is only necessary to pass to Query::addField() so it // SQL query object is only necessary to pass to Query::addField() so it
// can join tables as necessary. On the other hand, conditions need to be // can join tables as necessary. On the other hand, conditions need to be
// added to the $conditionContainer object to keep grouping. // added to the $conditionContainer object to keep grouping.
$sql_query = $conditionContainer instanceof SelectInterface ? $conditionContainer : $this->sqlQuery; $sql_query = $conditionContainer instanceof SelectInterface ? $conditionContainer : $conditionContainer->sqlQuery;
$tables = $this->query->getTables($sql_query); $tables = $this->query->getTables($sql_query);
foreach ($this->conditions as $condition) { foreach ($this->conditions as $condition) {
if ($condition['field'] instanceof ConditionInterface) { if ($condition['field'] instanceof ConditionInterface) {
$sql_condition = $sql_query->getConnection()->condition($condition['field']->getConjunction()); $sql_condition = $sql_query->getConnection()->condition($condition['field']->getConjunction());
// Add the SQL query to the object before calling this method again. // Add the SQL query to the object before calling this method again.
$condition['field']->sqlQuery = $sql_query; $sql_condition->sqlQuery = $sql_query;
$condition['field']->nestedInsideOrCondition = $this->nestedInsideOrCondition || strtoupper($this->conjunction) === 'OR'; $condition['field']->nestedInsideOrCondition = $this->nestedInsideOrCondition || strtoupper($this->conjunction) === 'OR';
$condition['field']->compile($sql_condition); $condition['field']->compile($sql_condition);
$conditionContainer->condition($sql_condition); $conditionContainer->condition($sql_condition);
......
...@@ -12,13 +12,6 @@ ...@@ -12,13 +12,6 @@
*/ */
class ConditionAggregate extends ConditionAggregateBase { class ConditionAggregate extends ConditionAggregateBase {
/**
* The current SQL query, set by parent condition compile() method calls.
*
* @var \Drupal\Core\Database\Query\SelectInterface
*/
protected SelectInterface $sqlQuery;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -28,13 +21,13 @@ public function compile($conditionContainer) { ...@@ -28,13 +21,13 @@ public function compile($conditionContainer) {
// SQL query object is only necessary to pass to Query::addField() so it // SQL query object is only necessary to pass to Query::addField() so it
// can join tables as necessary. On the other hand, conditions need to be // can join tables as necessary. On the other hand, conditions need to be
// added to the $conditionContainer object to keep grouping. // added to the $conditionContainer object to keep grouping.
$sql_query = ($conditionContainer instanceof SelectInterface) ? $conditionContainer : $this->sqlQuery; $sql_query = ($conditionContainer instanceof SelectInterface) ? $conditionContainer : $conditionContainer->sqlQuery;
$tables = new Tables($sql_query); $tables = new Tables($sql_query);
foreach ($this->conditions as $condition) { foreach ($this->conditions as $condition) {
if ($condition['field'] instanceof ConditionAggregateInterface) { if ($condition['field'] instanceof ConditionAggregateInterface) {
$sql_condition = $sql_query->getConnection()->condition($condition['field']->getConjunction()); $sql_condition = $sql_query->getConnection()->condition($condition['field']->getConjunction());
// Add the SQL query to the object before calling this method again. // Add the SQL query to the object before calling this method again.
$condition['field']->sqlQuery = $sql_query; $sql_condition->sqlQuery = $sql_query;
$condition['field']->compile($sql_condition); $condition['field']->compile($sql_condition);
$sql_query->condition($sql_condition); $sql_query->condition($sql_condition);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment