Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3421017
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3421017
Commits
4b505654
Commit
4b505654
authored
8 years ago
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2808333
by chx: Factor out the join from Tables.php
parent
a491c499
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
+27
-2
27 additions, 2 deletions
core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
with
27 additions
and
2 deletions
core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
+
27
−
2
View file @
4b505654
...
...
@@ -3,6 +3,7 @@
namespace
Drupal\Core\Entity\Query\Sql
;
use
Drupal\Core\Database\Query\SelectInterface
;
use
Drupal\Core\Entity\EntityType
;
use
Drupal\Core\Entity\Query\QueryException
;
use
Drupal\Core\Entity\Sql\SqlEntityStorageInterface
;
use
Drupal\Core\Entity\Sql\TableMappingInterface
;
...
...
@@ -260,8 +261,7 @@ public function addField($field, $type, $langcode) {
$entity_type
=
$this
->
entityManager
->
getDefinition
(
$entity_type_id
);
$field_storage_definitions
=
$this
->
entityManager
->
getFieldStorageDefinitions
(
$entity_type_id
);
// Add the new entity base table using the table and sql column.
$join_condition
=
'%alias.'
.
$entity_type
->
getKey
(
'id'
)
.
" =
$table
.
$sql_column
"
;
$base_table
=
$this
->
sqlQuery
->
leftJoin
(
$entity_type
->
getBaseTable
(),
NULL
,
$join_condition
);
$base_table
=
$this
->
addNextBaseTable
(
$entity_type
,
$table
,
$sql_column
);
$propertyDefinitions
=
array
();
$key
++
;
$index_prefix
.
=
"
$next_index_prefix
."
;
...
...
@@ -367,4 +367,29 @@ protected function getTableMapping($table, $entity_type_id) {
return
array_flip
(
$mapping
);
}
/**
* Add the next entity base table.
*
* For example, when building the SQL query for
* @code
* condition('uid.entity.name', 'foo', 'CONTAINS')
* @endcode
*
* this adds the users table.
*
* @param \Drupal\Core\Entity\EntityType $entity_type
* The entity type being joined, in the above example, User.
* @param string $table
* This is the table being joined, in the above example, {users}.
* @param string $sql_column
* This is the SQL column in the existing table being joined to.
*
* @return string
* The alias of the next entity table joined in.
*/
protected
function
addNextBaseTable
(
EntityType
$entity_type
,
$table
,
$sql_column
)
{
$join_condition
=
'%alias.'
.
$entity_type
->
getKey
(
'id'
)
.
" =
$table
.
$sql_column
"
;
return
$this
->
sqlQuery
->
leftJoin
(
$entity_type
->
getBaseTable
(),
NULL
,
$join_condition
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment