Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

implement correctly generated fetch requests with repeating variables.

  • Loading branch information...
commit 716b22457b9a2473357e8b1d2e6c17304ba22d87 1 parent e834411
Sergei Winitzki authored
Showing with 16 additions and 2 deletions.
  1. +16 −2 mogenerator.m
View
18 mogenerator.m
@@ -179,6 +179,18 @@ - (NSString *)_resolveKeyPathType:(NSString *)keyPath {
return [entity managedObjectClassName];
}
+// changes by Sergei Winitzki
+// auxiliary function
+- (BOOL) bindingsArray:(NSArray *)bindings containsVariableNamed:(NSString *)name {
+ for (NSDictionary *dict in bindings) {
+ if ([[dict objectForKey:@"name"] isEqual:name]) {
+ return YES;
+ }
+ }
+ return NO;
+}
+// end of changes by Sergei Winitzki
+
- (void)_processPredicate:(NSPredicate*)predicate_ bindings:(NSMutableArray*)bindings_ {
if (!predicate_) return;
@@ -209,11 +221,13 @@ - (void)_processPredicate:(NSPredicate*)predicate_ bindings:(NSMutableArray*)bin
type = [self _resolveKeyPathType:[lhs keyPath]];
}
type = [type stringByAppendingString:@"*"];
-
- [bindings_ addObject:[NSDictionary dictionaryWithObjectsAndKeys:
+ // changes by Sergei Winitzki: 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]];
+ } // end of changes by Sergei Winitzki
} break;
default:
assert(0 && "unknown NSExpression type");
Please sign in to comment.
Something went wrong with that request. Please try again.