* EOAccess/EOAdaptorChannel.m

call delegate -adaptorChannel:willPerformOperations:
	* EOAccess/EODatabaseContext.m:
	  propagate delegate to channel
	  fix objectsForSourceGlobalID:relationshipName:editingContext: 
	    isToManyToOne case
	* EOAdaptors/PostgreSQLAdaptor/PostgreSQLChannel.m:
	  call delegate methods
	  adding assert to catch bad dates
	  use adaptor -primaryKeySequenceNameFormat
	* EOAccess/EOrelationship.m
	  implement -isParentRelationship
	  verify/clean -isReciprocalToRelationship:
	  implement -qualifierWithSourceRow:
	  small fix on -removeJoin:
	  use batch faulting when -setNumberOfToManyFaultsToBatchFetch:
	  improve -setIsMandatory
	  fix exception message -validateValue:
	  clean -_intermediateAttributes
	  clean -isMultiHop
	  implement -primaryKeyForTargetRowFromSourceDBSnapshot:
	  implement -_setSourceToDestinationKeyMap:
	  implement -qualifierForDBSnapshot:
	  fix/implement -isToManyToOne
	  fix -foreignKeyInDestination
	  implement -isPropagatesPrimaryKeyPossible
	  implement -qualifierOmittingAuxiliaryQualifierWithSourceRow
	  implement -auxiliaryQualifier
	  implement -setAuxiliaryQualifier:
	  clean -_sourceRowToForeignKeyMapping
	  add comment in -_sourceAttributeNames
	  fix -joinForAttribute:
	  fix -_flushCache
	  fix -_stringFromDeleteRule:
	  implement -_rightSideKeyMap
	  implement -_leftSideKeyMap
	  implement -_substitutionRelationshipForRow:
	  fix -isFlattened
	  remove _componentRelationships
	* EOAccess/EORelationship.h
	  remove _componentRelationships
	* EOAccess/EOEntityPriv.[hm]
	  fix _hiddenRelationships return type
	* EOAccess/Entity.m:
	  implement -_mapAttribute:toDestinationAttributeInLastComponentOfRelationshipPath:
	  implement -_inverseRelationshipPathForPath:
	  implement -_relationshipPathHasIdenticalKeys:
	  rewrite & fix -_keyMapForRelationshipPath:
	  rewrite & fix -_keyMapForIdenticalKeyRelationshipPath:
	  implement -valueForSQLExpression:
	  fix -validateObjectForDelete:
	  implement -qualifierForDBSnapshot:
	  fix -_addAttributesToFetchForRelationshipPath:atts:
	  fix -_parsePropertyName:	
	  implement -fetchSpecificationNamed:
	  implement +externalNameForInternalName:separatorString:useAllCaps:
	  implement +nameForExternalName:separatorString:initialCaps:
	  implement -stringByMarkingUpcaseTransitionsWithDelimiter
	  implement -snapshotKeyForAttributeName:
	  implement -_flattenedAttNameToSnapshotKeyMapping
	  fix -_attributesToFetch
	  fix -_attributesToSave
	* EOAccess/Entity.h:
	  fix _inverseRelationshipPathForPath:
	  fix -_relationshipPathHasIdenticalKey:
	  add _flgas.isSingleTableEntity
	* EOAccess/EntityPriv.h:
	  fix -qualifierForDBSnapshot:
	* EOAccess/EOPrivate.[hm]
	  add GDL2_EORelationshipClass
	  add GDL2_EOEntityClass
	* EOAccess/EOModel.m:
	  cache [EOEntity class]
	  add -propertyListForEntity:name: to enable subclassing
	* EOAccess/EOAttribute.m
	  fix -isFlattened
	  implement -targetAttribute
	  implement -relationshipPath
	  fix -_setDefinitionWithoutFlushingCaches:
	  fix -_normalizeDefinition:path:
	  fix -isReadOnly
	  implement -_setOverrideForKeyEnum:
	  implement -_hasAnyOverrides
	  implement -_isKeyEnumOverriden:
	  implement -_prototypeKeys
	  fix -initWithPropertyList:owner:
	  fix -readFormat
	  fix -writeFormat
	  fix -scale
	  fix -precision
	  fix -width
	  fix -allowsNull
	  fix -isReadOnly
	  fix -valueClassName
	  fix -externalType
	  fix -valueType
	  implement -_setValuesFromTargetAttribute
	* EOAccess/EOAttribute.h
	  declare -targetAttribute
	  declare -relationshipPath
	* EOAccess/EOAttributePriv.h
	  declare EOAttributeProtoOverrideBits enum
	  fix method arguments
	  declare  _setValuesFromTargetAttribute()
	* EOAccess/EOExpressionArray.h
	  declare -_isPropertyPath
	* EOAccess/EOExpressionArray.m
	  implement -_isPropertyPath



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@37813 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Manuel Guesdon 2014-04-26 18:23:22 +00:00
parent 97b6302f68
commit 04d6bb3aac
19 changed files with 2006 additions and 1345 deletions

109
ChangeLog
View file

