Skip to content

Commit 4e3cad4

Browse files
committed
Modify sanity checks to better handle common scenerios related to inner joins
1 parent d60925d commit 4e3cad4

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/Objects/Migrator.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,19 @@ private function sanityCheck()
148148
$this->fieldsToMigrate = $this->source->getFields();
149149
}
150150

151+
$postDotFieldsToMigrate = array_map(function ($field) {
152+
$fieldParts = explode('.', $field);
153+
return end($fieldParts);
154+
}, $this->fieldsToMigrate);
155+
151156
foreach (array_keys($this->fieldMap) as $sourceField) {
152-
if (!in_array($sourceField, $this->fieldsToMigrate)) {
157+
if (!in_array($sourceField, $this->fieldsToMigrate) && !in_array($sourceField, $postDotFieldsToMigrate)) {
153158
throw new MissingFieldToMigrateException('The source field `'.$sourceField.'` is present in the field map but not present in the fields to migrate.');
154159
}
155160
}
156161

157162
foreach ($this->keyFields as $keyField) {
158-
if (!in_array($keyField, $this->fieldsToMigrate)) {
163+
if (!in_array($keyField, $this->fieldsToMigrate) && !in_array($keyField, $postDotFieldsToMigrate)) {
159164
throw new MissingFieldToMigrateException('The field `'.$keyField.'` is present in the key fields list but not present in the fields to migrate.');
160165
}
161166
}

0 commit comments

Comments
 (0)