// 1. If the map is joinable, join it. We will want to accept all rows
// which are either not in the map, or marked in the map as NEEDS_UPDATE.
// Note that if high water fields are in play, we want to accept all rows
// above the high water mark in addition to those selected by the map
// conditions, so we need to OR them together (but AND with any existing
// conditions in the query). So, ultimately the SQL condition will look
// like (original conditions) AND (map IS NULL OR map needs update
// OR above high water).
$conditions =
$this->query->
orConditionGroup();
$condition_added = FALSE;
$added_fields =
[];
if ($this->
mapJoinable()) { // Build the join to the map table. Because the source key could have
// multiple fields, we need to build things up.
$count = 1;
$map_join = '';
$delimiter = '';
foreach ($this->
getIds() as $field_name =>
$field_schema) { if (isset($field_schema['alias'
])) { $field_name =
$field_schema['alias'
] . '.' .
$this->query->
escapeField($field_name);
} $map_join .= "
$delimiter$field_name = map.sourceid" .
$count++;
$delimiter = ' AND ';
}