@ -1,3 +1,112 @@
2014-04-26 Manuel Guesdon <mguesdon@orange-concept.com>
* EOAccess/EOAdaptorChannel.m
call delegate -adaptorChannel:willPerformOperations:
* EOAccess/EODatabaseContext.m:
propagate delegate to channel
fix objectsForSourceGlobalID:relationshipName:editingContext:
isToManyToOne case
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLChannel.m:
call delegate methods
adding assert to catch bad dates
use adaptor -primaryKeySequenceNameFormat
* EOAccess/EOrelationship.m
implement -isParentRelationship
verify/clean -isReciprocalToRelationship:
implement -qualifierWithSourceRow:
small fix on -removeJoin:
use batch faulting when -setNumberOfToManyFaultsToBatchFetch:
improve -setIsMandatory
fix exception message -validateValue:
clean -_intermediateAttributes
clean -isMultiHop
implement -primaryKeyForTargetRowFromSourceDBSnapshot:
implement -_setSourceToDestinationKeyMap:
implement -qualifierForDBSnapshot:
fix/implement -isToManyToOne
fix -foreignKeyInDestination
implement -isPropagatesPrimaryKeyPossible
implement -qualifierOmittingAuxiliaryQualifierWithSourceRow
implement -auxiliaryQualifier
implement -setAuxiliaryQualifier:
clean -_sourceRowToForeignKeyMapping
add comment in -_sourceAttributeNames
fix -joinForAttribute:
fix -_flushCache
fix -_stringFromDeleteRule:
implement -_rightSideKeyMap
implement -_leftSideKeyMap
implement -_substitutionRelationshipForRow:
fix -isFlattened
remove _componentRelationships
* EOAccess/EORelationship.h
remove _componentRelationships
* EOAccess/EOEntityPriv.[hm]
fix _hiddenRelationships return type
* EOAccess/Entity.m:
implement -_mapAttribute:toDestinationAttributeInLastComponentOfRelationshipPath:
implement -_inverseRelationshipPathForPath:
implement -_relationshipPathHasIdenticalKeys:
rewrite & fix -_keyMapForRelationshipPath:
rewrite & fix -_keyMapForIdenticalKeyRelationshipPath:
implement -valueForSQLExpression:
fix -validateObjectForDelete:
implement -qualifierForDBSnapshot:
fix -_addAttributesToFetchForRelationshipPath:atts:
fix -_parsePropertyName:
implement -fetchSpecificationNamed:
implement +externalNameForInternalName:separatorString:useAllCaps:
implement +nameForExternalName:separatorString:initialCaps:
implement -stringByMarkingUpcaseTransitionsWithDelimiter
implement -snapshotKeyForAttributeName:
implement -_flattenedAttNameToSnapshotKeyMapping
fix -_attributesToFetch
fix -_attributesToSave
* EOAccess/Entity.h:
fix _inverseRelationshipPathForPath:
fix -_relationshipPathHasIdenticalKey:
add _flgas.isSingleTableEntity
* EOAccess/EntityPriv.h:
fix -qualifierForDBSnapshot:
* EOAccess/EOPrivate.[hm]
add GDL2_EORelationshipClass
add GDL2_EOEntityClass
* EOAccess/EOModel.m:
cache [EOEntity class]
add -propertyListForEntity:name: to enable subclassing
* EOAccess/EOAttribute.m
fix -isFlattened
implement -targetAttribute
implement -relationshipPath
fix -_setDefinitionWithoutFlushingCaches:
fix -_normalizeDefinition:path:
fix -isReadOnly
implement -_setOverrideForKeyEnum:
implement -_hasAnyOverrides
implement -_isKeyEnumOverriden:
implement -_prototypeKeys
fix -initWithPropertyList:owner:
fix -readFormat
fix -writeFormat
fix -scale
fix -precision
fix -width
fix -allowsNull
fix -isReadOnly
fix -valueClassName
fix -externalType
fix -valueType
implement -_setValuesFromTargetAttribute
* EOAccess/EOAttribute.h
declare -targetAttribute
declare -relationshipPath
* EOAccess/EOAttributePriv.h
declare EOAttributeProtoOverrideBits enum
fix method arguments
declare _setValuesFromTargetAttribute()
* EOAccess/EOExpressionArray.h
declare -_isPropertyPath
* EOAccess/EOExpressionArray.m
implement -_isPropertyPath
2014-03-09 Sebastian Reitenbach <sebastia@l00-bugdead-prods.de> 2014-03-09 Sebastian Reitenbach <sebastia@l00-bugdead-prods.de>
* EOControl/EOCheapArray.m * EOControl/EOCheapArray.m
* EOControl/EODebug.m * EOControl/EODebug.m

View file

@ -599,6 +599,10 @@ prepareInsertExpressionWithRow:changedValues
int i = 0; int i = 0;
int count = 0; int count = 0;
if (_delegateRespondsTo.willPerformOperations)
adaptorOperations=[_delegate adaptorChannel: self
willPerformOperations: adaptorOperations];
count=[adaptorOperations count]; count=[adaptorOperations count];
for(i = 0; i < count; i++) for(i = 0; i < count; i++)

View file

