Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/workspaces/src/EntityQuery/Query.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
10 class Query extends BaseQuery { | 10 class Query extends BaseQuery { |
11 | 11 |
12 use QueryTrait { | 12 use QueryTrait { |
13 prepare as traitPrepare; | 13 prepare as traitPrepare; |
14 } | 14 } |
15 | |
16 /** | |
17 * Stores the SQL expressions used to build the SQL query. | |
18 * | |
19 * The array is keyed by the expression alias and the values are the actual | |
20 * expressions. | |
21 * | |
22 * @var array | |
23 * An array of expressions. | |
24 */ | |
25 protected $sqlExpressions = []; | |
26 | 15 |
27 /** | 16 /** |
28 * {@inheritdoc} | 17 * {@inheritdoc} |
29 */ | 18 */ |
30 public function prepare() { | 19 public function prepare() { |
40 // Since the query is against the base table, we have to take into account | 29 // Since the query is against the base table, we have to take into account |
41 // that the revision ID might come from the workspace_association | 30 // that the revision ID might come from the workspace_association |
42 // relationship, and, as a consequence, the revision ID field is no longer | 31 // relationship, and, as a consequence, the revision ID field is no longer |
43 // a simple SQL field but an expression. | 32 // a simple SQL field but an expression. |
44 $this->sqlFields = []; | 33 $this->sqlFields = []; |
45 $this->sqlExpressions[$revision_field] = "COALESCE(workspace_association.target_entity_revision_id, base_table.$revision_field)"; | 34 $this->sqlQuery->addExpression("COALESCE(workspace_association.target_entity_revision_id, base_table.$revision_field)", $revision_field); |
46 $this->sqlExpressions[$id_field] = "base_table.$id_field"; | 35 $this->sqlQuery->addExpression("base_table.$id_field", $id_field); |
36 | |
37 $this->sqlGroupBy['workspace_association.target_entity_revision_id'] = 'workspace_association.target_entity_revision_id'; | |
38 $this->sqlGroupBy["base_table.$id_field"] = "base_table.$id_field"; | |
39 $this->sqlGroupBy["base_table.$revision_field"] = "base_table.$revision_field"; | |
47 } | 40 } |
48 | 41 |
49 return $this; | 42 return $this; |
50 } | 43 } |
51 | 44 |
52 /** | |
53 * {@inheritdoc} | |
54 */ | |
55 protected function finish() { | |
56 foreach ($this->sqlExpressions as $alias => $expression) { | |
57 $this->sqlQuery->addExpression($expression, $alias); | |
58 } | |
59 return parent::finish(); | |
60 } | |
61 | |
62 } | 45 } |