Commits

Tuukka Norri  committed 4887b2f

Added some assertions and a call for cache pruning

  • Participants
  • Parent commits c0e5230

Comments (0)

Files changed (5)

File Sources/BXAttributeDescription.m

 {
 	BXEntityDescription* entity = [self entity];
 	CFSetCallBacks callbacks = PGTSScannedSetCallbacks ();
+	ExpectV ([rel destinationEntity]);
 	if ([[rel entity] isEqual: entity])
 	{
 		if (! mRelationshipsUsing)

File Sources/BXEntityDescription.m

  * \ingroup descriptions
  */
 @implementation BXEntityDescription
-
 + (void) initialize
 {
     static BOOL tooLate = NO;
         TSEnumerate (currentRel, e, [mRelationships objectEnumerator])
         {
             [currentRel setEntity: nil];
-            [[currentRel inverseRelationship] setDestinationEntity: nil];
+			[currentRel removeAttributeDependency];
+			BXRelationshipDescription* inverse = [(BXRelationshipDescription *) currentRel inverseRelationship];
+            [inverse removeDestinationEntity];
+			[inverse removeAttributeDependency];
 			[[currentRel class] unregisterProperty: currentRel entity: self];
         }
     }
 {
 	return [mRelationships PGTSValueSelectFunction: &InverseToOneRelationships];
 }
+
+
++ (id) cachedEntities
+{
+	return gEntities;
+}
 @end

File Sources/BXEntityDescriptionPrivate.h

 
 
 @interface BXEntityDescription (PrivateMethods)
++ (id) cachedEntities;
 - (NSURL *) entityKey;
 + (NSURL *) entityKeyForDatabaseURI: (NSURL *) databaseURI schema: (NSString *) schemaName table: (NSString *) tableName;
 + (id) entityWithDatabaseURI: (NSURL *) anURI table: (NSString *) tName inSchema: (NSString *) sName;

File Sources/BXRelationshipDescription.m

 
 
 @implementation BXRelationshipDescription (PrivateMethods)
-- (id) initWithName: (NSString *) name entity: (BXEntityDescription *) entity 
+- (id) initWithName: (NSString *) name 
+			 entity: (BXEntityDescription *) entity 
   destinationEntity: (BXEntityDescription *) destinationEntity
 {
+	Expect (name);
+	Expect (entity);
+	Expect (destinationEntity);
+	
 	if ((self = [super initWithName: name entity: entity]))
 	{
 		mDestinationEntity = destinationEntity;
 	return self;
 }
 
-- (void) setDestinationEntity: (BXEntityDescription *) entity
+- (void) removeDestinationEntity
 {
-	if (! entity)
-		[[self entity] removeRelationship: self];
-	mDestinationEntity = entity;
+	[[self entity] removeRelationship: self];
+	mDestinationEntity = nil;
 }
 
 

File Sources/BXRelationshipDescriptionPrivate.h

 - (id) initWithName: (NSString *) aName entity: (BXEntityDescription *) entity 
   destinationEntity: (BXEntityDescription *) destinationEntity;
 - (BXForeignKey *) foreignKey;
-- (void) setDestinationEntity: (BXEntityDescription *) entity;
+- (void) removeDestinationEntity;
 - (void) setForeignKey: (BXForeignKey *) aKey;
 - (BOOL) isInverse;
 - (void) setIsInverse: (BOOL) aBool;