@ -68,7 +68,7 @@ typedef enum {
EOInOutParameter EOInOutParameter
} EOParameterDirection; } EOParameterDirection;
#define EOATTRIBUTE_PROTO_OVERRIDE_BITS_COUNT 18
@interface EOAttribute : NSObject <EOPropertyListEncoding> @interface EOAttribute : NSObject <EOPropertyListEncoding>
{ {
NSString *_name; NSString *_name;
@ -94,7 +94,7 @@ typedef enum {
unsigned int allowsNull:1; unsigned int allowsNull:1;
unsigned int isReadOnly:1; unsigned int isReadOnly:1;
unsigned int isParentAnEOEntity:1; unsigned int isParentAnEOEntity:1;
unsigned int protoOverride:18; unsigned int protoOverride:EOATTRIBUTE_PROTO_OVERRIDE_BITS_COUNT;
unsigned int isAttributeValueInitialized:1; unsigned int isAttributeValueInitialized:1;
unsigned int unused : 10; unsigned int unused : 10;
} _flags; } _flags;
@ -107,6 +107,7 @@ typedef enum {
NSString *_docComment; NSString *_docComment;
id _parent; /* unretained */ id _parent; /* unretained */
NSString *_prototypeName;
EOAttribute *_prototype; EOAttribute *_prototype;
EOExpressionArray *_definitionArray; EOExpressionArray *_definitionArray;
EOAttribute *_realAttribute; // if the attribute is flattened //Not in EOF ! EOAttribute *_realAttribute; // if the attribute is flattened //Not in EOF !
@ -166,8 +167,6 @@ typedef enum {
- (NSString *)docComment; - (NSString *)docComment;
- (BOOL)isKeyDefinedByPrototype: (NSString *)key;
/** /**
* Returns YES if the attribute references aProperty, NO otherwise. * Returns YES if the attribute references aProperty, NO otherwise.
*/ */
@ -176,6 +175,12 @@ typedef enum {
- (void)setParent: (id)parent; - (void)setParent: (id)parent;
- (void)setEntity:(EOEntity*)entity;
- (NSString*)relationshipPath;
- (EOAttribute*)targetAttribute;
@end @end
@ -219,8 +224,8 @@ typedef enum {
- (void)setDocComment: (NSString *)docComment; - (void)setDocComment: (NSString *)docComment;
- (id)_normalizeDefinition: (EOExpressionArray *)definition - (id)_normalizeDefinition: (id)definition
path: (id)path; path: (NSArray *)path;
@end @end

File diff suppressed because it is too large Load diff

View file

@ -27,22 +27,53 @@
#ifndef __EOAttributePriv_h__ #ifndef __EOAttributePriv_h__
#define __EOAttributePriv_h__ #define __EOAttributePriv_h__
typedef enum _EOAttributeProtoOverrideBits
{
EOAttributeProtoOverrideBits_externalType = 0,
EOAttributeProtoOverrideBits_columnName = 1,
EOAttributeProtoOverrideBits_readOnly = 2,
EOAttributeProtoOverrideBits_valueClassName = 3,
EOAttributeProtoOverrideBits_valueType = 4,
EOAttributeProtoOverrideBits_width = 5,
EOAttributeProtoOverrideBits_precision = 6,
EOAttributeProtoOverrideBits_scale = 7,
EOAttributeProtoOverrideBits_writeFormat = 8,
EOAttributeProtoOverrideBits_readFormat = 9,
EOAttributeProtoOverrideBits_userInfo = 10,
EOAttributeProtoOverrideBits_serverTimeZone = 11,
EOAttributeProtoOverrideBits_valueFactoryMethodName = 12,
EOAttributeProtoOverrideBits_adaptorValueConversionMethodName = 13,
EOAttributeProtoOverrideBits_factoryMethodArgumentType = 14,
EOAttributeProtoOverrideBits_allowsNull = 15,
EOAttributeProtoOverrideBits_parameterDirection = 16,
EOAttributeProtoOverrideBits_internalInfo = 17,
EOAttributeProtoOverrideBits__count
} EOAttributeProtoOverrideBits;
@interface EOAttribute (EOAttributePrivate) @interface EOAttribute (EOAttributePrivate)
-(EOExpressionArray*)_objectForPList:(NSDictionary*)pList;
- (EOExpressionArray *)_definitionArray; - (EOExpressionArray *)_definitionArray;
- (EOAttribute *)realAttribute; - (EOAttribute *)realAttribute;
- (Class)_valueClass; - (Class)_valueClass;
- (unichar)_valueTypeCharacter; - (unichar)_valueTypeCharacter;
- (void)_setDefinitionWithoutFlushingCaches: (NSString *)definition;
- (EOModel*)_parentModel;
- (void)_removeFromEntityArray:(NSArray*)entityArray
selector:(SEL)setSelector;
- (void)_setValuesFromTargetAttribute;
-(void)_setSourceToDestinationKeyMap:(NSDictionary*)map;
-(NSDictionary*) _sourceToDestinationKeyMap;
@end @end
@interface EOAttribute (EOAttributePrivate2) @interface EOAttribute (EOAttributePrivate2)
- (BOOL)_hasAnyOverrides; - (BOOL)_hasAnyOverrides;
- (void)_resetPrototype; - (void)_resetPrototype;
- (void)_updateFromPrototype; - (void)_updateFromPrototype;
- (void)_setOverrideForKeyEnum: (int)keyEnum; - (void)_setOverrideForKeyEnum: (EOAttributeProtoOverrideBits)keyEnum;
- (BOOL)_isKeyEnumOverriden: (int)param0; - (BOOL)_isKeyEnumOverriden: (EOAttributeProtoOverrideBits)keyEnum;
- (BOOL)_isKeyEnumDefinedByPrototype: (int)param0; - (BOOL)_isKeyEnumDefinedByPrototype: (EOAttributeProtoOverrideBits)keyEnum;
@end @end
#endif /* __EOAttributePriv_h__ */ #endif /* __EOAttributePriv_h__ */

View file

@ -479,7 +479,9 @@ static Class _contextClass = Nil;
[_registeredChannels count] + 1); [_registeredChannels count] + 1);
[_registeredChannels addObject:channel]; [_registeredChannels addObject:channel];
[channel setDelegate: nil];
//Channels have same delegate as context
[channel setDelegate: _delegate];
} }
- (void)unregisterChannel: (EODatabaseChannel *)channel - (void)unregisterChannel: (EODatabaseChannel *)channel
@ -1070,7 +1072,6 @@ classPropertyNames = [entity classPropertyNames];
EOEntity *entity; EOEntity *entity;
EORelationship *relationship; EORelationship *relationship;
NSUInteger maxBatch = 0; NSUInteger maxBatch = 0;
BOOL isToManyToOne = NO;
EOEntity *destinationEntity = nil; EOEntity *destinationEntity = nil;
EOModel *destinationEntityModel = nil; EOModel *destinationEntityModel = nil;
NSArray *models = nil; NSArray *models = nil;
@ -1099,13 +1100,16 @@ classPropertyNames = [entity classPropertyNames];
//Get the max number of fault to fetch //Get the max number of fault to fetch
maxBatch = [relationship numberOfToManyFaultsToBatchFetch]; maxBatch = [relationship numberOfToManyFaultsToBatchFetch];
isToManyToOne = [relationship isToManyToOne];//NO if(maxBatch == 0)
{
if (isToManyToOne) if ([relationship isToManyToOne])
{ {
NSEmitTODO(); maxBatch = [[relationship firstRelationship]numberOfToManyFaultsToBatchFetch];
[self notImplemented: _cmd]; //TODO if isToManyToOne if(maxBatch == 0)
} maxBatch=1;
}
}
//TODO: use maxBatch
//Get the fault entity (aka relationsip destination entity) //Get the fault entity (aka relationsip destination entity)
destinationEntity = [relationship destinationEntity]; destinationEntity = [relationship destinationEntity];

View file

@ -85,6 +85,7 @@
EOMKKDInitializer* _propertyDictionaryInitializer; EOMKKDInitializer* _propertyDictionaryInitializer;
EOMKKDInitializer* _instanceDictionaryInitializer; EOMKKDInitializer* _instanceDictionaryInitializer;
EOMKKDSubsetMapping* _snapshotToAdaptorRowSubsetMapping; EOMKKDSubsetMapping* _snapshotToAdaptorRowSubsetMapping;
NSMutableDictionary* _flattenedAttNameToSnapshotKeyMapping;
Class _classForInstances; Class _classForInstances;
@ -116,7 +117,7 @@
unsigned int isAbstractEntity:1; unsigned int isAbstractEntity:1;
unsigned int updating:1; unsigned int updating:1;
unsigned int cachesObjects:1; unsigned int cachesObjects:1;
unsigned int unused:1; unsigned int isSingleTableEntity:1;
unsigned int extraRefCount:22; unsigned int extraRefCount:22;
} _flags; } _flags;

