mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-04-23 13:10:48 +00:00
* EOControl/EODetailDataSource.m (-editingContext): Return the master
data sources editing context. * EOControl/EOGlobalID.m (-description): Correct conversion specification. * EOAccess/EOModel.m (-referencesToProperty:): Implement. * EOAccess/EORelationship.m (-referencesProperty:): Fix bug in or when sending messages to nil. (-validateName:): Return nil if the name is the properties current name. * EOAccess/EOModel.m (-validateName:): Ditto. * EOAccess/EOEntity.m (-validateName:): Ditto. (-relationships): Handle partially converted relationships array. (-addAttribute:): Remove unnecessary cast. (-addRelationship:): Ditto. (-removeAttribute): Remove property from the class properties and primary key attributes arrays. (-removeRelationship:): Remove property from the class properties array. (-_setIsEdited:): Rebuild _relationshipsByName. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: Fix warning. * EOAdaptors/Postgres95/Postgres95Values.m: Remove c99 usage. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@22681 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5faa90d0e1
commit
fbedef852f
9 changed files with 163 additions and 25 deletions
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
2006-03-19 Matt Rice <ratmice@yahoo.com>
|
||||
|
||||
* EOControl/EODetailDataSource.m (-editingContext): Return the master
|
||||
data sources editing context.
|
||||
* EOControl/EOGlobalID.m (-description): Correct conversion
|
||||
specification.
|
||||
* EOAccess/EOModel.m (-referencesToProperty:): Implement.
|
||||
* EOAccess/EORelationship.m (-referencesProperty:): Fix bug in or when
|
||||
sending messages to nil.
|
||||
(-validateName:): Return nil if the name is the properties current name.
|
||||
* EOAccess/EOModel.m (-validateName:): Ditto.
|
||||
* EOAccess/EOEntity.m (-validateName:): Ditto.
|
||||
(-relationships): Handle partially converted relationships array.
|
||||
(-addAttribute:): Remove unnecessary cast.
|
||||
(-addRelationship:): Ditto.
|
||||
(-removeAttribute): Remove property from the class properties and
|
||||
primary key attributes arrays.
|
||||
(-removeRelationship:): Remove property from the class properties
|
||||
array.
|
||||
(-_setIsEdited:): Rebuild _relationshipsByName.
|
||||
* EOAdaptors/Postgres95/Postgres95SQLExpression.m: Fix warning.
|
||||
* EOAdaptors/Postgres95/Postgres95Values.m: Remove c99 usage.
|
||||
|
||||
2005-12-18 Matt Rice <ratmice@yahoo.com>
|
||||
|
||||
* EOAdaptors/Postgres95/LoginPanel/postgreslogo.tif: New file.
|
||||
|
|
|
@ -708,6 +708,7 @@ RCS_ID("$Id$")
|
|||
const char *p, *s = [name cString];
|
||||
int exc = 0;
|
||||
|
||||
if ([_name isEqual:name]) return nil;
|
||||
if (!name || ![name length]) exc++;
|
||||
|
||||
if (!exc)
|
||||
|
|
|
@ -1219,7 +1219,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
|
|||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSDictionary *attrPList = [relationshipPLists
|
||||
id attrPList = [relationshipPLists
|
||||
objectAtIndex: i];
|
||||
EORelationship *relationship = nil;
|
||||
NSString *relationshipName = nil;
|
||||
|
@ -1227,9 +1227,11 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
|
|||
EOFLOGObjectLevelArgs(@"EOEntity", @"attrPList: %@",
|
||||
attrPList);
|
||||
|
||||
relationship = [EORelationship
|
||||
relationshipWithPropertyList: attrPList
|
||||
owner: self];
|
||||
relationship=[attrPList isKindOfClass: [EORelationship class]]
|
||||
? attrPList
|
||||
: [EORelationship
|
||||
relationshipWithPropertyList: attrPList
|
||||
owner: self];
|
||||
|
||||
relationshipName = [relationship name];
|
||||
|
||||
|
@ -1288,9 +1290,12 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
|
|||
{
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSString *relName = [relNames objectAtIndex: i];
|
||||
NSDictionary *relPList = [relationshipPLists
|
||||
objectAtIndex: i];
|
||||
if ([relPList isKindOfClass: [EORelationship class]])
|
||||
continue;
|
||||
{
|
||||
NSString *relName = [relNames objectAtIndex: i];
|
||||
EORelationship *relationship = [self relationshipNamed:
|
||||
relName];
|
||||
|
||||
|
@ -1307,6 +1312,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
|
|||
|
||||
[relationship awakeWithPropertyList: relPList];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1961,7 +1967,7 @@ createInstanceWithEditingContext:globalID:zone:
|
|||
|
||||
[self willChange];
|
||||
if ([self createsMutableObjects])
|
||||
[(GCMutableArray *)_attributes addObject: attribute];
|
||||
[_attributes addObject: attribute];
|
||||
else
|
||||
_attributes
|
||||
= RETAIN([AUTORELEASE(_attributes) arrayByAddingObject: attribute]);
|
||||
|
@ -1976,6 +1982,13 @@ createInstanceWithEditingContext:globalID:zone:
|
|||
[attribute setParent: self];
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the attribute from the -attributes array, and the
|
||||
* -classProperties, and -primaryKeyAttributes arrays if they contain it.
|
||||
* does not remove any references to the attribute from other properties.
|
||||
* the caller should insure that no such references exist by calling
|
||||
* -referencesProperty: or [EOModel -referencesToProperty:].
|
||||
*/
|
||||
- (void) removeAttribute: (EOAttribute *)attribute
|
||||
{
|
||||
if (attribute)
|
||||
|
@ -1986,18 +1999,47 @@ createInstanceWithEditingContext:globalID:zone:
|
|||
|
||||
//TODO
|
||||
if ([self createsMutableObjects])
|
||||
[(GCMutableArray *)_attributes removeObject: attribute];
|
||||
{
|
||||
[_attributes removeObject: attribute];
|
||||
|
||||
[_classProperties removeObject:attribute];
|
||||
[_primaryKeyAttributes removeObject:attribute];
|
||||
}
|
||||
else
|
||||
{
|
||||
_attributes
|
||||
= [[GCMutableArray alloc] initWithArray:AUTORELEASE(_attributes)
|
||||
copyItems:NO];
|
||||
[(GCMutableArray *)_attributes removeObject: attribute];
|
||||
[_attributes removeObject: attribute];
|
||||
_attributes
|
||||
= [[GCArray alloc] initWithArray:AUTORELEASE(_attributes)
|
||||
copyItems:NO];
|
||||
if ([_classProperties containsObject:attribute])
|
||||
{
|
||||
_classProperties = [[GCMutableArray alloc]
|
||||
initWithArray:AUTORELEASE(_classProperties)
|
||||
copyItems:NO];
|
||||
[_classProperties removeObject: attribute];
|
||||
_classProperties = [[GCArray alloc]
|
||||
initWithArray:AUTORELEASE(_classProperties)
|
||||
copyItems:NO];
|
||||
}
|
||||
if ([_primaryKeyAttributes containsObject:attribute])
|
||||
{
|
||||
_primaryKeyAttributes = [[GCMutableArray alloc]
|
||||
initWithArray:AUTORELEASE(_primaryKeyAttributes)
|
||||
copyItems:NO];
|
||||
[_primaryKeyAttributes removeObject: attribute];
|
||||
_primaryKeyAttributes = [[GCArray alloc]
|
||||
initWithArray:AUTORELEASE(_primaryKeyAttributes)
|
||||
copyItems:NO];
|
||||
}
|
||||
|
||||
}
|
||||
// in _setIsEdited _attributesByName isn't cleared do it here??
|
||||
[_attributesByName removeObjectForKey: [attribute name]];
|
||||
// _classProperty*Names is cleared
|
||||
// _primaryKeyAttributeNames is cleared
|
||||
[self _setIsEdited];//To clean caches
|
||||
}
|
||||
}
|
||||
|
@ -2024,7 +2066,7 @@ createInstanceWithEditingContext:globalID:zone:
|
|||
|
||||
[self willChange];
|
||||
if ([self createsMutableObjects])
|
||||
[(GCMutableArray *)_relationships addObject: relationship];
|
||||
[_relationships addObject: relationship];
|
||||
else
|
||||
_relationships = RETAIN([AUTORELEASE(_relationships)
|
||||
arrayByAddingObject: relationship]);
|
||||
|
@ -2039,6 +2081,13 @@ createInstanceWithEditingContext:globalID:zone:
|
|||
[self _setIsEdited];//To clean caches
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the relationship from the -relationships array and
|
||||
* the -classProperties array if it contains the relationship.
|
||||
* The caller should insure that no references to the
|
||||
* relationship exist by calling -referencesProperty: or
|
||||
* [EOModel -referencesToProperty].
|
||||
*/
|
||||
- (void)removeRelationship: (EORelationship *)relationship
|
||||
{
|
||||
NSEmitTODO(); //TODO
|
||||
|
@ -2052,16 +2101,26 @@ createInstanceWithEditingContext:globalID:zone:
|
|||
if(_relationshipsByName != nil)
|
||||
[_relationshipsByName removeObjectForKey:[relationship name]];
|
||||
if ([self createsMutableObjects])
|
||||
[(GCMutableArray *)_relationships removeObject: relationship];
|
||||
{
|
||||
[_relationships removeObject: relationship];
|
||||
[_classProperties removeObject: relationship];
|
||||
}
|
||||
else
|
||||
{
|
||||
_relationships
|
||||
= [[GCMutableArray alloc] initWithArray:AUTORELEASE(_relationships)
|
||||
copyItems:NO];
|
||||
[(GCMutableArray *)_relationships removeObject: relationship];
|
||||
[_relationships removeObject: relationship];
|
||||
_relationships
|
||||
= [[GCArray alloc] initWithArray:AUTORELEASE(_relationships)
|
||||
copyItems:NO];
|
||||
_classProperties = [[GCMutableArray alloc]
|
||||
initWithArray:AUTORELEASE(_classProperties)
|
||||
copyItems:NO];
|
||||
[_classProperties removeObject: relationship];
|
||||
_classProperties = [[GCArray alloc]
|
||||
initWithArray:AUTORELEASE(_classProperties)
|
||||
copyItems:NO];
|
||||
}
|
||||
[self _setIsEdited];//To clean caches
|
||||
}
|
||||
|
@ -2202,7 +2261,9 @@ createInstanceWithEditingContext:globalID:zone:
|
|||
const char *p, *s = [name cString];
|
||||
int exc = 0;
|
||||
NSArray *storedProcedures;
|
||||
|
||||
|
||||
if ([_name isEqual:name]) return nil;
|
||||
|
||||
if (!name || ![name length]) exc++;
|
||||
if (!exc)
|
||||
{
|
||||
|
@ -2843,6 +2904,12 @@ createInstanceWithEditingContext:globalID:zone:
|
|||
(_instanceDictionaryInitializer ? "Not NIL" : "NIL"));
|
||||
AUTORELEASE_SETNIL(_instanceDictionaryInitializer);
|
||||
|
||||
EOFLOGObjectLevelArgs(@"EOEntity",@"_relationshipsByName: %p %s",
|
||||
_relationshipsByName,
|
||||
(_relationshipsByName ? "Not NIL" : "NIL"));
|
||||
AUTORELEASE_SETNIL(_relationshipsByName);
|
||||
_flags.relationshipsIsLazy = YES;
|
||||
|
||||
//TODO call _flushCache on each attr
|
||||
NSAssert4(!_attributesToFetch
|
||||
|| [_attributesToFetch isKindOfClass: [NSArray class]],
|
||||
|
|
|
@ -74,8 +74,11 @@ RCS_ID("$Id$")
|
|||
#include <EOAccess/EOAccessFault.h>
|
||||
#include <EOAccess/EOAdaptor.h>
|
||||
#include <EOAccess/EOAttribute.h>
|
||||
#include <EOAccess/EORelationship.h>
|
||||
|
||||
#include "EOEntityPriv.h"
|
||||
#include "EOPrivate.h"
|
||||
#include "EOAttributePriv.h"
|
||||
|
||||
#define DEFAULT_MODEL_VERSION 2
|
||||
|
||||
|
@ -1599,12 +1602,45 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of flattened attributes and relationships in the receiver's
|
||||
* entities that reference property, or nil if nothing references it.
|
||||
*/
|
||||
- (NSArray *) referencesToProperty: (id)property
|
||||
{
|
||||
// TODO
|
||||
[self notImplemented: _cmd];
|
||||
|
||||
return nil;
|
||||
// TODO test
|
||||
NSEnumerator *entityEnumerator = [[self entities] objectEnumerator];
|
||||
IMP enumNO=NULL;
|
||||
EOEntity *ent;
|
||||
NSMutableArray *refProps = [NSMutableArray array];
|
||||
|
||||
while ((ent = GDL2_NextObjectWithImpPtr(entityEnumerator,&enumNO)))
|
||||
{
|
||||
NSEnumerator *propEnumerator = [[ent attributes] objectEnumerator];
|
||||
EOAttribute *attr;
|
||||
EORelationship *rel;
|
||||
IMP propEnumNO=NULL;
|
||||
|
||||
while ((attr = GDL2_NextObjectWithImpPtr(propEnumerator,&propEnumNO)))
|
||||
{
|
||||
if ([attr isFlattened] && [[attr realAttribute] isEqual: property])
|
||||
{
|
||||
[refProps addObject:attr];
|
||||
}
|
||||
}
|
||||
|
||||
propEnumerator = [[ent relationships] objectEnumerator];
|
||||
propEnumNO = NULL;
|
||||
while ((rel = GDL2_NextObjectWithImpPtr(propEnumerator, &propEnumNO)))
|
||||
{
|
||||
if ([rel referencesProperty:property])
|
||||
{
|
||||
[refProps addObject:rel];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [refProps count] ? [NSArray arrayWithArray:refProps] : nil;
|
||||
}
|
||||
|
||||
- (NSArray *) externalModelsReferenced
|
||||
|
|
|
@ -810,17 +810,21 @@ to know what to-many mean :-) **/
|
|||
- (BOOL)referencesProperty: (id)property
|
||||
{
|
||||
BOOL referencesProperty = NO;
|
||||
NSArray *srcAttribs = [self sourceAttributes];
|
||||
NSArray *destAttribs = [self destinationAttributes];
|
||||
NSArray *compRels = [self componentRelationships];
|
||||
|
||||
NSEmitTODO(); //TODO
|
||||
EOFLOGObjectLevelArgs(@"EORelationship", @"in referencesProperty:%@",
|
||||
property);
|
||||
|
||||
referencesProperty = ([[self sourceAttributes]
|
||||
indexOfObject: property] != NSNotFound
|
||||
|| [[self destinationAttributes]
|
||||
indexOfObject: property] != NSNotFound
|
||||
|| [[self componentRelationships]
|
||||
indexOfObject: property] != NSNotFound);
|
||||
referencesProperty =
|
||||
((srcAttribs
|
||||
&& [srcAttribs indexOfObject: property] != NSNotFound)
|
||||
|| (destAttribs
|
||||
&& [destAttribs indexOfObject: property] != NSNotFound)
|
||||
|| (compRels
|
||||
&& [compRels indexOfObject: property] != NSNotFound));
|
||||
|
||||
return referencesProperty;
|
||||
}
|
||||
|
@ -1218,6 +1222,7 @@ relationships. Nil if none" **/
|
|||
int exc = 0;
|
||||
NSArray *storedProcedures = nil;
|
||||
|
||||
if ([_name isEqual:name]) return nil;
|
||||
if (!name || ![name length])
|
||||
exc++;
|
||||
if (!exc)
|
||||
|
|
|
@ -39,6 +39,7 @@ RCS_ID("$Id$")
|
|||
#ifdef GNUSTEP
|
||||
#include <Foundation/NSUtilities.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
#else
|
||||
#include <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
|
|
@ -203,7 +203,7 @@ to strlen(bytes)
|
|||
value = [PSQLA_alloc(NSNumber) initWithUnsignedLongLong:strtoull(bytes,NULL,10)];
|
||||
break;
|
||||
case 'f':
|
||||
value = [PSQLA_alloc(NSNumber) initWithFloat: strtof(bytes,NULL)];
|
||||
value = [PSQLA_alloc(NSNumber) initWithFloat: (float)strtod(bytes,NULL)];
|
||||
break;
|
||||
case 'd':
|
||||
case '\0':
|
||||
|
|
|
@ -203,7 +203,12 @@ RCS_ID("$Id$")
|
|||
|
||||
- (EOEditingContext *)editingContext
|
||||
{
|
||||
return [_masterObject editingContext];
|
||||
/*
|
||||
* 4.5 documented as _masterObject or nil
|
||||
* in 5.x this is documented as returning the master data source or nil
|
||||
* seems to be a documentation error in 4.5
|
||||
*/
|
||||
return [_masterDataSource editingContext];
|
||||
}
|
||||
|
||||
- (NSArray *)fetchObjects
|
||||
|
|
|
@ -240,7 +240,7 @@ static unsigned short sequence = (unsigned short)-1;
|
|||
}
|
||||
}
|
||||
dst[j] = 0;
|
||||
return [NSString stringWithFormat: @"<%@ %s>",
|
||||
return [NSString stringWithFormat: @"<%s %s>",
|
||||
GSClassNameFromObject(self), dst];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue