COmmit Part 2

* EOAccess/EOAdaptor.m:
  o optimization in 'for' loops
* EOAccess/EODatabase.m:
  o include <EOCOntrol/EOPriv.h>
  o replaced isNilOrEONull() by _isNilOrEONull()
* EOAccess/EODatabaseContext.h:
  o added _snapshotForGlobalIDIMP
* EOAccess/EODatabaseContext.m:
  o commented  NSEmitTODO in
  -objectsForSourceGlobalID:relationshipName:editingContext:
  o added beter exception format in
  qualifierForLockingAttributes:primaryKeyAttributes:entity:snapshot:
  o fix compiler warning in -relayPrimaryKey:object:entity:
  o logs
  o optimizations in -objectsWithFetchSpecification:editingContext:
  o replaced isNilOrEONull() by _isNilOrEONull()
  o replace [EOFault isFault:] by _isFault()
  o use _snapshotForGlobalIDIMP
  o IMP usage optimization
* EOAccess/EOAttribute.[hm]:
  o added EOAdaptorUnknownType
  o added _adaptorValueType and avoid recomputing it each time
  o added _valueTypeChar to avoid string comparaisons
  o use EOPriv classes declarations
  o Temporary reverted David changes in
  -adaptorValueByConvertingAttributeValue
* EOAccess/EOAttributePriv.h:
  o added _valueTypeChar to avoid string comparaisons
* EOAccess/EOEntityPriv.h:
  o moved -attributeForPath: and -relationshipForPath: to
  EOEntityGDL2Additions category
* EOAccess/EOEntity.h:
  o moved private -attributeForPath: and -relationshipForPath: to
  EOEntityGDL2Additions category
* EOAccess/EOEntity.m:
  o better exception in classProperties
  o fix compiler warning in -setClassProperties:,
  -setPrimaryKeyAttributes:,
	-setAttributesUsedForLocking:
	o moved -attributeForPath: and -relationshipForPath: to
	EOEntityGDL2Additions category
	o include <EOCOntrol/EOPriv.h>
	o replaced [EONull null] by GDL2EONull
* EOAccess/EOSQLExpression.m:
  o optimization in -tableListWithRootEntity:
  o optimization in -formatSQLString:format:
  o optimization in +sqlPatternFromShellPattern:
  o optimization in +sqlPatternFromShellPattern:withEscapeCharacter:
  o fix in -sqlStringForKeyValueQualifier:
  o added log in -sqlStringForKeyValueQualifier: for not handled
  readFormat
  o added log -addInsertListAttribute:value: for not handled
  writeFormat
  o added log -addUpdateListAttribute:value: for not handled
  writeFormat
  o changed  EOFLOGObjectFnStart to EOFLOGObjectFnStartCond
  o changed  EOFLOGObjectFnStop to EOFLOGObjectFnStopCond
  o include <EOCOntrol/EOPriv.h>
  o replaced [EONull null] by GDL2EONull
* EOAccess/EOSQLQualifier.m:
  o implemented EOKeyComparisonQualifier
  -schemaBasedQualifierWithRootEntity
* EOAccess/EOUtilities.m:
  o include <EOCOntrol/EOPriv.h>
  o replaced [EONull null] by GDL2EONull
* EOControl/EOPriv.[hm]:
  o added. Contains various classes/selectors/IMPs
* EOControl/EOClassDescription.m:
  o handle EONull case in -propagateDeleteForObject:editingContext:,
    -addObject:toPropertyWithKey:, -snapshot,
    -removeObject:fromPropertyWithKey:,
	_setObject:forBothSidesOfRelationshipWithKey:,
	addObject:toBothSidesOfRelationshipWithKey:,
		-removeObject:fromBothSidesOfRelationshipWithKey:
		o fix compiler warning in
		-dictionaryForInstanceProperties, -shallowCopy,
		-updateFromSnapshot:, -snapshot
		o include <EOCOntrol/EOPriv.h>
		o replaced [EONull null] by GDL2EONull
		o replaced isNilOrEONull() by _isNilOrEONull()
		o fix in -validateForSave
		o rewritten -validateValue:forKey: selector build
* EOControl/EOEditingContext.h:
  o added -hasUnprocessedChanges
* EOControl/EOEditingContext.m:
  o added -hasUnprocessedChanges
  o added NS_DURING,... to catch exceptions
  o replace [EOFault isFault:] by _isFault()
  o IMP usage optimization
* EOControl/EOKeyGlobalID.m:
  o replaced isNilOrEONull() by _isNilOrEONull()
  o include <EOCOntrol/EOPriv.h>
* EOControl/EOGenericRecord.m:
  o partially rewritten -description
  o include <EOCOntrol/EOPriv.h>
  o replaced isNilOrEONull() by _isNilOrEONull()
  o replace [EOFault isFault:] by _isFault()
  o changed variable name type of
  _infoForInstanceVariableNamed:retType:retSize:retOffset:
  o rewritten valueForKey:,... to use cString NSKeyValueCoding
* EOControl/EOKeyValueCoding.m:
  o changed NSAssert in NSArray -valueForKey:
  o optimization in NSDictionary -takeValue:forKeyPath:isSmart:
  o optimization in NSDictionary -takeStoredValue:forKeyPath:
  o include <EOCOntrol/EOPriv.h>
  o replaced [EONull null] by GDL2EONull
  o include <EOCOntrol/EOPriv.h>
* EOControl/EOKeyValueQualifier.m:
  o fixes for EONull/nil in -evaluateWithObject:
  o replaced [EONull null] by GDL2EONull
  o include <EOCOntrol/EOPriv.h>
* EOControl/EOSortOrdering.m:
  o include <EOCOntrol/EOPriv.h>
  o replaced [EONull null] by GDL2EONull
* EOAdaptors/Postgres95SQLExpression.m:
  o float formatting in +formatValue:forAttribute:
  o added -externalNameQuoteCharacter
  o added +sqlPatternFromShellPattern:
  o added +sqlPatternFromShellPattern:withEscapeCharacter:
  o replaced isNilOrEONull() by _isNilOrEONull()
* EOAdaptors/Postgres95Channel.m:
  o logs
* EOAdaptors/Postgres95Values.m:
  o logs
  o fix in +setPostgres95Format:
  o fix calendard format to handle timezone (%z)
  o optimizations
* EOControl/EOMutableKnownKeyDictionary.m
  o removed EOMKKDArrayMapping
  +dictionaryFromDictionary:subsetMapping:
  o include <EOCOntrol/EOPriv.h>
  o replaced isNilOrEONull() by _isNilOrEONull()
* EOControl/EONSAddOns.[hm]:
  o added NSString(ShellPattern)


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20688 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Manuel Guesdon 2005-02-11 17:37:23 +00:00
parent 409de8d589
commit bd72217067
21 changed files with 2638 additions and 1699 deletions

120
ChangeLog
View file

@ -1,3 +1,123 @@
2005-02-11 Manuel Guesdon <mguesdon@orange-concept.com>
* EOAccess/EOAdaptor.m:
o optimization in 'for' loops
* EOAccess/EODatabase.m:
o include <EOCOntrol/EOPriv.h>
o replaced isNilOrEONull() by _isNilOrEONull()
* EOAccess/EODatabaseContext.h:
o added _snapshotForGlobalIDIMP
* EOAccess/EODatabaseContext.m:
o commented NSEmitTODO in -objectsForSourceGlobalID:relationshipName:editingContext:
o added beter exception format in qualifierForLockingAttributes:primaryKeyAttributes:entity:snapshot:
o fix compiler warning in -relayPrimaryKey:object:entity:
o logs
o optimizations in -objectsWithFetchSpecification:editingContext:
o replaced isNilOrEONull() by _isNilOrEONull()
o replace [EOFault isFault:] by _isFault()
o use _snapshotForGlobalIDIMP
o IMP usage optimization
* EOAccess/EOAttribute.[hm]:
o added EOAdaptorUnknownType
o added _adaptorValueType and avoid recomputing it each time
o added _valueTypeChar to avoid string comparaisons
o use EOPriv classes declarations
o Temporary reverted David changes in -adaptorValueByConvertingAttributeValue
* EOAccess/EOAttributePriv.h:
o added _valueTypeChar to avoid string comparaisons
* EOAccess/EOEntityPriv.h:
o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category
* EOAccess/EOEntity.h:
o moved private -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category
* EOAccess/EOEntity.m:
o better exception in classProperties
o fix compiler warning in -setClassProperties:, -setPrimaryKeyAttributes:,
-setAttributesUsedForLocking:
o moved -attributeForPath: and -relationshipForPath: to EOEntityGDL2Additions category
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
* EOAccess/EOSQLExpression.m:
o optimization in -tableListWithRootEntity:
o optimization in -formatSQLString:format:
o optimization in +sqlPatternFromShellPattern:
o optimization in +sqlPatternFromShellPattern:withEscapeCharacter:
o fix in -sqlStringForKeyValueQualifier:
o added log in -sqlStringForKeyValueQualifier: for not handled readFormat
o added log -addInsertListAttribute:value: for not handled writeFormat
o added log -addUpdateListAttribute:value: for not handled writeFormat
o changed EOFLOGObjectFnStart to EOFLOGObjectFnStartCond
o changed EOFLOGObjectFnStop to EOFLOGObjectFnStopCond
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
* EOAccess/EOSQLQualifier.m:
o implemented EOKeyComparisonQualifier -schemaBasedQualifierWithRootEntity
* EOAccess/EOUtilities.m:
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
* EOControl/EOPriv.[hm]:
o added. Contains various classes/selectors/IMPs
* EOControl/EOClassDescription.m:
o handle EONull case in -propagateDeleteForObject:editingContext:,
-addObject:toPropertyWithKey:, -snapshot, -removeObject:fromPropertyWithKey:,
_setObject:forBothSidesOfRelationshipWithKey:, addObject:toBothSidesOfRelationshipWithKey:,
-removeObject:fromBothSidesOfRelationshipWithKey:
o fix compiler warning in -dictionaryForInstanceProperties, -shallowCopy, -updateFromSnapshot:, -snapshot
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
o replaced isNilOrEONull() by _isNilOrEONull()
o fix in -validateForSave
o rewritten -validateValue:forKey: selector build
* EOControl/EOEditingContext.h:
o added -hasUnprocessedChanges
* EOControl/EOEditingContext.m:
o added -hasUnprocessedChanges
o added NS_DURING,... to catch exceptions
o replace [EOFault isFault:] by _isFault()
o IMP usage optimization
* EOControl/EOKeyGlobalID.m:
o replaced isNilOrEONull() by _isNilOrEONull()
o include <EOCOntrol/EOPriv.h>
* EOControl/EOGenericRecord.m:
o partially rewritten -description
o include <EOCOntrol/EOPriv.h>
o replaced isNilOrEONull() by _isNilOrEONull()
o replace [EOFault isFault:] by _isFault()
o changed variable name type of _infoForInstanceVariableNamed:retType:retSize:retOffset:
o rewritten valueForKey:,... to use cString NSKeyValueCoding
* EOControl/EOKeyValueCoding.m:
o changed NSAssert in NSArray -valueForKey:
o optimization in NSDictionary -takeValue:forKeyPath:isSmart:
o optimization in NSDictionary -takeStoredValue:forKeyPath:
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
o include <EOCOntrol/EOPriv.h>
* EOControl/EOKeyValueQualifier.m:
o fixes for EONull/nil in -evaluateWithObject:
o replaced [EONull null] by GDL2EONull
o include <EOCOntrol/EOPriv.h>
* EOControl/EOSortOrdering.m:
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
* EOAdaptors/Postgres95SQLExpression.m:
o float formatting in +formatValue:forAttribute:
o added -externalNameQuoteCharacter
o added +sqlPatternFromShellPattern:
o added +sqlPatternFromShellPattern:withEscapeCharacter:
o replaced isNilOrEONull() by _isNilOrEONull()
* EOAdaptors/Postgres95Channel.m:
o logs
* EOAdaptors/Postgres95Values.m:
o logs
o fix in +setPostgres95Format:
o fix calendard format to handle timezone (%z)
o optimizations
* EOControl/EOMutableKnownKeyDictionary.m
o removed EOMKKDArrayMapping +dictionaryFromDictionary:subsetMapping:
o include <EOCOntrol/EOPriv.h>
o replaced isNilOrEONull() by _isNilOrEONull()
* EOControl/EONSAddOns.[hm]:
o added NSString(ShellPattern)
2005-02-10 David Ayers <d.ayers@inode.at>
* EOControl/EOEditingContext.m (_globalIDChanged:): Make assert