File diff suppressed because it is too large Load diff

View file

@ -63,13 +63,13 @@
- (NSArray *)relationshipsPlist; - (NSArray *)relationshipsPlist;
- (id)rootParent; - (id)rootParent;
- (void)_setParent: (id)param0; - (void)_setParent: (id)param0;
- (NSArray *)_hiddenRelationships; - (NSMutableArray *)_hiddenRelationships;
- (NSArray *)_propertyNames; - (NSArray *)_propertyNames;
- (id)_flattenAttribute: (id)param0 - (EOAttribute*) _flattenAttribute: (EOAttribute*)attribute
relationshipPath: (id)param1 relationshipPath: (NSString*)relationshipPath
currentAttributes: (id)param2; currentAttributes: (NSDictionary*)currentAttributes;
- (NSString *)snapshotKeyForAttributeName: (NSString *)attributeName; - (NSString *)snapshotKeyForAttributeName: (NSString *)attributeName;
- (id)_flattenedAttNameToSnapshotKeyMapping; - (NSDictionary*)_flattenedAttNameToSnapshotKeyMapping;
- (EOMKKDSubsetMapping *)_snapshotToAdaptorRowSubsetMapping; - (EOMKKDSubsetMapping *)_snapshotToAdaptorRowSubsetMapping;
- (EOMutableKnownKeyDictionary *)_dictionaryForPrimaryKey; - (EOMutableKnownKeyDictionary *)_dictionaryForPrimaryKey;
- (EOMutableKnownKeyDictionary *)_dictionaryForProperties; - (EOMutableKnownKeyDictionary *)_dictionaryForProperties;
@ -93,19 +93,18 @@
@end @end
@interface EOEntity (EOEntityRelationshipPrivate) @interface EOEntity (EOEntityRelationshipPrivate)
- (EORelationship *)_inverseRelationshipPathForPath: (NSString *)path; - (NSString *)_inverseRelationshipPathForPath: (NSString *)path;
- (NSDictionary *)_keyMapForRelationshipPath: (NSString *)path; - (NSDictionary *)_keyMapForRelationshipPath: (NSString *)path;
- (NSDictionary*)_keyMapForIdenticalKeyRelationshipPath: (NSString *)path; - (NSDictionary*)_keyMapForIdenticalKeyRelationshipPath: (NSString *)path;
- (EOAttribute*)_mapAttribute: (EOAttribute*)attribute - (EOAttribute*)_mapAttribute: (EOAttribute*)attribute
toDestinationAttributeInLastComponentOfRelationshipPath: (NSString *)path; toDestinationAttributeInLastComponentOfRelationshipPath: (NSString *)path;
- (BOOL)_relationshipPathIsToMany: (NSString *)relPath; - (BOOL)_relationshipPathIsToMany: (NSString *)relPath;
- (BOOL)_relationshipPathHasIdenticalKeys: (id)param0; - (BOOL)_relationshipPathHasIdenticalKeys: (NSString*)path;
@end @end
@interface EOEntity (EOEntitySQLExpression) @interface EOEntity (EOEntitySQLExpression)
- (NSString *)valueForSQLExpression: (EOSQLExpression *)sqlExpression; - (NSString *)valueForSQLExpression: (EOSQLExpression *)sqlExpression;
+ (NSString *)valueForSQLExpression: (EOSQLExpression *)sqlExpression;
@end @end
@interface EOEntity (EOEntityPrivateXX) @interface EOEntity (EOEntityPrivateXX)
@ -123,7 +122,7 @@ toDestinationAttributeInLastComponentOfRelationshipPath: (NSString *)path;
- (NSArray *)classPropertyAttributeNames; - (NSArray *)classPropertyAttributeNames;
- (NSArray *)classPropertyToManyRelationshipNames; - (NSArray *)classPropertyToManyRelationshipNames;
- (NSArray *)classPropertyToOneRelationshipNames; - (NSArray *)classPropertyToOneRelationshipNames;
- (id)qualifierForDBSnapshot: (id)param0; - (EOQualifier*) qualifierForDBSnapshot:(NSDictionary*)dbSnapshot;
- (void)_addAttributesToFetchForRelationshipPath: (NSString *)path - (void)_addAttributesToFetchForRelationshipPath: (NSString *)path
atts: (NSMutableDictionary *)atts; atts: (NSMutableDictionary *)atts;
- (NSArray *)dbSnapshotKeys; - (NSArray *)dbSnapshotKeys;

