@@ -221,6 +221,7 @@ protected function addDataObjectDBFields(DataObject $dataObject): void
221221 }
222222
223223 $ dbFields = $ dataObject ->config ()->get ('db ' );
224+
224225 if (!is_array ($ dbFields )) {
225226 return ;
226227 }
@@ -270,7 +271,7 @@ protected function addDataObjectHasOneFields(DataObject $dataObject, int $curren
270271 }
271272
272273 // This class has requested that it not be included in relationship maps.
273- $ exclude = Config::inst ()->get ($ relationClassName , 'exclude_from_fixture_relationships ' );
274+ $ exclude = Config::inst ()->get ($ relationFieldName , 'exclude_from_fixture_relationships ' );
274275
275276 if ($ exclude ) {
276277 continue ;
@@ -292,6 +293,7 @@ protected function addDataObjectHasOneFields(DataObject $dataObject, int $curren
292293 if ($ relationClassName == DataObject::class) {
293294 continue ;
294295 }
296+
295297 $ relatedObject = DataObject::get ($ relationClassName )->byID ($ relatedObjectID );
296298
297299 // We expect the relationship to be a DataObject.
@@ -368,19 +370,23 @@ protected function addDataObjectHasManyFields(DataObject $dataObject, int $curre
368370 {
369371 /** @var array $hasManyRelationships */
370372 $ hasManyRelationships = $ dataObject ->config ()->get ('has_many ' );
373+
371374 if (!is_array ($ hasManyRelationships )) {
372375 return ;
373376 }
374377
375378 $ schema = $ dataObject ->getSchema ();
376379
377380 foreach ($ hasManyRelationships as $ relationFieldName => $ relationClassName ) {
381+ // Relationships are sometimes defined as ClassName.FieldName. Drop the .FieldName
382+ $ cleanRelationshipClassName = strtok ($ relationClassName , '. ' );
378383 // Use Schema to make sure that this relationship has a reverse has_one created. This will throw an
379384 // Exception if there isn't (SilverStripe always expects you to have it).
380385 $ schema ->getRemoteJoinField ($ dataObject ->ClassName , $ relationFieldName , 'has_many ' );
381386
382387 // This class has requested that it not be included in relationship maps.
383- $ exclude = Config::inst ()->get ($ relationClassName , 'exclude_from_fixture_relationships ' );
388+ $ exclude = Config::inst ()->get ($ cleanRelationshipClassName , 'exclude_from_fixture_relationships ' );
389+
384390 if ($ exclude ) {
385391 continue ;
386392 }
@@ -402,6 +408,7 @@ protected function addDataObjectManyManyFieldWarnings(DataObject $dataObject, in
402408 {
403409 /** @var array $manyManyRelationships */
404410 $ manyManyRelationships = $ dataObject ->config ()->get ('many_many ' );
411+
405412 if (!is_array ($ manyManyRelationships )) {
406413 return ;
407414 }
@@ -418,11 +425,11 @@ protected function addDataObjectManyManyFieldWarnings(DataObject $dataObject, in
418425
419426 // This many_many relationship is being excluded anyhow, so we're also all good here.
420427 $ exclude = Config::inst ()->get ($ relationshipValue , 'exclude_from_fixture_relationships ' );
428+
421429 if ($ exclude ) {
422430 continue ;
423431 }
424432
425-
426433 // Ok, so, you're probably expecting the fixture to include this relationship... but it won't. Here's your
427434 // warning.
428435 $ this ->addWarning (sprintf (
0 commit comments