Commits

Tuukka Norri  committed 798893e

Changed expression creation so that nil is returned instead of () in case of an empty predicate
- References #115.
- Didn't test this yet, though.

  • Participants
  • Parent commits e2a6bae
  • Branches PGTS

Comments (0)

Files changed (2)

File TigerFramework/PGTSTiger.xcodeproj/project.pbxproj

 		0867D690FE84028FC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "PGTSTiger" */;
-			compatibilityVersion = "Xcode 2.4";
 			hasScannedForEncodings = 1;
 			mainGroup = 0867D691FE84028FC02AAC07 /* PGTSTiger */;
 			productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;

File TigerFramework/Sources/NSPredicate+PGTSAdditions.m

 {
     log4AssertValueReturn (nil != [context objectForKey: kPGTSConnectionKey], nil, 
 						   @"Did you remember to set connection to %@ in context?", kPGTSConnectionKey);
-    NSString* rval = nil;
+    NSString* retval = nil;
     NSArray* subpredicates = [self subpredicates];
     NSMutableArray* parts = [NSMutableArray arrayWithCapacity: [subpredicates count]];
     TSEnumerate (currentPredicate, e, [subpredicates objectEnumerator])
     
     NSString* glue = nil;
     NSCompoundPredicateType type = [self compoundPredicateType];
-    if (NSNotPredicateType == type)
-        rval = [NSString stringWithFormat: @"(NOT %@)", [parts objectAtIndex: 0]];
-    else
-    {
-        switch (type)
-        {
-            case NSAndPredicateType:
-                glue = @" AND ";
-                break;
-            case NSOrPredicateType:
-                glue = @" OR ";
-                break;
-            default:
-                //FIXME: exception
-                break;
-        }
-        rval = [NSString stringWithFormat: @"(%@)", [parts componentsJoinedByString: glue]];
+	if (0 < [parts count])
+	{
+		if (NSNotPredicateType == type)
+			retval = [NSString stringWithFormat: @"(NOT %@)", [parts objectAtIndex: 0]];
+		else
+		{
+			switch (type)
+			{
+				case NSAndPredicateType:
+					glue = @" AND ";
+					break;
+				case NSOrPredicateType:
+					glue = @" OR ";
+					break;
+				default:
+					//FIXME: exception
+					break;
+			}
+			retval = [NSString stringWithFormat: @"(%@)", [parts componentsJoinedByString: glue]];
+		}
     }
-    return rval;
+    return retval;
 }
 @end