Commits

Tuukka Norri committed ad908c3

Bug fixes
- Added some assertions.
- Fixed even more memory leaks.
- -[BXDatabaseContext objectWithID:error:] could earlier perform the fetch without validating first. (This was probably caused by some of our recent modifications.) Fixed this.
- Removed a duplicate method from PGTSQueryDescription.

Comments (0)

Files changed (6)

Sources/BXDatabaseContext.m

     if (nil == retval && [self checkErrorHandling])
     {
         NSError* localError = nil;
+		[self connectIfNeeded: &localError];
+		if (localError)
+			goto error;
+		
+		[self validateEntity: [anID entity] error: &localError];
+		if (localError)
+			goto error;
+		
 		NSArray* objects = [self executeFetchForEntity: (BXEntityDescription *) [anID entity] 
 										 withPredicate: [anID predicate] returningFaults: NO error: &localError];
-        if (nil == localError)
-        {
-            if (0 < [objects count])
-            {
-                retval = [objects objectAtIndex: 0];
-            }
-            else
-            {
-                localError = [NSError errorWithDomain: kBXErrorDomain code: kBXErrorObjectNotFound userInfo: nil];
-            }
-        }
+		if (localError) goto error;
+		
+		if (0 < [objects count])
+			retval = [objects objectAtIndex: 0];
+		else
+		{
+			//FIXME: some human-readable error?
+			localError = [NSError errorWithDomain: kBXErrorDomain code: kBXErrorObjectNotFound userInfo: nil];
+		}
+		
+	error:
         BXHandleError (error, localError);
     }
     return retval;

Sources/BXDatabaseObjectID.m

     if (ok)
     {
         NSDictionary* attributes = [mEntity attributesByName];
+		Expect (attributes);
         NSMutableArray* predicates = [NSMutableArray arrayWithCapacity: [pkeyFValues count]];
     
         TSEnumerate (currentKey, e, [pkeyFValues keyEnumerator])

Sources/BXPGInterface.m

 {
 	ExpectR (entity, NO);
 	ExpectR (error, NO);
+	ExpectR (database, NO);
 	BXPGTableDescription* table = (id) [database table: [entity name] inSchema: [entity schemaName]];
 	if (table)
 	{

Sources/PGTSIndexDescription.h

 
 @interface PGTSIndexDescription : PGTSAbstractClassDescription <PGTSIndexDescription>
 {
-    PGTSTableDescription* mTable;
+    PGTSTableDescription* mTable; //Weak
     NSSet* mFields;
     BOOL mIsPrimaryKey;
     BOOL mIsUnique;

Sources/PGTSIndexDescription.m

 #import "PGTSHOM.h"
 
 
-//FIXME: implement this.
 @implementation PGTSIndexDescriptionProxy
+- (void) dealloc
+{
+	[mFields release];
+	[super dealloc];
+}
+
 - (PGTSTableDescription *) table
 {
 	[[NSException exceptionWithName: NSInternalInconsistencyException reason: @"-[PGTSIndexDescriptionProxy table:] called." userInfo: nil] raise];

Sources/PGTSQueryDescription.m

 	return self;
 }
 
-- (void) dealloc
-{
-	[mQuery release];
-	[mUserInfo release];
-	[super dealloc];
-}
-
 - (SEL) callback
 {
 	return mCallback;