View file

@ -39,6 +39,7 @@ RCS_ID("$Id$")
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSException.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSInvocation.h>
#else
#include <Foundation/Foundation.h>
#endif
@ -144,6 +145,8 @@ NSString *EOAccessFaultObjectNotAvailableException = @"EOAccessFaultObjectNotAva
{
if ((self = [super init]))
{
NSDebugFLog(@"INIT EOAccessFaultHandler %p. ThreadID=%p",
(void*)self,(void*)objc_thread_id());
}
return self;
@ -180,8 +183,8 @@ NSString *EOAccessFaultObjectNotAvailableException = @"EOAccessFaultObjectNotAva
- (void)dealloc
{
#ifdef DEBUG
// NSDebugFLog(@"Dealloc EOAccessFaultHandler %p. ThreadID=%p",
// (void*)self,(void*)objc_thread_id());
NSDebugFLog(@"Dealloc EOAccessFaultHandler %p. ThreadID=%p",
(void*)self,(void*)objc_thread_id());
#endif
DESTROY(gid);
@ -220,6 +223,10 @@ NSString *EOAccessFaultObjectNotAvailableException = @"EOAccessFaultObjectNotAva
{
EOFLOGObjectFnStart();
// We want to be sure that we will not be autoreleased
// in a sub autorelease pool !
AUTORELEASE(RETAIN(self));
[databaseContext _fireFault: anObject];
//MIRKO: replaced
@ -236,12 +243,14 @@ NSString *EOAccessFaultObjectNotAvailableException = @"EOAccessFaultObjectNotAva
[self unableToFaultObject: anObject
databaseContext: databaseContext];
}
EOFLOGObjectFnStop();
}
- (BOOL)shouldPerformInvocation: (NSInvocation *)invocation
{
NSDebugFLLog(@"gsdb",@"invocation selector=%@ target: %p",
NSStringFromSelector([invocation selector]),
[invocation target]);
return YES;
}
@ -317,8 +326,8 @@ NSString *EOAccessFaultObjectNotAvailableException = @"EOAccessFaultObjectNotAva
- (void)dealloc
{
#ifdef DEBUG
// NSDebugFLog(@"Dealloc EOAccessArrayFaultHandler %p. ThreadID=%p",
// (void*)self,(void*)objc_thread_id());
NSDebugFLog(@"Dealloc EOAccessArrayFaultHandler %p. ThreadID=%p",
(void*)self,(void*)objc_thread_id());
#endif
DESTROY(sgid);
@ -357,6 +366,10 @@ NSString *EOAccessFaultObjectNotAvailableException = @"EOAccessFaultObjectNotAva
{
EOFLOGObjectFnStart();
// We want to be sure that we will not be autoreleased
// in a sub autorelease pool !
AUTORELEASE(RETAIN(self));
[databaseContext _fireArrayFault: anObject];
[(EOCheapCopyMutableArray *)anObject _setCopy: NO];
@ -380,6 +393,9 @@ NSString *EOAccessFaultObjectNotAvailableException = @"EOAccessFaultObjectNotAva
- (BOOL)shouldPerformInvocation: (NSInvocation *)invocation
{
NSDebugFLLog(@"gsdb",@"invocation selector=%@ target: %p",
NSStringFromSelector([invocation selector]),
[invocation target]);
return YES;
}

View file

@ -385,8 +385,10 @@ NSString *EOAdministrativeConnectionDictionaryKey
admChannel = [admContext createAdaptorChannel];
NS_DURING
{
int stmtsCount=0;
[admChannel openChannel];
for (i = 0; i < [stmts count]; i++)
stmtsCount=[stmts count];
for (i = 0; i < stmtsCount; i++)
{
[admChannel evaluateExpression: [stmts objectAtIndex: i]];
}
@ -928,8 +930,9 @@ NSString *EOAdministrativeConnectionDictionaryKey
*/
+ (void)assignExternalInfoForEntity: (EOEntity *)entity
{
NSArray *attributes;
unsigned i;
NSArray *attributes=nil;
unsigned i=0;
int attributesCount=0;
if ([[entity externalName] length] == 0)
{
@ -941,8 +944,9 @@ NSString *EOAdministrativeConnectionDictionaryKey
}
attributes = [entity attributes];
attributesCount=[attributes count];
for (i = 0; i < [attributes count]; i++)
for (i = 0; i < attributesCount; i++)
{
[self assignExternalInfoForAttribute: [attributes objectAtIndex: i]];
}
@ -956,12 +960,14 @@ NSString *EOAdministrativeConnectionDictionaryKey
*/
+ (void)assignExternalInfoForEntireModel: (EOModel *)model
{
NSArray *entities;
unsigned i;
NSArray *entities=nil;
unsigned i=0;
int entitiesCount=0;
entities = [model entities];
entitiesCount=[entities count];
for (i = 0; i < [entities count]; i++)
for (i = 0; i < entitiesCount; i++)
{
[self assignExternalInfoForEntity: [entities objectAtIndex: i]];
}

View file

@ -53,6 +53,7 @@ RCS_ID("$Id$")
#include <GNUstepBase/GSCategories.h>
#endif
#include <EOControl/EOPriv.h>
#include <EOControl/EOMutableKnownKeyDictionary.h>
#include <EOControl/EOFetchSpecification.h>
#include <EOControl/EONSAddOns.h>

View file

@ -57,7 +57,8 @@ typedef enum {
} EOFactoryMethodArgumentType;
typedef enum {
EOAdaptorNumberType = 0,
EOAdaptorUnknownType = 0, // 0 so it is initialization value
EOAdaptorNumberType,
EOAdaptorCharactersType,
EOAdaptorBytesType,
EOAdaptorDateType
@ -84,7 +85,9 @@ typedef enum {
unsigned int _width;
unsigned short _precision;
short _scale;
char _valueTypeChar; /** First char of _valueType or \0 **/
Class _valueClass;
EOAdaptorValueType _adaptorValueType;
EOFactoryMethodArgumentType _argumentType;
NSString *_valueFactoryMethodName;
NSString *_adaptorValueConversionMethodName;

View file

@ -66,6 +66,7 @@ RCS_ID("$Id$")
#include <EOControl/EONull.h>
#include <EOControl/EOObserver.h>
#include <EOControl/EODebug.h>
#include <EOControl/EOPriv.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOEntity.h>
@ -82,25 +83,14 @@ RCS_ID("$Id$")
@implementation EOAttribute
static EONull *null = nil;
static Class NSStringClass;
static Class NSNumberClass;
static Class NSDecimalNumberClass;
static Class NSDataClass;
static Class NSDateClass;
static Class NSCalendarDateClass;
+ (void)initialize
{
if (null == nil)
static BOOL initialized=NO;
if (!initialized)
{
null = [EONull null];
NSStringClass = [NSString class];
NSNumberClass = [NSNumber class];
NSDecimalNumberClass = [NSDecimalNumber class];
NSDataClass = [NSData class];
NSDateClass = [NSDate class];
NSCalendarDateClass = [NSCalendarDate class];
initialized=YES;
GDL2PrivInit();
}
}
@ -116,8 +106,7 @@ static Class NSCalendarDateClass;
{
if ((self = [self init]))
{
//OK
NSString *tmpString;
NSString *tmpString = nil;
id tmpObject = nil;
[self setName: [propertyList objectForKey: @"name"]];
@ -208,7 +197,7 @@ static Class NSCalendarDateClass;
tmpString = [propertyList objectForKey: @"parameterDirection"];
if (tmpString)
{
if ([tmpString isKindOfClass: NSNumberClass])
if ([tmpString isKindOfClass: GDL2NSNumberClass])
{
[self setParameterDirection: [tmpString intValue]];
}
@ -682,11 +671,10 @@ static Class NSCalendarDateClass;
{
if (_valueType)
return _valueType;
if([self isFlattened])
else if([self isFlattened])
return [[_definitionArray realAttribute] valueType];
return [_prototype valueType];
else
return [_prototype valueType];
}
@end
@ -905,17 +893,24 @@ return nexexp
ASSIGN(_valueType, type);
if ([_valueType length]==1)
_valueTypeChar=(char)[_valueType characterAtIndex:0];
else
_valueTypeChar='\0';
[self _setOverrideForKeyEnum: 4];//TODO
}
- (void)setValueClassName: (NSString *)name
{
//OK
[self willChange];
ASSIGN(_valueClassName, name);
_valueClass = NSClassFromString(_valueClassName);//TODO Do it later !
_valueClass = NSClassFromString(_valueClassName);
_adaptorValueType=EOAdaptorUnknownType; // reset adaptorValueType
[self _setOverrideForKeyEnum: 3];//TODO
}
@ -1080,12 +1075,12 @@ return nexexp
NSData *value = nil;
Class valueClass = [self _valueClass];
if (valueClass != Nil && valueClass != NSDataClass)
if (valueClass != Nil && valueClass != GDL2NSDataClass)
{
switch (_argumentType)
{
case EOFactoryMethodArgumentIsNSData:
value = [[NSData alloc] initWithBytes:bytes length: length]; //For efficiency reasons, the returned value is NOT autoreleased !
value = [GDL2NSData_alloc() initWithBytes:bytes length: length]; //For efficiency reasons, the returned value is NOT autoreleased !
if(_valueFactoryMethod != NULL)
value = [(id)valueClass performSelector: _valueFactoryMethod
@ -1115,7 +1110,7 @@ return nexexp
}
if(!value)
value = [[NSData alloc] initWithBytes: bytes length: length];//For efficiency reasons, the returned value is NOT autoreleased !
value = [GDL2NSData_alloc() initWithBytes: bytes length: length];//For efficiency reasons, the returned value is NOT autoreleased !
return value;
}
@ -1136,15 +1131,15 @@ return nexexp
id value = nil;
Class valueClass = [self _valueClass];
if (valueClass != Nil && valueClass != NSStringClass)
if (valueClass != Nil && valueClass != GDL2NSStringClass)
{
switch (_argumentType)
{
case EOFactoryMethodArgumentIsNSString:
value = [[NSString alloc] initWithData: [NSData dataWithBytes: bytes
length: length]
encoding: encoding];//For efficiency reasons, the returned value is NOT autoreleased !
value = [GDL2NSString_alloc() initWithData: [NSData dataWithBytes: bytes
length: length]
encoding: encoding];//For efficiency reasons, the returned value is NOT autoreleased !
value = [(id)valueClass performSelector: _valueFactoryMethod
withObject: [value autorelease]];
break;
@ -1173,9 +1168,9 @@ return nexexp
}
if(!value)
value = [[NSString alloc]
initWithData: [NSData dataWithBytes: bytes length: length]
encoding: encoding];//For efficiency reasons, the returned value is NOT autoreleased !
value = [GDL2NSString_alloc()
initWithData: [NSData dataWithBytes: bytes length: length]
encoding: encoding];//For efficiency reasons, the returned value is NOT autoreleased !
return value;
}
@ -1200,7 +1195,7 @@ return nexexp
NSCalendarDate *date;
//For efficiency reasons, the returned value is NOT autoreleased !
date = [[NSCalendarDateClass allocWithZone: zone]
date = [[GDL2NSCalendarDateClass allocWithZone: zone]
initWithYear: year
month: month
day: day
@ -1245,17 +1240,30 @@ return nexexp
switch (adaptorValueType)
{
/* Temporary reverted so we can discuss about this
case EOAdaptorNumberType:
convert = [value isKindOfClass: NSNumberClass] ? NO : YES;
convert = [value isKindOfClass: GDL2NSNumberClass] ? NO : YES;
break;
case EOAdaptorCharactersType:
convert = [value isKindOfClass: NSStringClass] ? NO : YES;
convert = [value isKindOfClass: GDL2NSStringClass] ? NO : YES;
break;
case EOAdaptorBytesType:
convert = [value isKindOfClass: NSDataClass] ? NO : YES;
convert = [value isKindOfClass: GDL2NSDataClass] ? NO : YES;
break;
case EOAdaptorDateType:
convert = [value isKindOfClass: NSDateClass] ? NO : YES;
convert = [value isKindOfClass: GDL2NSDateClass] ? NO : YES;
break;
*/
//TODO It's only a quick Fix
case EOAdaptorNumberType:
case EOAdaptorCharactersType:
case EOAdaptorDateType:
convert = ([value isKindOfClass: GDL2NSNumberClass]
|| [value isKindOfClass: GDL2NSStringClass]
|| [value isKindOfClass: GDL2NSDateClass]) ? NO : YES;
break;
case EOAdaptorBytesType:
convert = [value isKindOfClass: GDL2NSDataClass] ? NO : YES;
break;
default:
[NSException raise: NSInvalidArgumentException
@ -1263,7 +1271,7 @@ return nexexp
adaptorValueType];
}
convert = (value == null) ? NO : convert;
convert = (value == GDL2EONull) ? NO : convert;
if (convert)
{
@ -1281,8 +1289,10 @@ return nexexp
/* This exception might not be conformant, but seems helpful. */
[NSException raise: NSInvalidArgumentException
format: @"Value of class: %@ needs conversion "
@"yet no conversion method specified.",
NSStringFromClass([value class])];
@"yet no conversion method specified. "
@"Attribute is %@. adaptorValueType=%d",
NSStringFromClass([value class]),
self,adaptorValueType];
}
}
else
@ -1306,27 +1316,32 @@ return nexexp
- (EOAdaptorValueType)adaptorValueType
{
Class adaptorClasses[] = { NSNumberClass,
NSStringClass,
NSDateClass };
EOAdaptorValueType values[] = { EOAdaptorNumberType,
EOAdaptorCharactersType,
EOAdaptorDateType };
Class valueClass;
int i;
for ( i = 0; i < 3; i++)
if (_adaptorValueType==EOAdaptorUnknownType)
{
for ( valueClass = [self _valueClass];
valueClass != Nil;
valueClass = GSObjCSuper(valueClass))
{
if (valueClass == adaptorClasses[i])
return values[i];
}
}
return EOAdaptorBytesType;
Class adaptorClasses[] = { GDL2NSNumberClass,
GDL2NSStringClass,
GDL2NSDateClass };
EOAdaptorValueType values[] = { EOAdaptorNumberType,
EOAdaptorCharactersType,
EOAdaptorDateType };
Class valueClass = Nil;
int i = 0;
for ( i = 0; i < 3; i++)
{
for ( valueClass = [self _valueClass];
valueClass != Nil;
valueClass = GSObjCSuper(valueClass))
{
if (valueClass == adaptorClasses[i])
_adaptorValueType=values[i];
}
}
if (_adaptorValueType==EOAdaptorUnknownType)
_adaptorValueType=EOAdaptorBytesType;
};
return _adaptorValueType;
}
- (EOFactoryMethodArgumentType)factoryMethodArgumentType
@ -1389,9 +1404,9 @@ return nexexp
if ([*valueP isKindOfClass: valueClass] == NO)
{
if ([*valueP isKindOfClass: NSStringClass])
if ([*valueP isKindOfClass: GDL2NSStringClass])
{
if (valueClass == NSNumberClass)
if (valueClass == GDL2NSNumberClass)
{
if ([[self valueType] isEqualToString: @"i"] == YES)
*valueP = [NSNumber numberWithInt:
@ -1430,24 +1445,24 @@ return nexexp
*valueP = [NSNumber numberWithDouble:
[*valueP doubleValue]];
}
else if (valueClass == NSDecimalNumberClass)
else if (valueClass == GDL2NSDecimalNumberClass)
*valueP = [NSDecimalNumber
decimalNumberWithString: *valueP];
else if (valueClass == NSDataClass)
else if (valueClass == GDL2NSDataClass)
*valueP = [*valueP
dataUsingEncoding: NSASCIIStringEncoding
allowLossyConversion: YES];
else if (valueClass == NSCalendarDateClass)
*valueP = [[[NSCalendarDateClass alloc]
else if (valueClass == GDL2NSCalendarDateClass)
*valueP = [[[GDL2NSCalendarDateClass alloc]
initWithString: *valueP]
autorelease];
}
}
else
{
if ([*valueP isKindOfClass: NSStringClass])
if ([*valueP isKindOfClass: GDL2NSStringClass])
{
unsigned width = [self width];
@ -1460,7 +1475,7 @@ return nexexp
length: width];
}
}
else if ([*valueP isKindOfClass: NSNumberClass])
else if ([*valueP isKindOfClass: GDL2NSNumberClass])
{
// TODO ??
}
@ -1515,13 +1530,25 @@ return nexexp
{
if (_valueClass)
return _valueClass;
if ([self isFlattened])
else if ([self isFlattened])
return [[_definitionArray realAttribute] _valueClass];
return [_prototype _valueClass];
else
return [_prototype _valueClass];
}
- (char)_valueTypeChar
{
char valueTypeChar=_valueTypeChar;
if (valueTypeChar=='\0')
{
// Compute it
NSString* valueType=[self valueType];
if ([valueType length]==1)
valueTypeChar=(char)[valueType characterAtIndex:0];
}
return valueTypeChar;
};
@end
@implementation EOAttribute (EOAttributePrivate2)

View file

@ -34,6 +34,7 @@
- (EOAttribute *)realAttribute;
- (Class)_valueClass;
- (char)_valueTypeChar;
@end
@interface EOAttribute (EOAttributePrivate2)

View file

@ -57,6 +57,7 @@ RCS_ID("$Id$")
#include <EOControl/EOKeyGlobalID.h>
#include <EOControl/EONull.h>
#include <EOControl/EODebug.h>
#include <EOControl/EOPriv.h>
#include <EOAccess/EOAccessFault.h>
#include <EOAccess/EOAdaptor.h>
@ -84,8 +85,16 @@ static NSMutableArray *databaseInstances;
+ (void)initialize
{
// THREAD
databaseInstances = [NSMutableArray new];
static BOOL initialized=NO;
if (!initialized)
{
initialized=YES;
GDL2PrivInit();
// THREAD
databaseInstances = [NSMutableArray new];
}
}
+ (void)makeAllDatabasesPerform: (SEL)aSelector withObject: anObject
@ -289,7 +298,7 @@ static NSMutableArray *databaseInstances;
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"object=%p (of class %@)",
object, [object class]);
NSAssert(!isNilOrEONull(object), @"No object");
NSAssert(!_isNilOrEONull(object), @"No object");
if ([EOFault isFault: object])
{

View file

@ -63,6 +63,7 @@ RCS_ID("$Id$")
#include <EOControl/EOKeyGlobalID.h>
#include <EOControl/EOObjectStore.h>
#include <EOControl/EODebug.h>
#include <EOControl/EOPriv.h>
#include <EOAccess/EODatabaseChannel.h>
#include <EOAccess/EODatabaseContext.h>
@ -87,8 +88,11 @@ RCS_ID("$Id$")
+ (void)initialize
{
if (self == [EODatabaseChannel class])
static BOOL initialized=NO;
if (!initialized)
{
initialized=YES;
GDL2PrivInit();
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(_registerDatabaseChannel:)
@ -317,7 +321,6 @@ RCS_ID("$Id$")
row = [_adaptorChannel fetchRowWithZone: NULL];
EOFLOGObjectLevelArgs(@"gsdb", @"row=%@", row);
//NSDebugMLog(@"TEST attributesToFetch=%@", [_currentEntity attributesToFetch]);
if (!row)
{
@ -345,7 +348,6 @@ RCS_ID("$Id$")
isFinal: YES];//OK
EOFLOGObjectLevelArgs(@"gsdb", @"gid=%@", gid);
//NSDebugMLog(@"TEST attributesToFetch=%@",[_currentEntity attributesToFetch]);
object = [_currentEditingContext objectForGlobalID: gid]; //OK //nil
@ -359,7 +361,6 @@ RCS_ID("$Id$")
snapshot = [_databaseContext snapshotForGlobalID: gid]; //OK
EOFLOGObjectLevelArgs(@"gsdb", @"snapshot=%@", snapshot);
//NSDebugMLog(@"TEST attributesToFetch=%@", [_currentEntity attributesToFetch]);
if (snapshot)
{
@ -391,7 +392,6 @@ RCS_ID("$Id$")
}
else
{
//NSDebugMLog(@"TEST attributesToFetch=%@", [_currentEntity attributesToFetch]);
EOFLOGObjectLevelArgs(@"gsdb", @"database class=%@", [database class]);
NSAssert(database, @"No database-context database");
@ -422,12 +422,10 @@ RCS_ID("$Id$")
globalID: gid
zone: NULL];
//NSDebugMLog(@"TEST attributesToFetch=%@", [_currentEntity attributesToFetch]);
EOFLOGObjectLevelArgs(@"gsdb", @"object=%@", object);
NSAssert1(object, @"No Object. entityClassDescripton=%@", entityClassDescripton);
[_currentEditingContext recordObject: object
globalID: gid];
EOEditingContext_recordObjectGlobalIDWithImpPtr(_currentEditingContext,NULL,object,gid);
}
else if (object && [EOFault isFault: object])
{
@ -480,8 +478,6 @@ RCS_ID("$Id$")
- (BOOL)isFetchInProgress
{
//NSDebugMLog(@"TEST attributesToFetch=%@", [_currentEntity attributesToFetch]);
return [_adaptorChannel isFetchInProgress];
}

File diff suppressed because it is too large Load diff

View file

@ -73,5 +73,6 @@
@end
GDL2ACCESS_EXPORT NSDictionary* EODatabaseContext_snapshotForGlobalIDWithImpPtr(EODatabaseContext* dbContext,IMP* impPtr,EOGlobalID* gid);
#endif /* __EODatabaseContextPriv_h__ */

View file

@ -273,6 +273,15 @@ GDL2ACCESS_EXPORT NSString *EONextPrimaryKeyProcedureOperation;
@end
/** Useful private methods made public in GDL2 **/
@interface EOEntity (EOEntityGDL2Additions)
/** Returns attribute (if any) for path **/
- (EOAttribute *)attributeForPath: (NSString *)path;
/** Returns relationship (if any) for path **/
- (EORelationship *)relationshipForPath: (NSString *)path;
@end
@interface EOEntityClassDescription : EOClassDescription
{

View file

@ -71,6 +71,7 @@ RCS_ID("$Id$")
#include <EOControl/EOKeyGlobalID.h>
#include <EOControl/EOEditingContext.h>
#include <EOControl/EONull.h>
#include <EOControl/EOPriv.h>
#include <EOControl/EOMutableKnownKeyDictionary.h>
#include <EOControl/EONSAddOns.h>
#include <EOControl/EOCheapArray.h>
@ -99,6 +100,17 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
@implementation EOEntity
+ (void)initialize
{
static BOOL initialized=NO;
if (!initialized)
{
initialized=YES;
GDL2PrivInit();
};
};
/* Not documented becuase it is not a public method. */
- (id) initWithPropertyList: (NSDictionary*)propertyList
owner: (id)owner
@ -1403,9 +1415,11 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
if (!classProperty)
classProperty = [self relationshipNamed: classPropertyName];
NSAssert2(classProperty,
@"No attribute or relationship named %@ to use as classProperty in entity %@",
NSAssert4(classProperty,
@"No attribute or relationship named '%@' (property at index %d) to use as classProperty in entity name '%@' : %@",
classPropertyName,
i+1,
[self name],
self);
if ([self isValidClassProperty: classProperty])
@ -1689,7 +1703,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
id value = [row objectForKey: [attr name]];
if (!value)
value = [EONull null];
value = GDL2EONull;
[dict setObject: value
forKey: [attr name]];
@ -1740,7 +1754,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
NS_DURING
{
value = [object valueForKey: key];
if (value == nil || value == [EONull null] || value == [NSNull null])
if (value == nil || value == GDL2EONull || value == [NSNull null])
isValid = NO;
}
NS_HANDLER
@ -2115,9 +2129,9 @@ createInstanceWithEditingContext:globalID:zone:
DESTROY(_classProperties);
if ([properties isKindOfClass:[GCArray class]]
|| [properties isKindOfClass: [GCMutableArray class]])
_classProperties = [[GCMutableArray alloc] initWithArray: properties];
_classProperties = [((NSArray*)[GCMutableArray alloc]) initWithArray: properties];
else
_classProperties = [[GCMutableArray alloc] initWithArray: properties]; //TODO
_classProperties = [((NSArray*)[GCMutableArray alloc]) initWithArray: properties]; //TODO
[self _setIsEdited]; //To clean cache
@ -2136,9 +2150,9 @@ createInstanceWithEditingContext:globalID:zone:
if ([keys isKindOfClass:[GCArray class]]
|| [keys isKindOfClass: [GCMutableArray class]])
_primaryKeyAttributes = [[GCMutableArray alloc] initWithArray: keys];
_primaryKeyAttributes = [((NSArray*)[GCMutableArray alloc]) initWithArray: keys];
else
_primaryKeyAttributes = [[GCMutableArray alloc] initWithArray: keys]; // TODO
_primaryKeyAttributes = [((NSArray*)[GCMutableArray alloc]) initWithArray: keys]; // TODO
[self _setIsEdited];//To clean cache
@ -2157,10 +2171,10 @@ createInstanceWithEditingContext:globalID:zone:
if ([attributes isKindOfClass: [GCArray class]] // TODO
|| [attributes isKindOfClass: [GCMutableArray class]])
_attributesUsedForLocking = [[GCMutableArray alloc]
_attributesUsedForLocking = [((NSArray*)[GCMutableArray alloc])
initWithArray: attributes];
else
_attributesUsedForLocking = [[GCMutableArray alloc]
_attributesUsedForLocking = [((NSArray*)[GCMutableArray alloc])
initWithArray: attributes];
[self _setIsEdited]; //To clean cache
@ -2418,6 +2432,107 @@ createInstanceWithEditingContext:globalID:zone:
@end
/** Useful private methods made public in GDL2 **/
@implementation EOEntity (EOEntityGDL2Additions)
/** Returns attribute (if any) for path **/
- (EOAttribute*) attributeForPath: (NSString*)path
{
//OK
EOAttribute *attribute = nil;
NSArray *pathElements = nil;
NSString *part = nil;
EOEntity *entity = self;
int i, count = 0;
EOFLOGObjectFnStart();
EOFLOGObjectLevelArgs(@"EOEntity", @"path=%@", path);
pathElements = [path componentsSeparatedByString: @"."];
EOFLOGObjectLevelArgs(@"EOEntity", @"pathElements=%@", pathElements);
count = [pathElements count];
for (i = 0; i < count - 1; i++)
{
EORelationship *rel = nil;
part = [pathElements objectAtIndex: i];
EOFLOGObjectLevelArgs(@"EOEntity", @"i=%d part=%@", i, part);
rel = [entity anyRelationshipNamed: part];
NSAssert2(rel,
@"no relationship named %@ in entity %@",
part,
[entity name]);
EOFLOGObjectLevelArgs(@"EOEntity", @"i=%d part=%@ rel=%@",
i, part, rel);
entity = [rel destinationEntity];
EOFLOGObjectLevelArgs(@"EOEntity", @"entity name=%@", [entity name]);
}
part = [pathElements lastObject];
EOFLOGObjectLevelArgs(@"EOEntity", @"part=%@", part);
attribute = [entity anyAttributeNamed: part];
EOFLOGObjectLevelArgs(@"EOEntity", @"resulting attribute=%@", attribute);
EOFLOGObjectFnStop();
return attribute;
}
/** Returns relationship (if any) for path **/
- (EORelationship*) relationshipForPath: (NSString*)path
{
//OK ?
EORelationship *relationship = nil;
EOEntity *entity = self;
NSArray *pathElements = nil;
int i, count;
EOFLOGObjectFnStart();
EOFLOGObjectLevelArgs(@"EOEntity", @"path=%@", path);
pathElements = [path componentsSeparatedByString: @"."];
count = [pathElements count];
for (i = 0; i < count; i++)
{
NSString *part = [pathElements objectAtIndex: i];
relationship = [entity anyRelationshipNamed: part];
EOFLOGObjectLevelArgs(@"EOEntity", @"i=%d part=%@ rel=%@",
i, part, relationship);
if (relationship)
{
entity = [relationship destinationEntity];
EOFLOGObjectLevelArgs(@"EOEntity", @"entity name=%@", [entity name]);
}
else if (i < (count - 1)) // Not the last part
{
NSAssert2(relationship,
@"no relationship named %@ in entity %@",
part,
[entity name]);
}
}
EOFLOGObjectFnStop();
EOFLOGObjectLevelArgs(@"EOEntity", @"relationship=%@", relationship);
return relationship;
}
@end
@implementation EOEntity (EOEntityPrivate)
- (BOOL)isPrototypeEntity
@ -3706,100 +3821,6 @@ toDestinationAttributeInLastComponentOfRelationshipPath: (NSString*)path
return [self notImplemented: _cmd]; //TODO
}
- (EOAttribute*) attributeForPath: (NSString*)path
{
//OK
EOAttribute *attribute = nil;
NSArray *pathElements = nil;
NSString *part = nil;
EOEntity *entity = self;
int i, count = 0;
EOFLOGObjectFnStart();
EOFLOGObjectLevelArgs(@"EOEntity", @"path=%@", path);
pathElements = [path componentsSeparatedByString: @"."];
EOFLOGObjectLevelArgs(@"EOEntity", @"pathElements=%@", pathElements);
count = [pathElements count];
for (i = 0; i < count - 1; i++)
{
EORelationship *rel = nil;
part = [pathElements objectAtIndex: i];
EOFLOGObjectLevelArgs(@"EOEntity", @"i=%d part=%@", i, part);
rel = [entity anyRelationshipNamed: part];
NSAssert2(rel,
@"no relationship named %@ in entity %@",
part,
[entity name]);
EOFLOGObjectLevelArgs(@"EOEntity", @"i=%d part=%@ rel=%@",
i, part, rel);
entity = [rel destinationEntity];
EOFLOGObjectLevelArgs(@"EOEntity", @"entity name=%@", [entity name]);
}
part = [pathElements lastObject];
EOFLOGObjectLevelArgs(@"EOEntity", @"part=%@", part);
attribute = [entity anyAttributeNamed: part];
EOFLOGObjectLevelArgs(@"EOEntity", @"resulting attribute=%@", attribute);
EOFLOGObjectFnStop();
return attribute;
}
- (EORelationship*) relationshipForPath: (NSString*)path
{
//OK ?
EORelationship *relationship = nil;
EOEntity *entity = self;
NSArray *pathElements = nil;
int i, count;
EOFLOGObjectFnStart();
EOFLOGObjectLevelArgs(@"EOEntity", @"path=%@", path);
pathElements = [path componentsSeparatedByString: @"."];
count = [pathElements count];
for (i = 0; i < count; i++)
{
NSString *part = [pathElements objectAtIndex: i];
relationship = [entity anyRelationshipNamed: part];
EOFLOGObjectLevelArgs(@"EOEntity", @"i=%d part=%@ rel=%@",
i, part, relationship);
if (relationship)
{
entity = [relationship destinationEntity];
EOFLOGObjectLevelArgs(@"EOEntity", @"entity name=%@", [entity name]);
}
else if (i < (count - 1)) // Not the last part
{
NSAssert2(relationship,
@"no relationship named %@ in entity %@",
part,
[entity name]);
}
}
EOFLOGObjectFnStop();
EOFLOGObjectLevelArgs(@"EOEntity", @"relationship=%@", relationship);
return relationship;
}
- (void) _addAttributesToFetchForRelationshipPath: (NSString*)relPath
atts: (NSMutableDictionary*)attributes
{

View file

@ -126,8 +126,6 @@ toDestinationAttributeInLastComponentOfRelationshipPath: (NSString *)path;
- (id)classPropertyToManyRelationshipNames;
- (id)classPropertyToOneRelationshipNames;
- (id)qualifierForDBSnapshot: (id)param0;
- (EOAttribute *)attributeForPath: (NSString *)path;
- (EORelationship *)relationshipForPath: (NSString *)path;
- (void)_addAttributesToFetchForRelationshipPath: (NSString *)path
atts: (NSMutableDictionary *)atts;
- (id)dbSnapshotKeys;

View file

@ -54,6 +54,7 @@ RCS_ID("$Id$")
#endif
#include <EOControl/EOObserver.h>
#include <EOControl/EOPriv.h>
#include <EOControl/EOMutableKnownKeyDictionary.h>
#include <EOControl/EONSAddOns.h>
#include <EOControl/EODebug.h>

View file

@ -63,6 +63,7 @@ RCS_ID("$Id$")
#include <EOControl/EOSortOrdering.h>
#include <EOControl/EODebug.h>
#include <EOControl/EONull.h>
#include <EOControl/EOPriv.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOEntity.h>
@ -88,13 +89,21 @@ NSString *EOBindVariableValueKey = @"EOBindVariableValueKey";
NSString *EOBindVariablePlaceHolderKey = @"EOBindVariablePlaceHolderKey";
NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
@interface EOSQLExpression(Private)
+ (id)sqlExpressionWithEntity: (EOEntity *)entity;
@end
@implementation EOSQLExpression
+ (void) initialize
{
static BOOL initialized=NO;
if (!initialized)
{
GDL2PrivInit();
};
};
+ (id)sqlExpressionWithEntity: (EOEntity *)entity
{
return [[[self alloc] initWithEntity: entity] autorelease];
@ -340,12 +349,13 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
// insert: ret quotation_place ?? / select: ret quotation_place t0
NSMutableString *entitiesString = [NSMutableString string];
NSEnumerator *relationshipEnum;
NSString *relationshipPath;
EOEntity *currentEntity;
IMP entitiesStringAppendStringIMP = NULL;
NSEnumerator *relationshipEnum = nil;
NSString *relationshipPath = nil;
EOEntity *currentEntity = nil;
int i = 0;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"entity=%@", entity);
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"_aliasesByRelationshipPath=%@",
@ -357,7 +367,10 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
currentEntity = entity;
if (i)
[entitiesString appendString: @", "];
GDL2AppendStringWithImp(entitiesString,
entitiesStringAppendStringIMP,@", ");
else
entitiesStringAppendStringIMP = [entitiesString methodForSelector:GDL2_appendStringSEL];
if ([relationshipPath isEqualToString: @""])
{
@ -374,7 +387,8 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
@"No external name for entity %@",
[currentEntity name]);
[entitiesString appendString: tableName];
GDL2AppendStringWithImp(entitiesString,
entitiesStringAppendStringIMP,tableName);
if (_flags.useAliases)
[entitiesString appendFormat: @" %@",
@ -385,7 +399,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
{
NSEnumerator *defEnum = nil;
NSArray *defArray = nil;
NSString *relationshipString;
NSString *relationshipString = nil;
NSString *tableName = nil;
defArray = [relationshipPath componentsSeparatedByString: @"."];
@ -421,14 +435,18 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
@"No external name for entity %@",
[currentEntity name]);
[entitiesString appendString: tableName];
GDL2AppendStringWithImp(entitiesString,
entitiesStringAppendStringIMP,tableName);
if (_flags.useAliases)
{
NSString *alias = [_aliasesByRelationshipPath
objectForKey: relationshipPath];
[entitiesString appendFormat: @" %@",alias];
GDL2AppendStringWithImp(entitiesString,
entitiesStringAppendStringIMP,@" ");
GDL2AppendStringWithImp(entitiesString,
entitiesStringAppendStringIMP,alias);
EOFLOGObjectLevelArgs(@"EOSQLExpression",
@"appending alias %@ in entitiesString",
@ -443,7 +461,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
@"entitiesString=%@",
entitiesString);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return entitiesString;
}
@ -456,7 +474,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
NSEnumerator *rowEnum;
NSString *attributeName;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"row=%@", row);
@ -505,7 +523,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"_statement=%@", _statement);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
}
- (void)prepareUpdateExpressionWithRow: (NSDictionary *)row
@ -519,7 +537,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
NSEnumerator *rowEnum;
NSString *attributeName;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
rowEnum = [row keyEnumerator];
while ((attributeName = [rowEnum nextObject]))
@ -550,7 +568,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
ASSIGN(_statement, statement);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
}
- (void)prepareDeleteExpressionForQualifier: (EOQualifier *)qualifier
@ -576,7 +594,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
NSString *lockClause = nil;
NSArray *sortOrderings;
EOFLOGObjectFnStartOrCond(@"EOSQLExpression");
EOFLOGObjectFnStartCond(@"EOSQLExpression");
// Turbocat (RawRow Additions)
if ([fetchSpecification rawRowKeyPaths]) {
@ -638,7 +656,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
_orderByString : nil)
lockClause:lockClause]);
EOFLOGObjectFnStopOrCond(@"EOSQLExpression");
EOFLOGObjectFnStopCond(@"EOSQLExpression");
}
*/
@ -659,7 +677,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
//Add Attributes to listString
int i, count = [attributes count];
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
//OK
for (i = 0; i < count; i++)
@ -764,7 +782,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
lockClause: lockClauseString];
ASSIGN(_statement, statement);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
}
- (NSString *)assembleJoinClauseWithLeftName: (NSString *)leftName
@ -774,7 +792,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
NSString *op = nil;
NSString *joinClause = nil;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"join parts=%@ %d %@",
leftName,
@ -809,7 +827,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"joinClause=%@", joinClause);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return joinClause;
}
@ -820,7 +838,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
{
NSString *joinClause = nil;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"join parts=%@ %d %@",
leftName,
@ -846,7 +864,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"_joinClauseString=%@",
_joinClauseString);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
}
/** Build join expression for all used relationships (call this) after all other query parts construction) **/
@ -856,7 +874,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
NSEnumerator *relationshipEnum;
NSString *relationshipPath;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"_aliasesByRelationshipPath=%@",
_aliasesByRelationshipPath);
@ -950,7 +968,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
}
}
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
}
- (NSString *)assembleInsertStatementWithRow: (NSDictionary *)row
@ -999,7 +1017,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
{ //TODO selectString ??
NSMutableString *sqlString;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"attributes=%@", attributes);
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"qualifier=%@", qualifier);
@ -1038,7 +1056,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
[sqlString appendFormat: @" ORDER BY %@", orderByClause];
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sqlString=%@", sqlString);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return sqlString;
}
@ -1070,7 +1088,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
NSMutableString *listString;
NSString *attributeSQLString;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"attribute name=%@",
[attribute name]);
@ -1114,7 +1132,8 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
writeFormat = [attribute writeFormat];
if ([writeFormat length] > 0)
{
//TODO
NSEmitTODO(); //TODO
NSDebugMLog(@"writeFormat '%@' not yet handled",writeFormat);
}
valueList = [self valueList];
@ -1128,7 +1147,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
}
NS_ENDHANDLER;
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
}
- (void)addUpdateListAttribute: (EOAttribute *)attribute
@ -1141,7 +1160,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
NSString *valueSQLString;
NSString *writeFormat;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
attributeSQLString = [self sqlStringForAttribute: attribute];
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"attributeSQLString=%@",
@ -1156,7 +1175,8 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
if ([writeFormat length] > 0)
{
//TODO
NSEmitTODO(); //TODO
NSDebugMLog(@"writeFormat '%@' not yet handled",writeFormat);
}
listString = [self listString];
@ -1167,7 +1187,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
[self appendItem: sqlStringToAdd
toListString: listString];
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
}
+ (NSString *)formatStringValue: (NSString *)string
@ -1193,7 +1213,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
//mirko new:return [value sqlString];
NSString *formattedValue = nil;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @" value=%@ class=%@",
value, [value class]);
@ -1209,9 +1229,9 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
string = [value sqlString];
EOFLOGObjectLevelArgs(@"EOSQLExpression", @" value %p=%@ null %p=%@",
value, value, [EONull null], [EONull null]);
value, value, GDL2EONull, GDL2EONull);
if ([value isEqual: [EONull null]])
if (value == GDL2EONull)
formattedValue = string;
else
formattedValue = [self formatSQLString: [self formatStringValue:
@ -1226,7 +1246,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
}
NS_ENDHANDLER;
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return formattedValue;
}
@ -1236,7 +1256,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
{
NSString *formatted = nil;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @" sqlString=%@ format=%@",
sqlString, format);
@ -1252,25 +1272,26 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
char *s;
NSMutableString *str = [NSMutableString stringWithCapacity:
[format length]];
IMP appendStringIMP = [str methodForSelector:GDL2_appendStringSEL];
while ((s = strchr(p, '%')))
{
switch (*(s + 1))
{
case '%':
[str appendString: [NSString stringWithCString: p
length: s-p+1]];
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p+1));
break;
case 'P':
if (s != p)
[str appendString: [NSString stringWithCString: p
length: s-p]];
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
[str appendString: sqlString];
break;
default:
if (s != p)
[str appendString: [NSString stringWithCString: p
length: s-p]];
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
break;
}
@ -1278,7 +1299,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
}
if (*p)
[str appendString: [NSString stringWithCString: p]];
GDL2AppendStringWithImp(str,appendStringIMP,[NSString stringWithCString: p]);
formatted = str;
}
@ -1292,7 +1313,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
EOFLOGObjectLevelArgs(@"EOSQLExpression", @" formatted=%@", formatted);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return formatted;
}
@ -1306,7 +1327,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
int i, count;
int nb=0;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"operation=%@ qualifiers=%@",
operation, qualifiers);
@ -1356,7 +1377,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"operation=%@ qualifiers=%@ count=%d nb=%d sqlString=%@",
operation, qualifiers, count, nb, sqlString);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return sqlString;
}
@ -1366,14 +1387,14 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
//OK
NSString *sqlString;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
sqlString = [self sqlStringForArrayOfQualifiers: qualifiers
operation: @" AND "];
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sqlString=%@", sqlString);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return sqlString;
}
@ -1383,14 +1404,14 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
//OK
NSString *sqlString;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
sqlString = [self sqlStringForArrayOfQualifiers: qualifiers
operation: @" OR "];
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sqlString=%@", sqlString);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return sqlString;
}
@ -1399,7 +1420,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
{
NSString *sqlQual = nil;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
sqlQual = [(id)qualifier sqlStringForSQLExpression: self];
if (sqlQual)
@ -1407,7 +1428,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sqlQual=%@", sqlQual);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return sqlQual;
}
@ -1424,7 +1445,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
EOAttribute* attribute=nil;
NSString* readFormat=nil;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"qualifier=%@", qualifier);
@ -1453,11 +1474,9 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
if (readFormat)
{
NSEmitTODO(); //TODO
NSDebugMLog(@"readFormat '%@' not yet handled",readFormat);
}
valueSQLString = [self sqlStringForValue: value
attributeNamed: key];//OK
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"valueSQLString=%@ qualifier=%@ [qualifier selector]=%p %@",
valueSQLString,
qualifier,
@ -1465,23 +1484,32 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
NSStringFromSelector([qualifier selector]));
selectorSQLString = [self sqlStringForSelector: [qualifier selector]
value: value];//OK //value ??
value: value];
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"selectorSQLString=%@",
selectorSQLString);
//??
if (sel_eq([qualifier selector], EOQualifierOperatorLike))
valueSQLString = [[self class] sqlPatternFromShellPattern: valueSQLString];
{
value = [[self class] sqlPatternFromShellPattern: value];
valueSQLString = [self sqlStringForValue: value
attributeNamed: key];
}
else if (sel_eq([qualifier selector], EOQualifierOperatorCaseInsensitiveLike))
{
valueSQLString = [[self class] sqlPatternFromShellPattern: valueSQLString];
//VERIFY
value = [[self class] sqlPatternFromShellPattern: value];
valueSQLString = [self sqlStringForValue: value
attributeNamed: key];
attributeSQLString = [NSString stringWithFormat: @"UPPER(%@)",
attributeSQLString];
valueSQLString = [NSString stringWithFormat: @"UPPER(%@)",
valueSQLString];
}
else
valueSQLString = [self sqlStringForValue: value
attributeNamed: key];
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"attributeSQLString=%@",
attributeSQLString);
@ -1507,7 +1535,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sqlString=%@", sqlString);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return sqlString; //return someting like t1.label = 'XXX'
}
@ -1627,7 +1655,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
EORelationship *rel = nil;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
NSAssert(entity,@"no entity");
NSAssert(name,@"no attribute name");
@ -1714,7 +1742,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
attribute);
}
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return sqlString;
}
@ -1725,14 +1753,14 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
//seems OK
if (sel_eq(selector, EOQualifierOperatorEqual))
{
if ([value isKindOfClass: [[EONull null] class]])
if (value==GDL2EONull)
return @"is";
else
return @"=";
}
else if (sel_eq(selector, EOQualifierOperatorNotEqual))
{
if ([value isKindOfClass: [[EONull null] class]])
if (value==GDL2EONull)
return @"is not";
else
return @"<>";
@ -1766,7 +1794,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
EOAttribute *attribute;
NSString *sqlString = nil;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"value=%@", value);
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"attributeName=%@",
@ -1816,7 +1844,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
format: [attribute readFormat]];
}
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sqlString=%@", sqlString);
return sqlString;
@ -1826,7 +1854,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
{
NSString *sqlString = nil;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"anAttribute=%@",
anAttribute);
@ -1956,7 +1984,7 @@ else if([anAttribute isDerived] == YES)
}
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sqlString=%@", sqlString);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return sqlString;
}
@ -1965,7 +1993,7 @@ else if([anAttribute isDerived] == YES)
{
NSString *sqlString = nil;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"path=%@", path);
@ -2027,7 +2055,7 @@ else if([anAttribute isDerived] == YES)
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"path=%@ sqlString=%@",
path, sqlString);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return sqlString;
}
@ -2058,67 +2086,79 @@ else if([anAttribute isDerived] == YES)
+ (NSString *)sqlPatternFromShellPattern: (NSString *)pattern
{
const char *s, *p, *init = [pattern cString];
NSMutableString *str = [NSMutableString stringWithCapacity:
[pattern length]];
for (s = p = init; *s; s++)
NSString* sqlPattern=nil;
int patternLength=[pattern length];
if (patternLength==0)
sqlPattern=pattern;
else
{
switch (*s)
const char *s, *p, *init = [pattern cString];
NSMutableString *str = [NSMutableString stringWithCapacity:
patternLength];
IMP appendStringIMP = [str methodForSelector:GDL2_appendStringSEL];
for (s = p = init; *s; s++)
{
case '*':
if (s != p)
[str appendString: [NSString stringWithCString: p
length: s-p]];
[str appendString: @"%"];
p = s+1;
break;
case '?':
if (s != p)
[str appendString:[NSString stringWithCString: p
length: s-p]];
[str appendString: @"_"];
p = s+1;
break;
case '%':
if (s != p)
[str appendString:[NSString stringWithCString: p
length: s-p]];
if (s != init && *(s-1) == '[' && *(s+1) == ']')
{
[str appendString: @"%]"];
p = s+2; s++;
}
else
{
[str appendString: @"[%]"];
p = s+1;
}
break;
case '_':
if (s != p)
[str appendString:[NSString stringWithCString: p
length: s-p]];
if (s != init && *(s-1) == '[' && *(s+1) == ']')
{
[str appendString: @"_]"];
p = s+2; p++;
}
else
{
[str appendString: @"[_]"];
p = s+1;
}
break;
switch (*s)
{
case '*':
if (s != p)
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
[str appendString: @"%"];
p = s+1;
break;
case '?':
if (s != p)
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
GDL2AppendStringWithImp(str,appendStringIMP,@"_");
p = s+1;
break;
case '%':
if (s != p)
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
if (s != init && *(s-1) == '[' && *(s+1) == ']')
{
GDL2AppendStringWithImp(str,appendStringIMP,@"%]");
p = s+2; s++;
}
else
{
GDL2AppendStringWithImp(str,appendStringIMP,@"[%]");
p = s+1;
}
break;
case '_':
if (s != p)
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
if (s != init && *(s-1) == '[' && *(s+1) == ']')
{
GDL2AppendStringWithImp(str,appendStringIMP,@"_]");
p = s+2; p++;
}
else
{
GDL2AppendStringWithImp(str,appendStringIMP,@"[_]");
p = s+1;
}
break;
}
}
}
if (*p)
GDL2AppendStringWithImp(str,appendStringIMP,[NSString stringWithCString: p]);
sqlPattern=str;
};
if (*p)
[str appendString: [NSString stringWithCString: p]];
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"pattern=%@ => %@",
pattern,sqlPattern);
return str;
return sqlPattern;
}
+ (NSString *)sqlPatternFromShellPattern: (NSString *)pattern
@ -2127,6 +2167,7 @@ else if([anAttribute isDerived] == YES)
const char *s, *p, *init = [pattern cString];
NSMutableString *str = [NSMutableString stringWithCapacity:
[pattern length]];
IMP appendStringIMP = [str methodForSelector:GDL2_appendStringSEL];
for (s = p = init; *s; s++)
{
@ -2134,47 +2175,47 @@ else if([anAttribute isDerived] == YES)
{
case '*':
if (s != p)
[str appendString: [NSString stringWithCString: p
length: s-p]];
[str appendString: @"%"];
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
GDL2AppendStringWithImp(str,appendStringIMP,@"%");
p = s+1;
break;
case '?':
if (s != p)
[str appendString: [NSString stringWithCString: p
length: s-p]];
[str appendString: @"_"];
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
GDL2AppendStringWithImp(str,appendStringIMP,@"_");
p = s+1;
break;
case '%':
if (s != p)
[str appendString:[NSString stringWithCString: p
length: s-p]];
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
if (s != init && *(s-1) == '[' && *(s+1) == ']')
{
[str appendString: @"%]"];
GDL2AppendStringWithImp(str,appendStringIMP,@"%]");
p = s+2; s++;
}
else
{
[str appendString: @"[%]"];
GDL2AppendStringWithImp(str,appendStringIMP,@"[%]");
p = s+1;
}
break;
case '_':
if (s != p)
[str appendString:[NSString stringWithCString: p
length: s-p]];
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
if (s != init && *(s-1) == '[' && *(s+1) == ']')
{
[str appendString: @"_]"];
GDL2AppendStringWithImp(str,appendStringIMP,@"_]");
p = s+2; p++;
}
else
{
[str appendString: @"[_]"];
GDL2AppendStringWithImp(str,appendStringIMP,@"[_]");
p = s+1;
}
break;
@ -2182,7 +2223,7 @@ else if([anAttribute isDerived] == YES)
}
if (*p)
[str appendString:[NSString stringWithCString:p]];
GDL2AppendStringWithImp(str,appendStringIMP,[NSString stringWithCString:p]);
return str;
}
@ -2252,7 +2293,7 @@ All relationshipPaths in _aliasesByRelationshipPath are direct paths **/
int count = 0;
int contextStackCurrentIndex = 0;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
contextStackCurrentIndex = [_contextStack count];
@ -2328,7 +2369,7 @@ All relationshipPaths in _aliasesByRelationshipPath are direct paths **/
}
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"alias=%@", alias);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return alias;
}
@ -2343,7 +2384,7 @@ All relationshipPaths in _aliasesByRelationshipPath are direct paths **/
NSArray *pathElements = nil;
int i, count;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
NSAssert(relationshipPath, @"No relationshipPath");
NSAssert([relationshipPath length] > 0, @"Empty relationshipPath");
@ -2398,7 +2439,7 @@ All relationshipPaths in _aliasesByRelationshipPath are direct paths **/
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"flattenRelPath=%@",
flattenRelPath);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return flattenRelPath;
}
@ -2417,7 +2458,7 @@ All relationshipPaths in _aliasesByRelationshipPath are direct paths **/
NSString *relPathAlias = nil;
NSString *attributeColumnName = nil;
EOFLOGObjectFnStart();
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"attribute=%@", attribute);
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"relationshipPath=%@",
@ -2438,7 +2479,7 @@ All relationshipPaths in _aliasesByRelationshipPath are direct paths **/
attributeColumnName];
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"alias=%@", alias);
EOFLOGObjectFnStop();
EOFLOGObjectFnStopCond(@"EOSQLExpression");
return alias;//Like t1.label
}

View file

@ -65,6 +65,7 @@ RCS_ID("$Id$")
#include <EOControl/EOObjectStoreCoordinator.h>
#include <EOControl/EONull.h>
#include <EOControl/EODebug.h>
#include <EOControl/EOPriv.h>
#include "EOEntityPriv.h"
@ -257,15 +258,24 @@ RCS_ID("$Id$")
- (EOQualifier *)schemaBasedQualifierWithRootEntity: (EOEntity *)entity
{
//TODO
[self notImplemented: _cmd];
return nil;
return self; // MG: Not sure
}
@end
@implementation EOKeyValueQualifier (EOQualifierSQLGeneration)
+ (void)initialize
{
static BOOL initialized=NO;
if (!initialized)
{
initialized=YES;
GDL2PrivInit();
};
};
- (NSString *)sqlStringForSQLExpression: (EOSQLExpression *)sqlExpression
{
return [sqlExpression sqlStringForKeyValueQualifier: self];
@ -346,7 +356,6 @@ when flattened: ???
NSString *destinationAttributeName;
EOJoin *join = [joins objectAtIndex: i];
id attributeValue = nil;
EONull *eoNull=[EONull null];
EOFLOGObjectLevelArgs(@"EOQualifier",@"join=%@",join);
@ -371,7 +380,7 @@ when flattened: ???
tmpQualifier = [EOKeyValueQualifier
qualifierWithKey: attributeName
operatorSelector: sel
value: (attributeValue ? attributeValue : eoNull)];
value: (attributeValue ? attributeValue : GDL2EONull)];
if (qualifier)//Already a qualifier
{

View file

@ -57,6 +57,7 @@ RCS_ID("$Id$")
#include <EOControl/EONull.h>
#include <EOControl/EOGenericRecord.h>
#include <EOControl/EODebug.h>
#include <EOControl/EOPriv.h>
#include <EOAccess/EOAttribute.h>
#include <EOAccess/EORelationship.h>
@ -172,7 +173,7 @@ static NSString *NSObjectNotAvailableException = @"NSObjectNotAvailableException
value, key, entityName);
if (!value)
value=[EONull null];
value=GDL2EONull;
NSAssert(value, @"No Value"); //Transform it to EONull ?
NSAssert(key, @"No Key");
@ -513,7 +514,7 @@ static NSString *NSObjectNotAvailableException = @"NSObjectNotAvailableException
{
NSDictionary* pk;
if (!value)
value=[EONull null];
value=GDL2EONull;
pk = [NSDictionary dictionaryWithObject: value
forKey: [(EOAttribute*)[primaryKeyAttributes
@ -592,7 +593,7 @@ static NSString *NSObjectNotAvailableException = @"NSObjectNotAvailableException
NSAssert([entityName length]>0,@"No entity name");
if (!value)
value=[EONull null];
value=GDL2EONull;
valueDict = [NSDictionary dictionaryWithObject: value
forKey: key];

View file

@ -67,6 +67,7 @@ RCS_ID("$Id$")
#include <EOControl/EOFetchSpecification.h>
#include <EOControl/EONSAddOns.h>
#include <EOControl/EODebug.h>
#include <EOControl/EOPriv.h>
#include <EOAccess/EOAttribute.h>
#include <EOAccess/EOEntity.h>
@ -162,6 +163,15 @@ pgResultDictionary(PGresult *pgResult)
@implementation Postgres95Channel
+ (void) initialize
{
static BOOL initialized=NO;
if (!initialized)
{
GDL2PrivInit();
};
};
/* Set DateStyle to use ISO format. */
- (void)_setDateStyle
{
@ -444,8 +454,7 @@ zone:zone
else
{
//For efficiency reasons, the returned value is NOT autoreleased !
values[i] = [[NSNumber alloc]
initWithLong: atol(string)];
values[i] = [GDL2NSNumber_alloc() initWithLong: atol(string)];
}
}
else
@ -457,7 +466,11 @@ zone:zone
}
}
NSDebugMLLog(@"gsdb", @"value[%d]=%@", i, values[i]);
NSDebugMLLog(@"gsdb", @"value[%d] (%p)=%@ of class: %@",
i, values[i], values[i], [values[i] class]);
// We don't want to add nil value to dictionary !
NSAssert1(values[i],@"No value for attribute: %@",attr);
}
NSDebugMLLog(@"gsdb", @"values count=%d values=%p", count, values);
@ -899,7 +912,6 @@ each key
EOFLOGObjectFnStart();
NSDebugMLog(@"TEST attributesToFetch=%@", [entity attributesToFetch]);
NSDebugMLLog(@"gsdb",@"%@ -- %@ 0x%x: isFetchInProgress=%s",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
@ -1366,8 +1378,6 @@ each key
NSString *externalType;
NSString *valueClass = @"NSString";
NSString *valueType = nil;
NSDebugMLog(@"TEST attributesToFetch=%@",
[[attribute entity] attributesToFetch]);
if (_origAttributes)
{
@ -1396,6 +1406,7 @@ each key
[attribute setColumnName: @"unknown"];
[attribute setExternalType: externalType];
//TODO: Optimize ?
if ([externalType isEqual: @"bool"])
valueClass = @"NSNumber", valueType = @"c";
else if ([externalType isEqual: @"char"])
@ -1436,8 +1447,6 @@ each key
}
attributes[i] = attribute;
NSDebugMLog(@"TEST attributesToFetch=%@",
[[attribute entity] attributesToFetch]);
}
[self setAttributesToFetch: AUTORELEASE([[NSArray alloc]
@ -1561,6 +1570,8 @@ each key
NSString *externalType;
externalType = [NSString stringWithCString: PQgetvalue(_pgResult,n,1)];
//TODO optimize ?
if ([externalType isEqual: @"bool"])
valueClass = @"NSNumber", valueType = @"c";
else if ([externalType isEqual: @"char"])
@ -1749,11 +1760,13 @@ each key
- (EOModel *)describeModelWithTableNames: (NSArray *)tableNames
{
EOModel *model;
EOAdaptor *adaptor;
EOEntity *entity;
NSArray *entityNames;
unsigned int i;
EOModel *model=nil;
EOAdaptor *adaptor=nil;
EOEntity *entity=nil;
NSArray *entityNames=nil;
unsigned int i=0;
int tableNamesCount=[tableNames count];
int entityNamesCount=0;
adaptor = [[self adaptorContext] adaptor];
model = AUTORELEASE([[EOModel alloc] init]);
@ -1761,7 +1774,7 @@ each key
[model setAdaptorName: [adaptor name]];
[model setConnectionDictionary: [adaptor connectionDictionary]];
for (i = 0; i < [tableNames count]; i++)
for (i = 0; i < tableNamesCount; i++)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSString *name;
@ -1782,7 +1795,8 @@ each key
/* <foreign key stuff> */
entityNames = [model entityNames];
for (i = 0; i < [entityNames count]; i++)
entityNamesCount=[entityNames count];
for (i = 0; i < entityNamesCount; i++)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSString *entityName;
@ -1802,7 +1816,7 @@ each key
[pool release];
}
for (i=0; i < [entityNames count]; i++)
for (i=0; i < entityNamesCount; i++)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSMutableArray *classProperties;

View file

@ -43,6 +43,9 @@ RCS_ID("$Id$")
#include <Foundation/Foundation.h>
#endif
#include <Foundation/NSDecimal.h>
#include <Foundation/NSDecimalNumber.h>
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#include <GNUstepBase/GSCategories.h>
@ -51,6 +54,7 @@ RCS_ID("$Id$")
#include <EOControl/EONull.h>
#include <EOControl/EONSAddOns.h>
#include <EOControl/EODebug.h>
#include <EOControl/EOPriv.h>
#include <EOAccess/EOAttribute.h>
#include <EOAccess/EOEntity.h>
@ -63,6 +67,10 @@ RCS_ID("$Id$")
#include "Postgres95Compatibility.h"
static SEL postgres95FormatSEL=NULL;
static IMP NSCalendarDatePostgres95FormatIMP=NULL;
/* These methods are undocumented but exist in GDL2 and WO4.5.
Ayers: Review (Don't rely on them) */
@interface EOEntity (Undocumented)
@ -77,6 +85,20 @@ RCS_ID("$Id$")
@implementation Postgres95SQLExpression
+ (void) initialize
{
static BOOL initialized=NO;
if (!initialized)
{
GDL2PrivInit();
postgres95FormatSEL=@selector(postgres95Format);
NSCalendarDatePostgres95FormatIMP=[GDL2NSCalendarDateClass
methodForSelector:postgres95FormatSEL];
};
};
+ (NSString *)formatValue: (id)value
forAttribute: (EOAttribute *)attribute
{
@ -134,9 +156,77 @@ RCS_ID("$Id$")
{
EOFLOGObjectLevelArgs(@"EOSQLExpression",
@"float case - value=%@ class=%@",
value, [value class]);
value, [value class]);
formatted = [NSString stringWithFormat: @"%@", value];
if (_isNilOrEONull(value))
formatted=@"NULL";
else
{
unsigned short precision=[attribute precision];
short scale=[attribute scale];
EOFLOGObjectLevelArgs(@"EOSQLExpression",
@"float case - value=%@ class=%@ precision=%d scale=%d",
value, [value class],precision,scale);
// As far as I understand, we need to try to do complex things if precision!=0 or scale!=0
if (precision==0 && scale==0)
{
// just convert it to string...
formatted = [NSString stringWithFormat: @"%@", value];
}
else
{
NSDecimalNumber* decimalValue=nil;
if ([value isKindOfClass: GDL2NSDecimalNumberClass] == NO)
{
if ([value isKindOfClass: GDL2NSStringClass] == YES)
{
decimalValue=[NSDecimalNumber decimalNumberWithString:value];
EOFLOGObjectLevelArgs(@"EOSQLExpression",
@"float case - value [%@]=%@ ==> decimalValue=%@",
value,[value class],decimalValue);
}
else if ([value respondsToSelector: @selector(doubleValue)])
{
decimalValue=(NSDecimalNumber*)[[[NSDecimalNumber alloc]initWithDouble:[value doubleValue]] autorelease];
EOFLOGObjectLevelArgs(@"EOSQLExpression",
@"float case - value [%@]=%@ ==> decimalValue=%@",
value,[value class],decimalValue);
}
else if ([value respondsToSelector: @selector(floatValue)])
{
decimalValue=(NSDecimalNumber*)[[[NSDecimalNumber alloc]initWithFloat:[value floatValue]] autorelease];
EOFLOGObjectLevelArgs(@"EOSQLExpression",
@"float case - value [%@]=%@ ==> decimalValue=%@",
value,[value class],decimalValue);
}
else if ([value respondsToSelector: @selector(intValue)])
{
decimalValue=(NSDecimalNumber*)[[[NSDecimalNumber alloc]initWithInt:[value intValue]] autorelease];
EOFLOGObjectLevelArgs(@"EOSQLExpression",
@"float case - value [%@]=%@ ==> decimalValue=%@",
value,[value class],decimalValue);
};
if (decimalValue)
{
NSDecimal decimal;
NSDecimalNumberHandler* handler=[NSDecimalNumberHandler decimalNumberHandlerWithRoundingMode:NSRoundPlain // Is Plain OK ?
scale:scale
raiseOnExactness:YES
raiseOnOverflow:YES
raiseOnUnderflow:YES
raiseOnDivideByZero:YES];
decimalValue=[decimalValue decimalNumberByRoundingAccordingToBehavior:handler];
decimal=[decimalValue decimalValue];
formatted=NSDecimalString(&decimal,nil);
}
else
{
// Not supported type: just convert it to string...
formatted = [NSString stringWithFormat: @"%@", value];
};
};
};
};
// value was for example 0 length string
if ([formatted length] == 0)
@ -148,7 +238,7 @@ RCS_ID("$Id$")
@"BOOL case - value=%@ class=%@",
value, [value class]);
if ([value isKindOfClass: [NSNumber class]] == YES)
if ([value isKindOfClass: GDL2NSNumberClass] == YES)
{
BOOL boolValue = [value boolValue];
@ -208,12 +298,14 @@ RCS_ID("$Id$")
value, value, [value class]);
}
// Value can also be a string...
if ([value isKindOfClass:[NSDate class]])
if ([value isKindOfClass: GDL2NSDateClass])
{
NSString *format = (*NSCalendarDatePostgres95FormatIMP)
(GDL2NSCalendarDateClass,postgres95FormatSEL);
formatted = [NSString stringWithFormat: @"'%@'",
[value
descriptionWithCalendarFormat:
[NSCalendarDate postgres95Format]//@"%d/%m/%Y %H:%M:%S"
descriptionWithCalendarFormat:format
timeZone: nil
locale: nil]];
}
@ -240,7 +332,7 @@ RCS_ID("$Id$")
PQfreemem (escapedString);
}
}
else
else // String...
{
int length = 0;
@ -291,6 +383,14 @@ RCS_ID("$Id$")
return formatted;
}
- (NSString *)externalNameQuoteCharacter
{
if ([EOSQLExpression useQuotedExternalNames])
return @"'";
else
return @"";
}
- (NSString *)lockClause
{
return @"FOR UPDATE";
@ -459,7 +559,8 @@ RCS_ID("$Id$")
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"entity=%@", entity);
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"_aliasesByRelationshipPath=%@",
_aliasesByRelationshipPath);
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"_flags.hasOuterJoin=%d",
_flags.hasOuterJoin);
contextStackCount=[_contextStack count];
if (contextStackCount>1 && _flags.hasOuterJoin)
@ -497,7 +598,7 @@ RCS_ID("$Id$")
EOFLOGObjectLevelArgs(@"EOSQLExpression",
@"entitiesString=%@", entitiesString);
if (useAliases)
[entitiesString appendFormat: @" %@",
[_aliasesByRelationshipPath
@ -685,6 +786,161 @@ RCS_ID("$Id$")
return finalEntitiesString;
}
// Postgres like seems buggy:
// see http://www.postgresql.org/docs/7.4/interactive/functions-matching.html
// for exemple "ab" doesn't match [_]b
+ (NSString *)sqlPatternFromShellPattern: (NSString *)pattern
{
NSString* sqlPattern=nil;
int patternLength=[pattern length];
if (patternLength==0)
sqlPattern=pattern;
else
{
const char *s, *p, *init = [pattern cString];
NSMutableString *str = [NSMutableString stringWithCapacity:
patternLength];
IMP appendStringIMP = [str methodForSelector:GDL2_appendStringSEL];
for (s = p = init; *s; s++)
{
switch (*s)
{
case '*':
if (s != p)
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
[str appendString: @"%"];
p = s+1;
break;
case '?':
if (s != p)
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
(*appendStringIMP)(str,GDL2_appendStringSEL,@"_");
p = s+1;
break;
case '%':
if (s != p)
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
if (s != init && *(s-1) == '[' && *(s+1) == ']')
{
(*appendStringIMP)(str,GDL2_appendStringSEL,@"%]");
p = s+2; s++;
}
else
{
(*appendStringIMP)(str,GDL2_appendStringSEL,@"[%]");
p = s+1;
}
break;
/*Postgresql doesn't want [_] but want _
case '_':
if (s != p)
(*appendStringIMP)(str,GDL2_appendStringSEL,
(*stringWithCString_lengthIMP)
(GDL2NSStringClass,GDL2_stringWithCString_lengthSEL,p,s-p));
if (s != init && *(s-1) == '[' && *(s+1) == ']')
{
(*appendStringIMP)(str,GDL2_appendStringSEL,@"_]");
p = s+2; p++;
}
else
{
(*appendStringIMP)(str,GDL2_appendStringSEL,@"[_]");
p = s+1;
}
break;
*/
}
}
if (*p)
(*appendStringIMP)(str,GDL2_appendStringSEL,[NSString stringWithCString:p]);
sqlPattern=str;
};
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"pattern=%@ => %@",
pattern,sqlPattern);
return sqlPattern;
}
+ (NSString *)sqlPatternFromShellPattern: (NSString *)pattern
withEscapeCharacter: (unichar)escapeCharacter
{
const char *s, *p, *init = [pattern cString];
NSMutableString *str = [NSMutableString stringWithCapacity:
[pattern length]];
IMP appendStringIMP = [str methodForSelector:GDL2_appendStringSEL];
for (s = p = init; *s; s++)
{
switch (*s)
{
case '*':
if (s != p)
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
GDL2AppendStringWithImp(str,appendStringIMP,@"%");
p = s+1;
break;
case '?':
if (s != p)
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
GDL2AppendStringWithImp(str,appendStringIMP,@"_");
p = s+1;
break;
case '%':
if (s != p)
GDL2AppendStringWithImp(str,appendStringIMP,
GDL2StringWithCStringAndLength(p,s-p));
if (s != init && *(s-1) == '[' && *(s+1) == ']')
{
GDL2AppendStringWithImp(str,appendStringIMP,@"%]");
p = s+2; s++;
}
else
{
GDL2AppendStringWithImp(str,appendStringIMP,@"[%]");
p = s+1;
}
break;
/*Postgresql doesn't want [_] but want _
case '_':
if (s != p)
GDL2AppendStringWithImp(str,appendStringIMP,
(*stringWithCString_lengthIMP)
(GDL2NSStringClass,GDL2_stringWithCString_lengthSEL,p,s-p));
if (s != init && *(s-1) == '[' && *(s+1) == ']')
{
GDL2AppendStringWithImp(str,appendStringIMP,@"_]");
p = s+2; p++;
}
else
{
GDL2AppendStringWithImp(str,appendStringIMP,@"[_]");
p = s+1;
}
break;
*/
}
}
if (*p)
GDL2AppendStringWithImp(str,appendStringIMP,[NSString stringWithCString:p]);
return str;
}
- (NSString *)columnTypeStringForAttribute:(EOAttribute *)attribute
{
NSString *extType = [attribute externalType];

View file

@ -55,7 +55,9 @@ RCS_ID("$Id$")
#include <EOAccess/EOAttribute.h>
#include <EOAccess/EOAttributePriv.h>
#include <EOControl/EONSAddOns.h>
#include <EOControl/EOPriv.h>
#include "Postgres95EOAdaptor/Postgres95Adaptor.h"
#include "Postgres95EOAdaptor/Postgres95Channel.h"
@ -67,8 +69,24 @@ void __postgres95_values_linking_function (void)
{
}
static SEL postgres95FormatSEL=NULL;
static IMP GDL2NSCalendarDate_postgres95FormatIMP=NULL;
@implementation Postgres95Values
+ (void) initialize
{
static BOOL initialized=NO;
if (!initialized)
{
GDL2PrivInit();
postgres95FormatSEL=@selector(postgres95Format);
GDL2NSCalendarDate_postgres95FormatIMP=[GDL2NSCalendarDateClass
methodForSelector:postgres95FormatSEL];
};
};
+ (id)newValueForBytes: (const void *)bytes
length: (int)length
@ -92,59 +110,105 @@ void __postgres95_values_linking_function (void)
return [self newValueForDateType: bytes
length: length
attribute: attribute];
case EOAdaptorUnknownType:
NSAssert1(NO,
@"Bad (EOAdaptorUnknownType) adaptor type for attribute : %@",
attribute);
return nil;
default:
NSAssert2(NO,
@"Bad (%d) adaptor type for attribute : %@",
(int)[attribute adaptorValueType],attribute);
return nil;
}
return nil;
}
/**
For efficiency reasons, the returned value is NOT autoreleased !
bytes is null terminated (cf Postgresql doc) and length is equivalent
to strlen(bytes)
**/
+ (id)newValueForNumberType: (const void *)bytes
length: (int)length
attribute: (EOAttribute *)attribute
{
NSString *str = nil;
{
id value = nil;
NSString* externalType=nil;
externalType=[attribute externalType];
if ([[attribute externalType] isEqualToString: @"bool"])
if (length==1 // avoid -isEqualToString if we can :-)
&& [externalType isEqualToString: @"bool"])
{
if (((char *)bytes)[0] == 't' && ((char *)bytes)[1] == 0)
return [[NSNumber alloc] initWithBool:YES];
if (((char *)bytes)[0] == 'f' && ((char *)bytes)[1] == 0)
return [[NSNumber alloc] initWithBool:NO];
value=RETAIN(GDL2NSNumberBool_Yes);
else if (((char *)bytes)[0] == 'f' && ((char *)bytes)[1] == 0)
value=RETAIN(GDL2NSNumberBool_No);
else
NSAssert1(NO,@"Bad boolean: %@",[NSString stringWithCString:bytes
length:length]);
}
str = [[NSString alloc] initWithCString:(char *)bytes length:length];
if ([[attribute valueClassName] isEqualToString: @"NSDecimalNumber"])
value = [[NSDecimalNumber alloc] initWithString: str];
else if ([[attribute valueType] isEqualToString: @"i"])
value = [[NSNumber alloc] initWithInt: [str intValue]];
else if ([[attribute valueType] isEqualToString: @"I"])
value = [[NSNumber alloc] initWithUnsignedInt: [str unsignedIntValue]];
else if ([[attribute valueType] isEqualToString: @"c"])
value = [[NSNumber alloc] initWithChar: [str intValue]];
else if ([[attribute valueType] isEqualToString: @"C"])
value = [[NSNumber alloc] numberWithUnsignedChar: [str unsignedIntValue]];
else if ([[attribute valueType] isEqualToString: @"s"])
value = [[NSNumber alloc] initWithShort: [str shortValue]];
else if ([[attribute valueType] isEqualToString: @"S"])
value = [[NSNumber alloc] initWithUnsignedShort: [str unsignedShortValue]];
else if ([[attribute valueType] isEqualToString: @"l"])
value = [[NSNumber alloc] initWithLong: [str longValue]];
else if ([[attribute valueType] isEqualToString: @"L"])
value = [[NSNumber alloc] initWithUnsignedLong: [str unsignedLongValue]];
else if ([[attribute valueType] isEqualToString: @"u"])
value = [[NSNumber alloc] initWithLongLong: [str longLongValue]];
else if ([[attribute valueType] isEqualToString: @"U"])
value = [[NSNumber alloc] initWithUnsignedLongLong: [str unsignedLongLongValue]];
else if ([[attribute valueType] isEqualToString: @"f"])
value = [[NSNumber alloc] initWithFloat: [str floatValue]];
else
value = [[NSNumber alloc] initWithDouble: [str doubleValue]];
{
Class valueClass=[attribute _valueClass];
[str release];
if (valueClass==GDL2NSDecimalNumberClass)
{
NSString* str = [GDL2NSString_alloc() initWithCString:bytes
length:length];
value = [GDL2NSDecimalNumber_alloc() initWithString: str];
RELEASE(str);
}
else
{
char valueTypeChar=[attribute _valueTypeChar];
switch(valueTypeChar)
{
case 'i':
value = [GDL2NSNumber_alloc() initWithInt: atoi(bytes)];
break;
case 'I':
value = [GDL2NSNumber_alloc() initWithUnsignedInt:(unsigned int)atol(bytes)];
break;
case 'c':
value = [GDL2NSNumber_alloc() initWithChar: atoi(bytes)];
break;
case 'C':
value = [GDL2NSNumber_alloc() initWithUnsignedChar: (unsigned char)atoi(bytes)];
break;
case 's':
value = [GDL2NSNumber_alloc() initWithShort: (short)atoi(bytes)];
break;
case 'S':
value = [GDL2NSNumber_alloc() initWithUnsignedShort: (unsigned short)atoi(bytes)];
break;
case 'l':
value = [GDL2NSNumber_alloc() initWithLong: atol(bytes)];
break;
case 'L':
value = [GDL2NSNumber_alloc() initWithUnsignedLong:strtoul(bytes,NULL,10)];
break;
case 'u':
value = [GDL2NSNumber_alloc() initWithLongLong:atoll(bytes)];
break;
case 'U':
value = [GDL2NSNumber_alloc() initWithUnsignedLongLong:strtoull(bytes,NULL,10)];
break;
case 'f':
value = [GDL2NSNumber_alloc() initWithFloat: strtof(bytes,NULL)];
break;
case 'd':
case '\0':
value = [GDL2NSNumber_alloc() initWithDouble: strtod(bytes,NULL)];
break;
default:
NSAssert2(NO,@"Unknown attribute valueTypeChar: %c for attribute: %@",
valueTypeChar,attribute);
};
};
};
return value;
}
@ -158,7 +222,7 @@ For efficiency reasons, the returned value is NOT autoreleased !
{
return [attribute newValueForBytes: bytes
length: length
encoding: [NSString defaultCStringEncoding]];
encoding: [NSString defaultCStringEncoding]];//TODO OPTIM
}
/**
@ -170,7 +234,7 @@ For efficiency reasons, the returned value is NOT autoreleased !
{
size_t newLength = length;
unsigned char *decodedBytes = 0;
id data;
id data = nil;
if ([[attribute externalType] isEqualToString: @"bytea"])
{
@ -195,17 +259,27 @@ For efficiency reasons, the returned value is NOT autoreleased !
length: (int)length
attribute: (EOAttribute *)attribute
{
id d;
NSString *str = [NSString stringWithCString: bytes length: length];
NSString *format = [NSCalendarDate postgres95Format];
id date=nil;
NSString *str = [GDL2NSString_alloc() initWithCString:(const char *)bytes
length:length];
NSString *format = (*GDL2NSCalendarDate_postgres95FormatIMP)
(GDL2NSCalendarDateClass,postgres95FormatSEL);
d = [[NSCalendarDate alloc] initWithString: str
calendarFormat: format];
// TODO server TZ ?
NSDebugMLLog(@"gsdb",@"str=%@ format=%@",str,format);
NSDebugMLLog(@"gsdb",@"str=%@ d=%@ format=%@",str,d,format);
date = [GDL2NSCalendarDate_alloc() initWithString: str
calendarFormat: format];
return d;
NSDebugMLLog(@"gsdb",@"str=%@ d=%@ dtz=%@ format=%@",str,date,[date timeZone],format);
//We may have some 'invalid' date so it's better to stop here
NSAssert2(date,
@"No date created for string '%@' for attribute: %@",
str,attribute);
RELEASE(str);
return date;
}
@ -327,12 +401,13 @@ if ([type isEqual:@"bytea"])
+ (NSString*)postgres95Format
{
return @"%Y-%m-%d %H:%M:%S";
return @"%Y-%m-%d %H:%M:%S%z";
}
+ (void)setPostgres95Format: (NSString*)dateFormat
{
NSLog(@"%@ - is deprecated. The adaptor always uses ISO format.");
NSLog(@"%@ - is deprecated. The adaptor always uses ISO format.",
NSStringFromSelector(_cmd));
}