Changeset 324

Show
Ignore:
Timestamp:
08/27/08 15:19:20 (3 months ago)
Author:
wolf
Message:

[FIX] mogenerator: typo in machine template which resulted in single-result version of fetch request wrapper always being picked, even for fetch requests without the "one" prefix in their name.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cocoa/mogenerator/mogeneratorTestMule/MOs/_HumanMO.h

    r319 r324  
    4949 
    5050 
    51 + (id)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_; 
    52 + (id)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ error:(NSError**)error_; 
     51+ (NSArray*)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_; 
     52+ (NSArray*)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ error:(NSError**)error_; 
    5353 
    5454 
  • trunk/cocoa/mogenerator/mogeneratorTestMule/MOs/_HumanMO.m

    r319 r324  
    7878 
    7979 
    80 + (id)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ { 
     80+ (NSArray*)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ { 
    8181        NSError *error = nil; 
    82         id result = [self fetchByHumanName:moc_ humanName:humanName_ error:&error]; 
     82        NSArray *result = [self fetchByHumanName:moc_ humanName:humanName_ error:&error]; 
    8383        if (error) { 
    8484                [NSApp presentError:error]; 
     
    8686        return result; 
    8787} 
    88 + (id)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ error:(NSError**)error_ { 
     88+ (NSArray*)fetchByHumanName:(NSManagedObjectContext*)moc_ humanName:(NSString*)humanName_ error:(NSError**)error_ { 
    8989        NSError *error = nil; 
    9090         
     
    9999        NSAssert(fetchRequest, @"Can't find fetch request named \"byHumanName\"."); 
    100100         
    101         id result = nil; 
    102         NSArray *results = [moc_ executeFetchRequest:fetchRequest error:&error]; 
    103          
    104         if (!error) { 
    105                 switch ([results count]) { 
    106                         case 0: 
    107                                 //      Nothing found matching the fetch request. That's cool, though: we'll just return nil. 
    108                                 break; 
    109                         case 1: 
    110                                 result = [results objectAtIndex:0]; 
    111                                 break; 
    112                         default: 
    113                                 NSAssert1(NO, @"byHumanName: 0 or 1 objects expected, %u found", [results count]); 
    114                 } 
    115         } 
    116          
     101        NSArray *result = [moc_ executeFetchRequest:fetchRequest error:&error]; 
    117102        if (error_) *error_ = error; 
    118103        return result; 
     
    133118         
    134119        NSManagedObjectModel *model = [[moc_ persistentStoreCoordinator] managedObjectModel]; 
    135         NSFetchRequest *fetchRequest = [model fetchRequestFromTemplateWithName:@"oneByHumanName" 
    136                                                                                                          substitutionVariables:[NSDictionary dictionaryWithObjectsAndKeys: 
     120        NSDictionary *substitutionVariables = [NSDictionary dictionaryWithObjectsAndKeys: 
    137121                                                                                                                 
    138122                                                                                                                humanName_, @"humanName", 
    139123                                                                                                                 
    140                                                                                                                 nil] 
    141                                                                                                          ]; 
     124                                                                                                                nil]; 
     125        NSFetchRequest *fetchRequest = [model fetchRequestFromTemplateWithName:@"oneByHumanName" 
     126                                                                                                         substitutionVariables:substitutionVariables]; 
    142127        NSAssert(fetchRequest, @"Can't find fetch request named \"oneByHumanName\"."); 
    143128         
     
    154139                                break; 
    155140                        default: 
    156                                 NSAssert1(NO, @"oneByHumanName: 0 or 1 objects expected, %u found", [results count]); 
     141                                NSLog(@"WARN fetch request oneByHumanName: 0 or 1 objects expected, %u found (substitutionVariables:%@, results:%@)", 
     142                                        [results count], 
     143                                        substitutionVariables, 
     144                                        results); 
    157145                } 
    158146        } 
  • trunk/cocoa/mogenerator/templates/machine.h.motemplate

    r319 r324  
    4949<$endforeach do$> 
    5050<$foreach FetchRequest prettyFetchRequests do$> 
    51 <$if Relationship.singleResult$> 
     51<$if FetchRequest.singleResult$> 
    5252+ (id)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_<$endforeach do2$>; 
    5353+ (id)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_<$endforeach do2$> error:(NSError**)error_; 
  • trunk/cocoa/mogenerator/templates/machine.m.motemplate

    r319 r324  
    117117 
    118118<$foreach FetchRequest prettyFetchRequests do$> 
    119 <$if Relationship.singleResult$> 
     119<$if FetchRequest.singleResult$> 
    120120+ (id)fetch<$FetchRequest.name.initialCapitalString$>:(NSManagedObjectContext*)moc_ <$foreach Binding FetchRequest.bindings do2$><$Binding.name$>:(<$Binding.type$>)<$Binding.name$>_<$endforeach do2$> { 
    121121        NSError *error = nil;