@@ -401,6 +401,32 @@ public void streamRelationHydrationMustFailRatherThanReturnPartialEntity() {
401401 }
402402 }
403403
404+ @ Test
405+ public void schemaOnlyRepositoryMustNotHydrateRelationFromGlobalMetadata () {
406+ registerTopNFixture ();
407+ EntityDescriptor child = metaFactory .resolveEntityDescriptor ("TopNChild" );
408+ PortableSQLRepository <TopNChild > schemaOnlyRepository =
409+ new PortableSQLRepository <>(child , sqliteDb , null );
410+ TopNChildRequest request = new TopNChildRequest ()
411+ .where ("id" , Operator .EQUAL , 11L )
412+ .comment ("load relation without a runtime metadata snapshot" );
413+ request .purpose ("prove a schema-only repository cannot borrow global metadata" );
414+
415+ EntityMetaFactory previousGlobal = EntityMetaFactory .get ();
416+ EntityMetaFactory .registerGlobal (metaFactory );
417+ try (var rows = schemaOnlyRepository .streamInternal (context , request )) {
418+ rows .findFirst ();
419+ fail ("A schema-only repository must not resolve a relation from global metadata" );
420+ } catch (TeaQLRuntimeException failure ) {
421+ assertTrue (failure .getMessage (), failure .getMessage ().contains ("TopNChild.parent" ));
422+ assertTrue (failure .getCause () instanceof IllegalStateException );
423+ assertTrue (failure .getCause ().getMessage (),
424+ failure .getCause ().getMessage ().contains ("no runtime metadata snapshot" ));
425+ } finally {
426+ EntityMetaFactory .registerGlobal (previousGlobal );
427+ }
428+ }
429+
404430 @ Test
405431 public void testConstantBootstrapIsIdempotentAndReconcilesModelChanges () throws Exception {
406432 SQLiteTeaQLDatabase database = new SQLiteTeaQLDatabase ();
0 commit comments