* EOAccess/EOEntity.m (-setName:): Validate the new name and remove

the checks from here.
  (-validateName): Don't check if an attribute or a relationship with
the name exist.  Check if an entity of the same name exists.
Return an exception with a valid reason in all cases.
* EOAccess/EOAttribute.m (validateName): Return an exception with a
valid reason in all cases.  Don't check if a relationship with the
name exists.
* EOAccess/EOAttribute.m (validateName): Return an exception with a
valid reason in all cases.  Don't check if a attribute with the
 name exists.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20652 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Matt Rice 2005-02-03 13:09:50 +00:00
parent 7ce3d33814
commit ffb09fb47b
4 changed files with 79 additions and 43 deletions

View file

@ -1,3 +1,17 @@
2005-02-02 Matt Rice <ratmice@yahoo.com>
* EOAccess/EOEntity.m (-setName:): Validate the new name and remove
the checks from here.
(-validateName): Don't check if an attribute or a relationship with
the name exist. Check if an entity of the same name exists.
Return an exception with a valid reason in all cases.
* EOAccess/EOAttribute.m (validateName): Return an exception with a
valid reason in all cases. Don't check if a relationship with the
name exists.
* EOAccess/EOAttribute.m (validateName): Return an exception with a
valid reason in all cases. Don't check if a attribute with the
name exists.
2005-01-27 David Ayers <d.ayers@inode.at>
* EOAccess/EODatabase.h/m:(EODistantPastTimeInterval): Added

View file

@ -739,10 +739,17 @@ static Class NSCalendarDateClass;
if (!exc && *s == '$')
exc++;
if (exc)
return [NSException exceptionWithName: NSInvalidArgumentException
reason: [NSString stringWithFormat:@"%@ -- %@ 0x%x: argument \"%@\" contains invalid char '%c'",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
name,
*p]
userInfo: nil];
if ([[self entity] attributeNamed:name])
exc++;
else if ([[self entity] relationshipNamed:name])
exc++;
else if ((storedProcedures = [[[self entity] model] storedProcedures]))
{
NSEnumerator *stEnum = [storedProcedures objectEnumerator];
@ -768,16 +775,18 @@ static Class NSCalendarDateClass;
}
}
}
if (exc)
return [NSException exceptionWithName: NSInvalidArgumentException
reason: [NSString stringWithFormat:@"%@ -- %@ 0x%x: argument \"%@\" contains invalid chars",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
name]
userInfo: nil];
if (exc)
{
return [NSException exceptionWithName: NSInvalidArgumentException
reason: [NSString stringWithFormat: @"%@ -- %@ 0x%x: \"%@\" already used in the model",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
name]
userInfo: nil];
}
return nil;
}

View file

@ -1874,18 +1874,8 @@ createInstanceWithEditingContext:globalID:zone:
- (void)setName: (NSString *)name
{
if (name && [name isEqual: _name]) return;
if (name
&& [name isEqual: _name] == NO
&& [_model entityNamed: name] != nil)
{
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x: \"%@\" already used in the model",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
name];
}
[[self validateName: name] raise];
[self willChange];
ASSIGNCOPY(_name, name);
@ -2200,8 +2190,17 @@ createInstanceWithEditingContext:globalID:zone:
}
if (!exc && *s == '$') exc++;
if ([self attributeNamed: name]) exc++;
else if ([self relationshipNamed: name]) exc++;
if (exc)
return [NSException exceptionWithName: NSInvalidArgumentException
reason: [NSString stringWithFormat:@"%@ -- %@ 0x%x: argument \"%@\" contains invalid char '%c'",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
name,
*p]
userInfo: nil];
if ([_model entityNamed: name]) exc++;
else if ((storedProcedures = [[self model] storedProcedures]))
{
NSEnumerator *stEnum = [storedProcedures objectEnumerator];
@ -2226,17 +2225,19 @@ createInstanceWithEditingContext:globalID:zone:
}
}
}
if (exc)
if (exc)
{
return [NSException exceptionWithName: NSInvalidArgumentException
reason: [NSString stringWithFormat:@"%@ -- %@ 0x%x: argument \"%@\" contains invalid chars",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
name]
userInfo: nil];
else
return nil;
reason: [NSString stringWithFormat: @"%@ -- %@ 0x%x: \"%@\" already used in the model",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
name]
userInfo: nil];
}
return nil;
}
- (void)addSubEntity: (EOEntity *)child

View file

@ -1223,6 +1223,16 @@ relationships. Nil if none" **/
}
if (!exc && *s == '$')
exc++;
if (exc)
return [NSException exceptionWithName: NSInvalidArgumentException
reason: [NSString stringWithFormat: @"%@ -- %@ 0x%x: argument \"%@\" contains invalid char '%c'",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
name,
*p]
userInfo: nil];
if ([[self entity] anyAttributeNamed: name])
exc++;
@ -1254,15 +1264,17 @@ relationships. Nil if none" **/
}
if (exc)
return [NSException exceptionWithName: NSInvalidArgumentException
reason: [NSString stringWithFormat: @"%@ -- %@ 0x%x: argument \"%@\" contains invalid chars",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
name]
{
return [NSException exceptionWithName: NSInvalidArgumentException
reason: [NSString stringWithFormat: @"%@ -- %@ 0x%x: \"%@\" already used in the model",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
name]
userInfo: nil];
else
return nil;
}
return nil;
}
- (void)setToMany: (BOOL)flag