View file

@ -98,6 +98,8 @@
- (NSString *)valueForSQLExpression: (EOSQLExpression *)sqlExpression; - (NSString *)valueForSQLExpression: (EOSQLExpression *)sqlExpression;
- (BOOL)_isPropertyPath;
@end /* EOExpressionArray */ @end /* EOExpressionArray */

View file

@ -66,6 +66,7 @@ RCS_ID("$Id$")
#include <EOAccess/EOEntity.h> #include <EOAccess/EOEntity.h>
#include <EOAccess/EOExpressionArray.h> #include <EOAccess/EOExpressionArray.h>
#include <EOAccess/EORelationship.h> #include <EOAccess/EORelationship.h>
#include "EOPrivate.h"
static SEL eqSel; static SEL eqSel;
@ -164,7 +165,7 @@ static SEL eqSel;
- (NSString *)expressionValueForContext: (id<EOExpressionContext>)ctx - (NSString *)expressionValueForContext: (id<EOExpressionContext>)ctx
{ {
if (ctx && [self count] if (ctx && [self count]
&& [[self objectAtIndex: 0] isKindOfClass: [EORelationship class]]) && [[self objectAtIndex: 0] isKindOfClass: GDL2_EORelationshipClass])
return [ctx expressionValueForAttributePath: self]; return [ctx expressionValueForAttributePath: self];
else else
{ {
@ -334,17 +335,10 @@ static SEL eqSel;
- (BOOL)_isPropertyPath - (BOOL)_isPropertyPath
{ {
/* if ([self count]<=0)
int i=0; return NO;
int count=0; else
return [[self objectAtIndex:0] isKindOfClass:GDL2_EORelationshipClass];
count=[self count];
objectAtIndex:i
if it's a string return NO
*/
//TODO
return NO;
} }
- (NSString *)valueForSQLExpression: (EOSQLExpression*)sqlExpression - (NSString *)valueForSQLExpression: (EOSQLExpression*)sqlExpression

View file

@ -91,9 +91,17 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
@end /* EOModel (EOModelPrivate) */ @end /* EOModel (EOModelPrivate) */
@implementation EOModel @implementation EOModel
+ (void)initialize
{
static BOOL initialized=NO;
if (!initialized)
{
initialized=YES;
};
};
+ (EOModel*) model + (EOModel*) model
{ {
return AUTORELEASE([[self alloc] init]); return AUTORELEASE([[self alloc] init]);
@ -199,8 +207,6 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
- (id)init - (id)init
{ {
if ((self = [super init])) if ((self = [super init]))
{ {
// Turbocat // Turbocat
@ -219,7 +225,6 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
name: EOClassDescriptionNeededNotification name: EOClassDescriptionNeededNotification
object: nil]; object: nil];
//No ?
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
addObserver: self addObserver: self
selector: @selector(_classDescriptionNeeded:) selector: @selector(_classDescriptionNeeded:)
@ -1344,7 +1349,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
for (; refIdx < refCount; refIdx++) { for (; refIdx < refCount; refIdx++) {
id refObj = [references objectAtIndex:refIdx]; id refObj = [references objectAtIndex:refIdx];
if ([refObj class] == [EOAttribute class]) if ([refObj class] == GDL2_EOAttributeClass)
{ {
[[(EOAttribute*) refObj entity] removeAttribute:refObj]; [[(EOAttribute*) refObj entity] removeAttribute:refObj];
} else { } else {
@ -1404,7 +1409,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
NSString *entityName = nil; NSString *entityName = nil;
NSString *entityClassName = nil; NSString *entityClassName = nil;
if ([entity isKindOfClass: [EOEntity class]]) if ([entity isKindOfClass:GDL2_EOEntityClass])
{ {
entityName = [entity name]; entityName = [entity name];
entityClassName = [entity className]; entityClassName = [entity className];
@ -1895,17 +1900,49 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
return returnPath; return returnPath;
} }
-(NSDictionary*)propertyListForEntity:(id)entity
name:(NSString*)name
{
NSDictionary* propList=nil;
NSString* plistPathName = [[[self path] stringByAppendingPathComponent: name]
stringByAppendingPathExtension: @"plist"];
EOFLOGObjectLevelArgs(@"gsdb", @"entity plistPathName =%@",
plistPathName);
propList = [NSDictionary dictionaryWithContentsOfFile: plistPathName];
EOFLOGObjectLevelArgs(@"gsdb", @"entity propList=%@", propList);
if (!propList)
{
if ([[NSFileManager defaultManager]
fileExistsAtPath: plistPathName])
{
NSAssert1(NO,
@"%@ is not a dictionary or is not readable.",
plistPathName);
}
else
{
propList = entity;
NSWarnLog(@"%@ doesn't exists. Using %@",
plistPathName, propList);
}
}
return propList;
}
- (EOEntity *) _verifyBuiltEntityObject: (id)entity - (EOEntity *) _verifyBuiltEntityObject: (id)entity
named: (NSString*)name named: (NSString*)name
{ {
if ([entity isKindOfClass: [EOEntity class]] == NO) if ([entity isKindOfClass:GDL2_EOEntityClass] == NO)
{ {
[EOObserverCenter suppressObserverNotification]; [EOObserverCenter suppressObserverNotification];
NS_DURING NS_DURING
{ {
NSString *basePath = nil; NSString *basePath = nil;
NSString *plistPathName = nil;
NSDictionary *propList = nil; NSDictionary *propList = nil;
EOFLOGObjectLevelArgs(@"gsdb", @"name=%@", name); EOFLOGObjectLevelArgs(@"gsdb", @"name=%@", name);
@ -1928,32 +1965,8 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
} }
else else
{ {
plistPathName = [[basePath stringByAppendingPathComponent: name] propList=[self propertyListForEntity:entity
stringByAppendingPathExtension: @"plist"]; name:name];
EOFLOGObjectLevelArgs(@"gsdb", @"entity plistPathName =%@",
plistPathName);
propList
= [NSDictionary dictionaryWithContentsOfFile: plistPathName];
EOFLOGObjectLevelArgs(@"gsdb", @"entity propList=%@", propList);
if (!propList)
{
if ([[NSFileManager defaultManager]
fileExistsAtPath: plistPathName])
{
NSAssert1(NO,
@"%@ is not a dictionary or is not readable.",
plistPathName);
}
else
{
propList = entity;
NSWarnLog(@"%@ doesn't exists. Using %@",
plistPathName, propList);
}
}
} }
[self _removeEntity: entity]; [self _removeEntity: entity];

View file

@ -50,7 +50,7 @@
{ {
NSMutableDictionary *_modelsByName; NSMutableDictionary *_modelsByName;
id _delegate; id _delegate;
@public //EORelationship need access to relationshipForRow
struct { struct {
unsigned int entityNamed:1; unsigned int entityNamed:1;
unsigned int relationshipForRow:1; unsigned int relationshipForRow:1;

View file

@ -38,6 +38,8 @@
// ==== Classes ==== // ==== Classes ====
GDL2ACCESS_EXPORT Class GDL2_EODatabaseContextClass; GDL2ACCESS_EXPORT Class GDL2_EODatabaseContextClass;
GDL2ACCESS_EXPORT Class GDL2_EOAttributeClass; GDL2ACCESS_EXPORT Class GDL2_EOAttributeClass;
GDL2ACCESS_EXPORT Class GDL2_EORelationshipClass;
GDL2ACCESS_EXPORT Class GDL2_EOEntityClass;
// ==== IMPs ==== // ==== IMPs ====
GDL2ACCESS_EXPORT IMP GDL2_EODatabaseContext_snapshotForGlobalIDIMP; GDL2ACCESS_EXPORT IMP GDL2_EODatabaseContext_snapshotForGlobalIDIMP;

View file

@ -44,6 +44,7 @@ RCS_ID("$Id$")
#include <EOControl/EOFault.h> #include <EOControl/EOFault.h>
#include <EOControl/EOMutableKnownKeyDictionary.h> #include <EOControl/EOMutableKnownKeyDictionary.h>
#include <EOAccess/EOAttribute.h> #include <EOAccess/EOAttribute.h>
#include <EOAccess/EOEntity.h>
#include <EOAccess/EODatabaseContext.h> #include <EOAccess/EODatabaseContext.h>
#include "EOPrivate.h" #include "EOPrivate.h"
@ -51,6 +52,8 @@ RCS_ID("$Id$")
// ==== Classes ==== // ==== Classes ====
Class GDL2_EODatabaseContextClass=Nil; Class GDL2_EODatabaseContextClass=Nil;
Class GDL2_EOAttributeClass=Nil; Class GDL2_EOAttributeClass=Nil;
Class GDL2_EORelationshipClass=Nil;
Class GDL2_EOEntityClass=Nil;
// ==== IMPs ==== // ==== IMPs ====
IMP GDL2_EODatabaseContext_snapshotForGlobalIDIMP=NULL; IMP GDL2_EODatabaseContext_snapshotForGlobalIDIMP=NULL;
@ -69,6 +72,8 @@ void GDL2_EOAccessPrivateInit()
// ==== Classes ==== // ==== Classes ====
GDL2_EODatabaseContextClass = [EODatabaseContext class]; GDL2_EODatabaseContextClass = [EODatabaseContext class];
GDL2_EOAttributeClass = [EOAttribute class]; GDL2_EOAttributeClass = [EOAttribute class];
GDL2_EORelationshipClass = [EORelationship class];
GDL2_EOEntityClass = [EOEntity class];
GDL2_EODatabaseContext_snapshotForGlobalIDIMP=[GDL2_EODatabaseContextClass instanceMethodForSelector:@selector(snapshotForGlobalID:)]; GDL2_EODatabaseContext_snapshotForGlobalIDIMP=[GDL2_EODatabaseContextClass instanceMethodForSelector:@selector(snapshotForGlobalID:)];

View file

@ -95,7 +95,6 @@ typedef enum {
/* Computed values */ /* Computed values */
NSArray *_sourceAttributes; NSArray *_sourceAttributes;
NSArray *_destinationAttributes; NSArray *_destinationAttributes;
NSMutableArray *_componentRelationships;//Used ????
} }
+ (id)relationshipWithPropertyList: (NSDictionary *)propertyList + (id)relationshipWithPropertyList: (NSDictionary *)propertyList
@ -192,9 +191,9 @@ typedef enum {
- (EORelationship *)firstRelationship; - (EORelationship *)firstRelationship;
- (EOEntity*) intermediateEntity; - (EOEntity*) intermediateEntity;
- (BOOL)isMultiHop; - (BOOL)isMultiHop;
- (void)_setSourceToDestinationKeyMap: (id)param0; - (void)_setSourceToDestinationKeyMap:(NSDictionary *)sourceToDestinationKeyMap;
- (id)qualifierForDBSnapshot: (id)param0; - (EOQualifier*)qualifierForDBSnapshot:(NSDictionary *)dbSnapshot;
- (id)primaryKeyForTargetRowFromSourceDBSnapshot: (id)param0; - (NSDictionary *)primaryKeyForTargetRowFromSourceDBSnapshot:(NSDictionary *)dbSnapshot;
- (NSString *)relationshipPath; - (NSString *)relationshipPath;
- (BOOL)isToManyToOne; - (BOOL)isToManyToOne;
- (NSDictionary *)_sourceToDestinationKeyMap; - (NSDictionary *)_sourceToDestinationKeyMap;
@ -203,9 +202,9 @@ typedef enum {
@interface EORelationship (EORelationshipPrivate2) @interface EORelationship (EORelationshipPrivate2)
- (BOOL)isPropagatesPrimaryKeyPossible; - (BOOL)isPropagatesPrimaryKeyPossible;
- (id)qualifierOmittingAuxiliaryQualifierWithSourceRow: (id)param0; - (EOQualifier*)qualifierOmittingAuxiliaryQualifierWithSourceRow: (NSDictionary *)row;
- (id)auxiliaryQualifier; - (EOQualifier*)auxiliaryQualifier;
- (void)setAuxiliaryQualifier: (id)param0; - (void)setAuxiliaryQualifier: (EOQualifier*)qualifier;
- (EOMutableKnownKeyDictionary *)_foreignKeyForSourceRow: (NSDictionary *)row; - (EOMutableKnownKeyDictionary *)_foreignKeyForSourceRow: (NSDictionary *)row;
- (EOMKKDSubsetMapping *)_sourceRowToForeignKeyMapping; - (EOMKKDSubsetMapping *)_sourceRowToForeignKeyMapping;
- (NSArray *)_sourceAttributeNames; - (NSArray *)_sourceAttributeNames;

File diff suppressed because it is too large Load diff

View file

@ -2053,7 +2053,7 @@ else if([attribute isDerived] == YES)
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"[path objectAtIndex:%d]=%@", EOFLOGObjectLevelArgs(@"EOSQLExpression", @"[path objectAtIndex:%d]=%@",
i, relationship); i, relationship);
NSAssert2([relationship isKindOfClass:[EORelationship class]], NSAssert2([relationship isKindOfClass:GDL2_EORelationshipClass],
@"'%@' is not a relationship but a %@", @"'%@' is not a relationship but a %@",
relationship, relationship,
[relationship class]); [relationship class]);

View file

@ -320,7 +320,6 @@ newValueForNumberTypeLengthAttribute(const void *bytes,
}; };
}; };
}; };
return value; return value;
} }
@ -397,11 +396,15 @@ newValueForDateTypeLengthAttribute (const void *bytes,
{ {
getDigits(&str[5],tmpString,2,&error); getDigits(&str[5],tmpString,2,&error);
month = atoi(tmpString); month = atoi(tmpString);
//Postgres can return bad dates sometimes (it accept bad date in insert/update)
NSCAssert2(month>0,@"Bad month in date %*s",length,bytes);
if (length > 9) if (length > 9)
{ {
getDigits(&str[8],tmpString,2,&error); getDigits(&str[8],tmpString,2,&error);
day = atoi(tmpString); day = atoi(tmpString);
//Postgres can return bad dates sometimes (it accept bad date in insert/update)
NSCAssert2(day>0,@"Bad day in date %*s",length,bytes);
if (length > 12) if (length > 12)
{ {
@ -1140,13 +1143,29 @@ each key
insertStatementForRow: nrow insertStatementForRow: nrow
entity: entity]; entity: entity];
if ([self _evaluateExpression: sqlexpr withAttributes: nil] == 0) //call evaluateExpression: if (!_delegateRespondsTo.shouldEvaluateExpression
[NSException raise: EOGeneralAdaptorException || [_delegate adaptorChannel: self
format: @"%@ -- %@ 0x%p: cannot insert row for entity '%@'", shouldEvaluateExpression: sqlexpr])
NSStringFromSelector(_cmd), {
NSStringFromClass([self class]), if ([self _evaluateExpression: sqlexpr
self, withAttributes: nil] == 0)
[entity name]]; {
[NSException raise: EOGeneralAdaptorException
format: @"%@ -- %@ 0x%p: cannot insert row for entity '%@'",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
[entity name]];
}
else
{
if (_delegateRespondsTo.didEvaluateExpression)
{
[_delegate adaptorChannel: self
didEvaluateExpression: sqlexpr];
}
}
}
} }
[_adaptorContext autoCommitTransaction]; [_adaptorContext autoCommitTransaction];
@ -1191,8 +1210,19 @@ each key
deleteStatementWithQualifier: qualifier deleteStatementWithQualifier: qualifier
entity: entity]; entity: entity];
rows = [self _evaluateExpression: sqlexpr withAttributes: nil]; if (!_delegateRespondsTo.shouldEvaluateExpression
|| [_delegate adaptorChannel: self
shouldEvaluateExpression: sqlexpr])
{
rows = [self _evaluateExpression: sqlexpr
withAttributes: nil];
if (_delegateRespondsTo.didEvaluateExpression)
{
[_delegate adaptorChannel: self
didEvaluateExpression: sqlexpr];
}
}
[adaptorContext autoCommitTransaction]; [adaptorContext autoCommitTransaction];
return rows; return rows;
@ -1262,8 +1292,18 @@ each key
fetchSpecification: fetchSpecification fetchSpecification: fetchSpecification
entity: entity]; entity: entity];
[self _evaluateExpression: sqlExpr if (!_delegateRespondsTo.shouldEvaluateExpression
withAttributes: attributes]; || [_delegate adaptorChannel: self
shouldEvaluateExpression: sqlExpr])
{
[self _evaluateExpression: sqlExpr
withAttributes: attributes];
if (_delegateRespondsTo.didEvaluateExpression)
{
[_delegate adaptorChannel: self
didEvaluateExpression: sqlExpr];
}
}
[_adaptorContext autoCommitTransaction]; [_adaptorContext autoCommitTransaction];
@ -2198,6 +2238,7 @@ each key
EOAttribute *primAttribute; EOAttribute *primAttribute;
NSString *sqlString; NSString *sqlString;
NSNumber *pkValue = nil; NSNumber *pkValue = nil;
NSString *sqlFormat = nil;
const char *string = NULL; const char *string = NULL;
int length = 0; int length = 0;
@ -2211,9 +2252,12 @@ each key
{ {
return nil; // We support only number keys return nil; // We support only number keys
} }
sqlString = [NSString stringWithFormat: @"SELECT nextval('%@_SEQ')", sqlFormat=[NSString stringWithFormat: @"SELECT nextval('%@')",
[entity primaryKeyRootName]]; [[[self adaptorContext]adaptor] primaryKeySequenceNameFormat]];
sqlString = [NSString stringWithFormat: sqlFormat,
[entity primaryKeyRootName]];
if ([self isDebugEnabled]) if ([self isDebugEnabled])
{ {