+2005-04-12 Helge Hess <helge.hess@opengroupware.org>
+
+ * v4.5.49
+
+ * fixed various gcc 3.4.3 warnings
+
+ * removed support for unused EOAttribute features like flattened,
+ derived, read-only, insert/update formats, definition
+
2005-03-15 Helge Hess <helge.hess@opengroupware.org>
* FoundationExt/GNUmakefile: properly include config.make (v4.5.48)
self->connectionDictionary];
[newGID autorelease];
}
- [_obj setObject:newGID forKey:@"globalID"];
+ [(NSMutableDictionary *)_obj setObject:newGID forKey:@"globalID"];
}
[self postDataSourceChangedNotification];
}
NSTimeZone *clientTimeZone;
NSTimeZone *serverTimeZone;
NSString *columnName;
- NSString *definition;
NSString *externalType;
NSString *valueClassName;
NSString *valueType;
- NSString *insertFormat;
- NSString *selectFormat;
- NSString *updateFormat;
NSDictionary *userDictionary;
-
- /* Garbage collectable objects */
- EOEntity *entity; /* non-retained */
- NSMutableArray *definitionArray; // These variables are meaningful only
- EOAttribute *realAttribute; // if the attribute is flattened
- unsigned width;
+ EOEntity *entity; /* non-retained */
+ unsigned width;
struct {
- BOOL isReadOnly:1;
- BOOL isDerived:1;
- BOOL isFlattened:1;
- BOOL allowsNull:1;
+ int allowsNull:1;
+ int reserved:31;
} flags;
}
/* Initializing new instances */
-- (id)initWithName:(NSString*)name;
+- (id)initWithName:(NSString *)name;
/* Accessing the entity */
- (void)setEntity:(EOEntity*)entity;
- (BOOL)hasEntity;
/* Accessing the name */
-- (BOOL)setName:(NSString*)name;
-- (NSString*)name;
-+ (BOOL)isValidName:(NSString*)name;
+- (BOOL)setName:(NSString *)name;
+- (NSString *)name;
++ (BOOL)isValidName:(NSString *)name;
/* Accessing date information */
-+ (NSString*)defaultCalendarFormat;
-- (void)setCalendarFormat:(NSString*)format;
-- (NSString*)calendarFormat;
++ (NSString *)defaultCalendarFormat;
+- (void)setCalendarFormat:(NSString *)format;
+- (NSString *)calendarFormat;
- (void)setClientTimeZone:(NSTimeZone*)tz;
- (NSTimeZone*)clientTimeZone;
- (void)setServerTimeZone:(NSTimeZone*)tz;
- (NSTimeZone*)serverTimeZone;
/* Accessing external definitions */
-- (void)setColumnName:(NSString*)columnName;
-- (NSString*)columnName;
-- (void)setDefinition:(NSString*)definition;
-- (NSString*)definition;
-- (NSMutableArray*)definitionArray;
-- (void)setExternalType:(NSString*)type;
-- (NSString*)externalType;
+- (void)setColumnName:(NSString *)columnName;
+- (NSString *)columnName;
+- (void)setExternalType:(NSString *)type;
+- (NSString *)externalType;
/* Accessing value type information */
-- (void)setValueClassName:(NSString*)name;
-- (NSString*)valueClassName;
-- (void)setValueType:(NSString*)type;
-- (NSString*)valueType;
+- (void)setValueClassName:(NSString *)name;
+- (NSString *)valueClassName;
+- (void)setValueType:(NSString *)type;
+- (NSString *)valueType;
/* Checking type information */
- (BOOL)referencesProperty:property;
-- (BOOL)isDerived;
-- (BOOL)isFlattened;
-- (BOOL)setReadOnly:(BOOL)flag;
-- (BOOL)isReadOnly;
-
-/* Accessing SQL statement formats */
-- (void)setInsertFormat:(NSString*)string;
-- (NSString*)insertFormat;
-- (void)setSelectFormat:(NSString*)string;
-- (NSString*)selectFormat;
-- (void)setUpdateFormat:(NSString*)string;
-- (NSString*)updateFormat;
/* Accessing the user dictionary */
- (void)setUserDictionary:(NSDictionary*)dictionary;
- (NSException *)validateValue:(id *)_value;
-- (NSString *)readFormat;
-- (NSString *)writeFormat;
-
@end
#endif /* __EOAttribute_h__ */
}
- (void)dealloc {
- RELEASE(self->name);
- RELEASE(self->calendarFormat);
- RELEASE(self->clientTimeZone);
- RELEASE(self->serverTimeZone);
- RELEASE(self->columnName);
- RELEASE(self->definition);
- RELEASE(self->externalType);
- RELEASE(self->valueClassName);
- RELEASE(self->valueType);
- RELEASE(self->insertFormat);
- RELEASE(self->selectFormat);
- RELEASE(self->updateFormat);
- RELEASE(self->userDictionary);
+ [self->name release];
+ [self->calendarFormat release];
+ [self->clientTimeZone release];
+ [self->serverTimeZone release];
+ [self->columnName release];
+ [self->externalType release];
+ [self->valueClassName release];
+ [self->valueType release];
+ [self->userDictionary release];
self->entity = nil; /* non-retained */
- RELEASE(self->definitionArray);
- RELEASE(self->realAttribute);
[super dealloc];
}
// These methods should be here to let the library work with NeXT foundation
- (id)copy {
- return RETAIN(self);
+ return [self retain];
}
- (id)copyWithZone:(NSZone *)_zone {
- return RETAIN(self);
+ return [self retain];
}
// Is equal only if same name; used to make aliasing ordering stable
return [EOEntity isValidName:_name];
}
-- (BOOL)setReadOnly:(BOOL)flag {
- if(!flag && ([self isDerived] || [self isFlattened]))
- return NO;
- flags.isReadOnly = flag;
- return YES;
-}
-
-- (BOOL)referencesProperty:(id)property {
- return (flags.isDerived)
- ? [self->definitionArray indexOfObject:property] != NSNotFound
- : NO;
-}
-
-- (void)setDefinition:(NSString *)def {
- NSArray *defArray;
- int i, count;
- EOEntity *currentEntity;
- id realAttributeName;
-
- if (def == nil) {
- [NSException raise:NSInvalidArgumentException
- format:@"invalid (nil) definition argument!"];
- }
-
- self->flags.isDerived = YES;
- self->flags.isFlattened = NO;
-
- ASSIGN(self->definition, def);
-
- if ([definition isNameOfARelationshipPath]) {
- self->flags.isFlattened = YES;
- defArray = [definition componentsSeparatedByString:@"."];
- count = [defArray count];
-
- RELEASE(self->definitionArray);
- self->definitionArray = [[NSMutableArray alloc] initWithCapacity:count];
-
- NS_DURING {
- currentEntity = self->entity;
-
- for (i = 0; i < count - 1; i++) {
- id relationshipName, relationship;
-
- relationshipName = [defArray objectAtIndex:i];
-
- if(![EOEntity isValidName:relationshipName]) {
- [[[InvalidNameException alloc]
- initWithName:relationshipName] raise];
- }
-
- relationship
- = [currentEntity relationshipNamed:relationshipName];
-
- if(relationship == nil) {
- [[[InvalidPropertyException alloc]
- initWithName:relationshipName entity:currentEntity] raise];
- }
- if([relationship isToMany]) {
- [[[RelationshipMustBeToOneException alloc]
- initWithName:relationshipName entity:currentEntity] raise];
- }
- [self->definitionArray addObject:relationship];
- currentEntity = [relationship destinationEntity];
- }
- realAttributeName = [defArray lastObject];
-
- RELEASE(self->realAttribute);
- self->realAttribute =
- RETAIN([currentEntity attributeNamed:realAttributeName]);
- if (self->realAttribute == nil) {
- [[[InvalidPropertyException alloc]
- initWithName:realAttributeName entity:currentEntity] raise];
- }
- [self->definitionArray addObject:self->realAttribute];
- }
- NS_HANDLER {
- RELEASE(self->definitionArray);
- self->definitionArray = nil;
- [localException raise];
- }
- NS_ENDHANDLER;
- }
- else {
- [self->definitionArray release];
- self->definitionArray = nil;
- self->definitionArray
- = [[EOExpressionArray parseExpression:definition
- entity:entity
- replacePropertyReferences:YES]
- retain];
- }
+- (BOOL)referencesProperty:(id)property { // TODO: still used?
+ return NO;
}
- (NSString *)expressionValueForContext:(id<EOExpressionContext>)context {
return self->serverTimeZone;
}
-- (void)setColumnName:(NSString*)_name {
- ASSIGN(self->columnName, _name);
+- (void)setColumnName:(NSString *)_name {
+ ASSIGNCOPY(self->columnName, _name);
}
- (NSString *)columnName {
return self->columnName;
}
-- (void)setExternalType:(NSString*)type {
- ASSIGN(self->externalType, type);
+- (void)setExternalType:(NSString *)type {
+ ASSIGNCOPY(self->externalType, type);
}
- (NSString *)externalType {
- return ((self->externalType == nil) && self->flags.isFlattened)
- ? [self->realAttribute externalType]
- : self->externalType;
+ return self->externalType;
}
- (void)setValueClassName:(NSString *)_name {
- ASSIGN(self->valueClassName, _name);
+ ASSIGNCOPY(self->valueClassName, _name);
}
- (NSString *)valueClassName {
- return ((self->valueClassName == nil) && self->flags.isFlattened)
- ? [self->realAttribute valueClassName]
- : self->valueClassName;
+ return self->valueClassName;
}
- (void)setValueType:(NSString *)type {
ASSIGN(self->valueType, type);
}
- (NSString *)valueType {
- return ((self->valueType == nil) && self->flags.isFlattened)
- ? [self->realAttribute valueType]
- : self->valueType;
-}
-
-- (void)setInsertFormat:(NSString *)string {
- ASSIGN(self->insertFormat, string);
-}
-- (NSString *)insertFormat {
- return self->insertFormat;
-}
-
-- (void)setSelectFormat:(NSString *)string {
- ASSIGN(self->selectFormat, string);
-}
-- (NSString *)selectFormat {
- return self->selectFormat;
-}
-
-- (void)setUpdateFormat:(NSString*)string {
- ASSIGN(self->updateFormat, string);
-}
-- (NSString *)updateFormat {
- return self->updateFormat;
+ return self->valueType;
}
- (void)setUserDictionary:(NSDictionary *)dict {
- (NSString *)name {
return self->name;
}
-- (NSString *)definition {
- return self->definition;
-}
-- (NSMutableArray *)definitionArray {
- return self->definitionArray;
-}
-- (BOOL)isDerived {
- return self->flags.isDerived;
-}
-- (BOOL)isFlattened {
- return self->flags.isFlattened;
-}
-
-- (BOOL)isReadOnly {
- return self->flags.isDerived ? YES : self->flags.isReadOnly;
-}
/* description */
return [[self propertyList] description];
}
-@end /* EOAttribute */
-
-
-@implementation EOAttribute (EOAttributePrivate)
+/* EOAttributePrivate */
+ (EOAttribute*)attributeFromPropertyList:(id)propertyList {
+ NSDictionary *plist = propertyList;
EOAttribute *attribute = nil;
NSString *timeZoneName;
id tmp;
+
+ attribute = [[[EOAttribute alloc] init] autorelease];
+
+ [attribute setName:[plist objectForKey:@"name"]];
+ [attribute setCalendarFormat:[plist objectForKey:@"calendarFormat"]];
- attribute = [[EOAttribute alloc] init];
- AUTORELEASE(attribute);
-
- [attribute setName:[propertyList objectForKey:@"name"]];
- [attribute setCalendarFormat:[propertyList objectForKey:@"calendarFormat"]];
-
- timeZoneName = [propertyList objectForKey:@"clientTimeZone"];
+ timeZoneName = [plist objectForKey:@"clientTimeZone"];
if (timeZoneName)
[attribute setClientTimeZone:[NSTimeZone timeZoneWithName:timeZoneName]];
- timeZoneName = [propertyList objectForKey:@"serverTimeZone"];
+ timeZoneName = [plist objectForKey:@"serverTimeZone"];
if (timeZoneName)
[attribute setServerTimeZone:[NSTimeZone timeZoneWithName:timeZoneName]];
- [attribute setColumnName: [propertyList objectForKey:@"columnName"]];
- [attribute setExternalType: [propertyList objectForKey:@"externalType"]];
- [attribute setValueClassName:[propertyList objectForKey:@"valueClassName"]];
- [attribute setValueType: [propertyList objectForKey:@"valueType"]];
- [attribute setInsertFormat: [propertyList objectForKey:@"insertFormat"]];
- [attribute setSelectFormat: [propertyList objectForKey:@"selectFormat"]];
- [attribute setUpdateFormat: [propertyList objectForKey:@"updateFormat"]];
- [attribute setUserDictionary:[propertyList objectForKey:@"userDictionary"]];
+ [attribute setColumnName: [plist objectForKey:@"columnName"]];
+ [attribute setExternalType: [plist objectForKey:@"externalType"]];
+ [attribute setValueClassName:[plist objectForKey:@"valueClassName"]];
+ [attribute setValueType: [plist objectForKey:@"valueType"]];
+ [attribute setUserDictionary:[plist objectForKey:@"userDictionary"]];
- [attribute setReadOnly:
- [[propertyList objectForKey:@"isReadOnly"] isEqual:@"Y"]];
-
- if ((tmp = [propertyList objectForKey:@"allowsNull"]))
+ if ((tmp = [plist objectForKey:@"allowsNull"]))
[attribute setAllowsNull:[tmp isEqual:@"Y"]];
else
[attribute setAllowsNull:YES];
- [attribute setWidth:
- [[propertyList objectForKey:@"width"] unsignedIntValue]];
-
- /* Don't call setDefinition: now. The attributes array in
- entity is not yet set. */
- attribute->definition = RETAIN([propertyList objectForKey:@"definition"]);
-
+ [attribute setWidth:[[plist objectForKey:@"width"] unsignedIntValue]];
return attribute;
}
were constructed and after the `attributes' array contains the real
attributes. */
- (void)replaceStringsWithObjects {
- if(self->definition) {
- NS_DURING
- [self setDefinition:self->definition];
- NS_HANDLER {
- //CATCH(PropertyDefinitionException)
- NSLog([localException reason]);
- [[self->entity model] errorInReading];
- }
- NS_ENDHANDLER;
- }
}
- (id)propertyList {
return [[(EOAttribute *)self name] compare:[_other name]];
}
-@end /* EOAttribute (EOAttributePrivate) */
-
-@implementation EOAttribute(ValuesConversion)
+/* ValuesConversion */
- (id)convertValue:(id)aValue toClass:(Class)aClass forType:(NSString*)_type {
// Check nil/EONull
toClass:aValueClass forType:[self valueType]];
}
-@end
+@end /* EOAttribute */
-@implementation NSString (EOAttributeTypeCheck)
+@implementation NSString(EOAttributeTypeCheck)
- (BOOL)isNameOfARelationshipPath {
BOOL result = NO;
return result;
}
-@end
+@end /* NSString(EOAttributeTypeCheck) */
@implementation EOAttribute(PropertyListCoding)
_addToPropList(_plist, self->name, @"name");
_addToPropList(_plist, self->calendarFormat, @"calendarFormat");
_addToPropList(_plist, self->columnName, @"columnName");
- _addToPropList(_plist, self->definition, @"definition");
_addToPropList(_plist, self->externalType, @"externalType");
_addToPropList(_plist, self->valueClassName, @"valueClassName");
_addToPropList(_plist, self->valueType, @"valueType");
- _addToPropList(_plist, self->insertFormat, @"insertFormat");
- _addToPropList(_plist, self->selectFormat, @"selectFormat");
- _addToPropList(_plist, self->updateFormat, @"updateFormat");
_addToPropList(_plist, self->userDictionary, @"userDictionary");
if (self->clientTimeZone) {
[_plist setObject:[NSNumber numberWithUnsignedInt:self->width]
forKey:@"width"];
}
-
- if (self->flags.isReadOnly) {
- [_plist setObject:[NSString stringWithCString:"Y"]
- forKey:@"isReadOnly"];
- }
if (self->flags.allowsNull) {
[_plist setObject:[NSString stringWithCString:"Y"]
forKey:@"allowsNull"];
return nil;
}
-- (NSString *)readFormat {
- return nil;
-}
-- (NSString *)writeFormat {
- return nil;
-}
-
@end /* EOAttribute(EOF2Additions) */
@implementation NSString(BeautifyAttributeName)
- (NSString *)_beautifyAttributeName {
+ // DML Unicode
unsigned clen = 0;
char *s = NULL;
unsigned cnt, cnt2;
}
+ (void)forgetObject:(id)_object {
- [EOObjectUniquer forgetObject:_object];
+ static Class UniquerClass = Nil;
+ if (UniquerClass == Nil) UniquerClass = [EOObjectUniquer class];
+ [(EOObjectUniquer *)UniquerClass forgetObject:_object];
[lock lock];
{
if(!([anAttribute isKindOfClass:[EOAttribute class]]
&& [self->attributesByName objectForKey:[anAttribute name]]))
return NO;
-
- if([anAttribute isDerived])
- return NO;
-
+
return YES;
}
return self->attributes;
}
-@end /* EOEntity */
-
-
-@implementation EOEntity (EOEntityCreation)
+/* EOEntityCreation */
+ (EOEntity *)entityFromPropertyList:(id)propertyList model:(EOModel *)_model {
+ NSDictionary *plist = propertyList;
EOEntity *entity;
NSArray *array;
NSEnumerator *enumerator;
id attributePList;
id relationshipPList;
- entity = AUTORELEASE([[EOEntity alloc] init]);
+ entity = [[[EOEntity alloc] init] autorelease];
[entity setCreateMutableObjects:YES];
- entity->name = RETAIN([propertyList objectForKey:@"name"]);
- entity->className = RETAIN([propertyList objectForKey:@"className"]);
- entity->externalName = RETAIN([propertyList objectForKey:@"externalName"]);
- entity->externalQuery = RETAIN([propertyList objectForKey:@"externalQuery"]);
- entity->userDictionary = RETAIN([propertyList objectForKey:@"userDictionary"]);
+ entity->name = RETAIN([plist objectForKey:@"name"]);
+ entity->className = RETAIN([plist objectForKey:@"className"]);
+ entity->externalName = RETAIN([plist objectForKey:@"externalName"]);
+ entity->externalQuery = RETAIN([plist objectForKey:@"externalQuery"]);
+ entity->userDictionary = RETAIN([plist objectForKey:@"userDictionary"]);
- array = [propertyList objectForKey:@"attributes"];
+ array = [plist objectForKey:@"attributes"];
enumerator = [array objectEnumerator];
while ((attributePList = [enumerator nextObject])) {
}
entity->attributesUsedForLocking
- = RETAIN([propertyList objectForKey:@"attributesUsedForLocking"]);
+ = RETAIN([plist objectForKey:@"attributesUsedForLocking"]);
entity->classPropertyNames
- = RETAIN([propertyList objectForKey:@"classProperties"]);
+ = RETAIN([plist objectForKey:@"classProperties"]);
- if ((attributePList = [propertyList objectForKey:@"primaryKeyAttributes"])) {
+ if ((attributePList = [plist objectForKey:@"primaryKeyAttributes"])) {
entity->primaryKeyAttributeNames
= RETAIN([attributePList sortedArrayUsingSelector:@selector(compare:)]);
}
else
- if ((attributePList = [propertyList objectForKey:@"primaryKeyAttribute"]))
+ if ((attributePList = [plist objectForKey:@"primaryKeyAttribute"]))
entity->primaryKeyAttributeNames
= RETAIN([NSArray arrayWithObject:attributePList]);
- array = [propertyList objectForKey:@"relationships"];
+ array = [plist objectForKey:@"relationships"];
enumerator = [array objectEnumerator];
while((relationshipPList = [enumerator nextObject])) {
EORelationship *relationship
EOAttribute *attr = [self->attributes objectAtIndex:i];
BOOL pk, lk, cp, sa;
- pk = _containsObject(self->primaryKeyAttributes, attr);
+ pk = _containsObject(self->primaryKeyAttributes, attr);
lk = _containsObject(self->attributesUsedForLocking, attr);
- cp = _containsObject(self->classProperties, attr);
- sa = (![attr isDerived] && ![attr isFlattened]);
-
- //NSLog(@"attribute %@ pk=%i lk=%i cp=%i sa=%i", [attr name], pk, lk, cp, sa);
+ cp = _containsObject(self->classProperties, attr);
+ sa = YES;
+
+#if 0
+ NSLog(@"attribute %@ pk=%i lk=%i cp=%i sa=%i",
+ [attr name], pk, lk, cp, sa);
+#endif
if ((pk || lk || cp) && (!_containsObject(fetAttr, attr)))
[fetAttr addObject:attr];
/* Checking contents */
- (BOOL)referencesObject:(id)anObject;
-- (NSString*)expressionValueForContext:(id<EOExpressionContext>)ctx;
+- (NSString *)expressionValueForContext:(id<EOExpressionContext>)ctx;
-+ (EOExpressionArray*)parseExpression:(NSString*)expression
- entity:(EOEntity*)entity
++ (EOExpressionArray *)parseExpression:(NSString *)expression
+ entity:(EOEntity *)entity
replacePropertyReferences:(BOOL)flag;
-+ (EOExpressionArray*)parseExpression:(NSString*)expression
- entity:(EOEntity*)entity
++ (EOExpressionArray *)parseExpression:(NSString *)expression
+ entity:(EOEntity *)entity
replacePropertyReferences:(BOOL)flag
relationshipPaths:(NSMutableArray *)relationshipPaths;
@implementation EOQuotedExpression
- (id)expressionValueForContext:(id<EOExpressionContext>)_context {
- NSMutableString *result;
- NSArray *components;
- id expr;
-
- expr = [self->expression expressionValueForContext:_context];
- components = [expr componentsSeparatedByString:quote];
- result = [[NSMutableString alloc] initWithCapacity:[expr length] + 10];
-
- [result appendString:quote];
- [result appendString:[components componentsJoinedByString:escape]];
- [result appendString:quote];
-
- return AUTORELEASE(result);
+ NSMutableString *result;
+ NSArray *components;
+ id expr;
+
+ expr = [(EOExpressionArray *)self->expression
+ expressionValueForContext:_context];
+ components = [expr componentsSeparatedByString:quote];
+ result = [NSMutableString stringWithCapacity:[expr length] + 10];
+
+ [result appendString:quote];
+ [result appendString:[components componentsJoinedByString:escape]];
+ [result appendString:quote];
+
+ return result;
}
- (id)initWithExpression:(id)_expression
}
- (void)setDefinition:(NSString *)def {
+ // TODO: do we need this?
if (def == nil) {
[NSException raise:NSInvalidArgumentException
format:@"invalid (nil) definition argument ..."];
+ (EORelationship *)relationshipFromPropertyList:(id)_plist
model:(EOModel *)model
{
+ NSDictionary *plist = _plist;
EORelationship *relationship = nil;
NSArray *array = nil;
NSEnumerator *enumerator = nil;
id joinPList = nil;
- relationship = AUTORELEASE([EORelationship new]);
+ relationship = [[[EORelationship alloc] init] autorelease];
[relationship setCreateMutableObjects:YES];
- [relationship setName:[_plist objectForKey:@"name"]];
+ [relationship setName:[plist objectForKey:@"name"]];
[relationship setUserDictionary:
- [_plist objectForKey:@"userDictionary"]];
+ [plist objectForKey:@"userDictionary"]];
- if ((array = [_plist objectForKey:@"joins"])) {
+ if ((array = [plist objectForKey:@"joins"])) {
enumerator = [array objectEnumerator];
joinPList = [enumerator nextObject];
}
relationship->destinationEntity =
- RETAIN([_plist objectForKey:@"destination"]);
+ RETAIN([plist objectForKey:@"destination"]);
// retained string
relationship->flags.isToMany =
- [[_plist objectForKey:@"isToMany"] isEqual:@"Y"];
+ [[plist objectForKey:@"isToMany"] isEqual:@"Y"];
relationship->flags.isMandatory =
- [[_plist objectForKey:@"isMandatory"] isEqual:@"Y"];
+ [[plist objectForKey:@"isMandatory"] isEqual:@"Y"];
/* Do not send here the -setDefinition: message because the relationships
are not yet created from the model file. */
relationship->definition
- = RETAIN([_plist objectForKey:@"definition"]);
+ = RETAIN([plist objectForKey:@"definition"]);
return relationship;
}
return [[(EORelationship *)self name] compare:[_other name]];
}
-@end /* EORelationship (EORelationshipPrivate) */
-
-@implementation EORelationship(EOJoin)
+/* EOJoin */
- (void)loadJoinPropertyList:(id)propertyList {
+ NSDictionary *plist = propertyList;
NSString *joinOperatorPList;
NSString *joinSemanticPList;
id tmp;
- tmp = [propertyList objectForKey:@"sourceAttribute"];
+ tmp = [plist objectForKey:@"sourceAttribute"];
[self setSourceAttribute:tmp];
- tmp = [propertyList objectForKey:@"destinationAttribute"];
+ tmp = [plist objectForKey:@"destinationAttribute"];
[self setDestinationAttribute:tmp];
- if ((joinOperatorPList = [propertyList objectForKey:@"joinOperator"])) {
+ if ((joinOperatorPList = [plist objectForKey:@"joinOperator"])) {
NSAssert([joinOperatorPList isEqual:@"EOJoinEqualTo"],
@"only EOJoinEqualTo is supported as the join operator !");
}
- if ((joinSemanticPList = [propertyList objectForKey:@"joinSemantic"])) {
+ if ((joinSemanticPList = [plist objectForKey:@"joinSemantic"])) {
NSAssert([joinSemanticPList isEqual:@"EOInnerJoin"],
@"only EOInnerJoin is supported as the join semantic !");
}
[self setDestinationAttribute:[_join destinationAttribute]];
}
-@end /* EORelationship(EOJoin) */
-
-@implementation EORelationship(PropertyListCoding)
+/* PropertyListCoding */
static inline void _addToPropList(NSMutableDictionary *_plist,
id _value, NSString *key) {
_addToPropList(_plist, flags.isMandatory ? @"Y" : @"N", @"isMandatory");
}
-@end /* EORelationship(PropertyListCoding) */
-
-@implementation EORelationship(EOF2Additions)
+/* EOF2Additions */
/* constraints */
return nil;
}
-@end /* EORelationship(EOF2Additions) */
+@end /* EORelationship */
@implementation EOJoin
@end /* EOJoin */
while((attributeName = [enumerator nextObject])) {
EOAttribute *attribute;
- NSString *updateFormat;
NSString *columnName = nil;
id value = nil;
- attribute = [entity attributeNamed:attributeName];
- updateFormat = [attribute updateFormat];
+ attribute = [entity attributeNamed:attributeName];
NSAssert1(attribute, @"attribute %@ should be non nil", attributeName);
columnName = adaptor
value = [row objectForKey:attributeName];
- if (updateFormat) {
- [scannerHandler setValue:value
- attribute:attribute
- adaptor:adaptor];
-#if defined(__s390__)
- value = [formatScanner performSelector:
- @selector(stringWithFormat:arguments:)
- withObject:updateFormat
- withObject:nil];
-#else
- value = [formatScanner stringWithFormat:updateFormat
- arguments:NULL];
-#endif
- }
- else {
- value = [self literalForAttribute:attribute
- withValue:value fromRow:row];
- }
-
- if(first) first = NO;
+ value = [self literalForAttribute:attribute
+ withValue:value fromRow:row];
+
+ if (first) first = NO;
else [expression appendString:@", "];
[expression appendString:columnName];
while ((attributeName = [enumerator nextObject])) {
EOAttribute *attribute;
- NSString *insertFormat;
id value;
attribute = [entity attributeNamed:attributeName];
- insertFormat = [attribute insertFormat];
value = [row objectForKey:attributeName];
NSAssert1(attribute, @"attribute %@ should be non nil", attributeName);
- if (insertFormat) {
- [scannerHandler setValue:value
- attribute:attribute
- adaptor:self->adaptor];
-#if defined(__s390__)
- value = [formatScanner performSelector:
- @selector(stringWithFormat:arguments:)
- withObject:insertFormat
- withObject:nil];
-#else
- value = [formatScanner stringWithFormat:insertFormat
- arguments:NULL];
-#endif
- }
- else {
- value = [self literalForAttribute:attribute
- withValue:value fromRow:row];
- }
-
- if(first) first = NO;
+ value = [self literalForAttribute:attribute
+ withValue:value fromRow:row];
+
+ if (first) first = NO;
else [expression appendString:@", "];
[expression appendString:value];
[attribute name],
[entity name]] raise];
}
- if ([attribute isFlattened]) {
- id definitionArray = [attribute definitionArray];
- NSRange range = { 0, [definitionArray count] - 1 };
- id relationshipPath = [definitionArray subarrayWithRange:range];
- [relationshipPaths addObject:relationshipPath];
- [entities addObjectsFromArray:relationshipPath];
- }
- else {
- /* attribute is normal. */
- [entities addObject:[attribute entity]];
- }
+ /* attribute is normal. */
+ [entities addObject:[attribute entity]];
}
[relationshipPaths unionSet:[qualifier relationshipPaths]];
[attribute name],
[entity name]] raise];
}
- if ([attribute isFlattened]) {
- id definitionArray = [attribute definitionArray];
- NSRange range = { 0, [definitionArray count] - 1 };
- id relationshipPath = [definitionArray subarrayWithRange:range];
-
- [relationshipPaths addObject:relationshipPath];
- [entities addObjectsFromArray:relationshipPath];
- }
}
entitiesAndPropertiesAliases = [NSMutableDictionary new];
}
- (NSString *)expressionValueForAttribute:(EOAttribute *)attribute {
- if([attribute isFlattened])
- return [self expressionValueForAttributePath:
- [attribute definitionArray]];
- else if([attribute isDerived])
- return [[attribute definitionArray] expressionValueForContext:self];
-
- /* attribute is a normal attribute. Its alias is the alias
- of its entity. */
- return [self expressionValueForAttribute:attribute
- context:[attribute entity]];
+ /* attribute is a normal attribute. Its alias is the alias
+ of its entity. */
+ return [self expressionValueForAttribute:attribute
+ context:[attribute entity]];
}
- (NSString *)expressionValueForAttributePath:(NSArray *)definitionArray {
sql = [self sqlStringForAttributeNamed:[_q leftKey]];
a = [[self entity] attributeNamed:[_q leftKey]]; /* relationships ? */
- sql = [[self class] formatSQLString:sql format:[a readFormat]];
+ sql = [[self class] formatSQLString:sql format:nil];
[s appendString:sql];
[s appendString:@" "];
sql = [self sqlStringForAttributeNamed:[_q rightKey]];
a = [[self entity] attributeNamed:[_q rightKey]]; /* relationships ? */
- sql = [[self class] formatSQLString:sql format:[a readFormat]];
+ sql = [[self class] formatSQLString:sql format:nil];
[s appendString:sql];
return s;
sql = [self sqlStringForAttributeNamed:[_q key]];
a = [[self entity] attributeNamed:[_q key]]; /* relationships ? */
- sql = [[self class] formatSQLString:sql format:[a readFormat]];
+ sql = [[self class] formatSQLString:sql format:nil];
[s appendString:sql];
[s appendString:@" "];
s = [[NSMutableString alloc] initWithCapacity:32];
[s appendString:[_attr columnName]];
[s appendString:@"="];
- _value = [[self class] formatSQLString:_value format:[_attr writeFormat]];
+ _value = [[self class] formatSQLString:_value format:nil];
[s appendString:_value];
[self appendItem:s toListString:[self listString]];
adaptor = [context adaptor];
if ([source isKindOfClass:AttributeClass]) {
- formattedLeft = [source expressionValueForContext:context];
+ formattedLeft = [(EOAttribute *)source expressionValueForContext:context];
}
else {
NSAssert([destination isKindOfClass:AttributeClass],
if ([destination isKindOfClass:AttributeClass]) {
NSString *tmp = formattedLeft;
- formattedLeft = [destination expressionValueForContext:context];
+ formattedLeft =
+ [(EOAttribute *)destination expressionValueForContext:context];
formattedRight = tmp;
}
else {
static void
handle_attribute(EOSQLQualifier *self, id object, id _relationshipPaths)
{
- if ([object isFlattened]) {
- id definitionArray = nil;
- id relsArray = nil;
- NSRange range;
-
- definitionArray = [object definitionArray];
- range = NSMakeRange(0, [definitionArray count] - 1);
- relsArray = [definitionArray subarrayWithRange:range];
-
- [self->relationshipPaths addObject:relsArray];
- [self->additionalEntities addObjectsFromArray:relsArray];
- }
- else {
- [self->additionalEntities addObject:[object entity]];
- }
+ [self->additionalEntities addObject:[object entity]];
}
- (void)_computeRelationshipPaths:(NSArray *)_relationshipPaths {
{
NSString *alias;
NSString *columnName;
- NSString *selectFormat;
- alias = [entitiesAndPropertiesAliases objectForKey:context];
- selectFormat = [attribute selectFormat];
+ alias = [entitiesAndPropertiesAliases objectForKey:context];
//NSLog(@"entitiesAndPropertiesAliases: %@", entitiesAndPropertiesAliases);
- if (selectFormat) {
- PrintfFormatScanner *formatScanner;
- EOSelectScannerHandler *scannerHandler;
-
- formatScanner =
- [[[[PrintfFormatScanner alloc] init] setAllowOnlySpecifier:YES]
- autorelease];
- scannerHandler =
- [[[EOSelectScannerHandler alloc] init] autorelease];
-
- [scannerHandler setAttribute:attribute adaptor:adaptor alias:alias];
- [formatScanner setFormatScannerHandler:scannerHandler];
-#if defined(__s390__)
- return [formatScanner performSelector:
- @selector(stringWithFormat:arguments:)
- withObject:selectFormat
- withObject:nil];
-#else
- return [formatScanner stringWithFormat:selectFormat arguments:NULL];
-#endif
- }
- else {
columnName = adaptor
? [adaptor formatAttribute:attribute]
: [attribute columnName];
}
return columnName;
- }
}
@end /* EOSelectSQLExpression */
@implementation EOSelectScannerHandler
-- (id)init
-{
- [super init];
-
+- (id)init {
+ if ((self = [super init]) != nil) {
specHandler['A']
- = [self methodForSelector:@selector(convertAttribute:scanner:)];
- return self;
+ = [self methodForSelector:@selector(convertAttribute:scanner:)];
+ }
+ return self;
}
-- (void)dealloc
-{
- RELEASE(self->attribute);
- RELEASE(self->adaptor);
- RELEASE(self->alias);
- [super dealloc];
+- (void)dealloc {
+ [self->attribute release];
+ [self->adaptor release];
+ [self->alias release];
+ [super dealloc];
}
- (void)setAttribute:(EOAttribute*)_attribute
# version file
-SUBMINOR_VERSION:=48
+SUBMINOR_VERSION:=49