int cnt, tc = [_tableNames count];
for (cnt = 0; cnt < tc; cnt++) {
- NSMutableDictionary *relNamesUsed =
- [NSMutableDictionary dictionaryWithCapacity:16];
- NSMutableArray *classProperties =
- [NSMutableArray arrayWithCapacity:16];
- NSMutableArray *primaryKeyAttributes =
- [NSMutableArray arrayWithCapacity:2];
- NSString *tableName = [_tableNames objectAtIndex:cnt];
- NSArray *attributes = [self _attributesForTableName:tableName];
- NSArray *pkeys = [self _primaryKeysNamesForTableName:tableName];
- NSArray *fkeys = [self _foreignKeysForTableName:tableName];
- EOEntity *entity = [[EOEntity new] autorelease];
- int cnt2;
- int ac = [attributes count];
- int fkc = [fkeys count];
-
+ NSMutableDictionary *relNamesUsed;
+ NSMutableArray *classProperties, *primaryKeyAttributes;
+ NSString *tableName;
+ NSArray *attributes, *pkeys, *fkeys;
+ EOEntity *entity;
+ int cnt2, ac, fkc;
+
+ relNamesUsed = [NSMutableDictionary dictionaryWithCapacity:16];
+ classProperties = [NSMutableArray arrayWithCapacity:16];
+ primaryKeyAttributes = [NSMutableArray arrayWithCapacity:2];
+ tableName = [_tableNames objectAtIndex:cnt];
+ attributes = [self _attributesForTableName:tableName];
+ pkeys = [self _primaryKeysNamesForTableName:tableName];
+ fkeys = [self _foreignKeysForTableName:tableName];
+ entity = [[[EOEntity alloc] init] autorelease];
+ ac = [attributes count];
+ fkc = [fkeys count];
+
[entity setName:[tableName _mySQL4ModelMakeClassName]];
[entity setClassName:
- [@"EO" stringByAppendingString:[tableName _mySQL4ModelMakeClassName]]];
+ [@"EO" stringByAppendingString:
+ [tableName _mySQL4ModelMakeClassName]]];
[entity setExternalName:tableName];
[classProperties addObjectsFromArray:[entity classProperties]];
[primaryKeyAttributes addObjectsFromArray:[entity primaryKeyAttributes]];
[entity setPrimaryKeyAttributes:primaryKeyAttributes];
for (cnt2 = 0; cnt2 < fkc; cnt2++) {
- NSDictionary *fkey = [fkeys objectAtIndex:cnt2];
- NSMutableArray *classProperties =
- AUTORELEASE([NSMutableArray new]);
- NSString *sa = [fkey objectForKey:@"sourceAttr"];
- NSString *da = [fkey objectForKey:@"targetAttr"];
- NSString *dt = [fkey objectForKey:@"targetTable"];
- EORelationship *rel =
- [[[EORelationship alloc] init] autorelease];
- EOJoin *join =
- [[[EOJoin alloc] init] autorelease];
- NSString *relName = nil;
-
+ NSDictionary *fkey;
+ NSMutableArray *classProperties;
+ NSString *sa, *da, *dt;
+ EORelationship *rel;
+ EOJoin *join; // TODO: fix me, EOJoin is deprecated
+ NSString *relName;
+
+ fkey = [fkeys objectAtIndex:cnt2];
+ classProperties = [NSMutableArray arrayWithCapacity:8];
+ sa = [fkey objectForKey:@"sourceAttr"];
+ da = [fkey objectForKey:@"targetAttr"];
+ dt = [fkey objectForKey:@"targetTable"];
+ rel = [[[EORelationship alloc] init] autorelease];
+
+ // TODO: fix me
+ join = [[[NSClassFromString(@"EOJoin") alloc] init] autorelease];
+
if ([pkeys containsObject:sa]) {
relName = [@"to" stringByAppendingString:
[dt _mySQL4ModelMakeClassName]];