Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #125 from winitzki/master

[FIX] Correct generation of fetch requests with repeated variables. (Sergei Winitzki)
  • Loading branch information...
commit 4334e67c0d33ddd7733748a6deb2256323d33115 2 parents e834411 + 12bd8c0
@rentzsch authored
Showing with 14 additions and 2 deletions.
  1. +14 −2 mogenerator.m
View
16 mogenerator.m
@@ -179,6 +179,16 @@ - (NSString *)_resolveKeyPathType:(NSString *)keyPath {
return [entity managedObjectClassName];
}
+// auxiliary function
+- (BOOL) bindingsArray:(NSArray *)bindings containsVariableNamed:(NSString *)name {
+ for (NSDictionary *dict in bindings) {
+ if ([[dict objectForKey:@"name"] isEqual:name]) {
+ return YES;
+ }
+ }
+ return NO;
+}
+
- (void)_processPredicate:(NSPredicate*)predicate_ bindings:(NSMutableArray*)bindings_ {
if (!predicate_) return;
@@ -209,11 +219,13 @@ - (void)_processPredicate:(NSPredicate*)predicate_ bindings:(NSMutableArray*)bin
type = [self _resolveKeyPathType:[lhs keyPath]];
}
type = [type stringByAppendingString:@"*"];
-
- [bindings_ addObject:[NSDictionary dictionaryWithObjectsAndKeys:
+ // make sure that no repeated variables are entered here.
+ if (![self bindingsArray:bindings_ containsVariableNamed:[rhs variable]]) {
+ [bindings_ addObject:[NSDictionary dictionaryWithObjectsAndKeys:
[rhs variable], @"name",
type, @"type",
nil]];
+ }
} break;
default:
assert(0 && "unknown NSExpression type");
Please sign in to comment.
Something went wrong with that request. Please try again.