From 38ea25d271ffcdb45c1f38e8efb92b6fd16240b2 Mon Sep 17 00:00:00 2001 From: helge Date: Sun, 5 Sep 2004 22:54:57 +0000 Subject: [PATCH] added a select..X method which doesn't raise NSExceptions, but returns them instead git-svn-id: http://svn.opengroupware.org/SOPE/trunk@106 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-gdl1/GDLAccess/ChangeLog | 6 ++ sope-gdl1/GDLAccess/EOAdaptorChannel.h | 22 ++-- sope-gdl1/GDLAccess/EOAdaptorChannel.m | 123 ++++++++++++++--------- sope-gdl1/GDLAccess/EORecordDictionary.m | 2 - sope-gdl1/GDLAccess/README | 14 +-- sope-gdl1/GDLAccess/Version | 2 +- sope-gdl1/GDLAccess/common.h | 2 - 7 files changed, 100 insertions(+), 71 deletions(-) diff --git a/sope-gdl1/GDLAccess/ChangeLog b/sope-gdl1/GDLAccess/ChangeLog index bae3a54f..f382b4ff 100644 --- a/sope-gdl1/GDLAccess/ChangeLog +++ b/sope-gdl1/GDLAccess/ChangeLog @@ -1,3 +1,9 @@ +2004-09-06 Helge Hess + + * EOAdaptorChannel.m: added + -selectAttributesX:describedByQualifier:fetchOrder:lock: for + selects which return, not raise, exceptions (v1.1.38) + 2004-08-31 Helge Hess * GNUmakefile.preamble: added library search pathes for FHS install diff --git a/sope-gdl1/GDLAccess/EOAdaptorChannel.h b/sope-gdl1/GDLAccess/EOAdaptorChannel.h index 751b1b84..efce51fe 100644 --- a/sope-gdl1/GDLAccess/EOAdaptorChannel.h +++ b/sope-gdl1/GDLAccess/EOAdaptorChannel.h @@ -98,19 +98,23 @@ - (BOOL)deleteRowsDescribedByQualifier:(EOSQLQualifier *)aQualifier; /* Fetching rows */ -- (BOOL)selectAttributes:(NSArray*)attributes - describedByQualifier:(EOSQLQualifier*)aQualifier - fetchOrder:(NSArray*)aFetchOrder +- (BOOL)selectAttributes:(NSArray *)attributes + describedByQualifier:(EOSQLQualifier *)aQualifier + fetchOrder:(NSArray *)aFetchOrder + lock:(BOOL)aLockFlag; +- (NSException *)selectAttributesX:(NSArray *)attributes + describedByQualifier:(EOSQLQualifier *)aQualifier + fetchOrder:(NSArray *)aFetchOrder lock:(BOOL)aLockFlag; - (NSArray*)describeResults; // override -- (NSMutableDictionary*)fetchAttributes:(NSArray*)attributes - withZone:(NSZone*)zone; +- (NSMutableDictionary*)fetchAttributes:(NSArray *)attributes + withZone:(NSZone *)zone; - (BOOL)isFetchInProgress; - (void)cancelFetch; // override -- (NSMutableDictionary*)dictionaryWithObjects:(id*)objects - forAttributes:(NSArray*)attributes zone:(NSZone*)zone; -- (NSMutableDictionary*)primaryFetchAttributes:(NSArray*)attributes - withZone:(NSZone*)zone; // override +- (NSMutableDictionary *)dictionaryWithObjects:(id *)objects + forAttributes:(NSArray *)attributes zone:(NSZone *)zone; +- (NSMutableDictionary *)primaryFetchAttributes:(NSArray *)attributes + withZone:(NSZone *)zone; // override /* Sending SQL to the server */ - (BOOL)evaluateExpression:(NSString *)_anExpression; // override diff --git a/sope-gdl1/GDLAccess/EOAdaptorChannel.m b/sope-gdl1/GDLAccess/EOAdaptorChannel.m index e8af497a..df54956d 100644 --- a/sope-gdl1/GDLAccess/EOAdaptorChannel.m +++ b/sope-gdl1/GDLAccess/EOAdaptorChannel.m @@ -122,15 +122,15 @@ if (!isOpen) return [[ChannelIsNotOpenedException new] autorelease]; - - if((row == nil) || (entity == nil)) { + + if ((row == nil) || (entity == nil)) { return [NSException exceptionWithName:NSInvalidArgumentException reason:@"row and entity arguments for " @"insertRow:forEntity: must not be the nil object" userInfo:nil]; } - if([self isFetchInProgress]) + if ([self isFetchInProgress]) return [AdaptorIsFetchingException exceptionWithAdaptor:self]; if ([self->adaptorContext transactionNestingLevel] == 0) @@ -266,6 +266,23 @@ /* compatibility methods (DEPRECATED, use the ...X methods */ +- (BOOL)selectAttributes:(NSArray *)attributes + describedByQualifier:(EOSQLQualifier *)qualifier + fetchOrder:(NSArray *)fetchOrder + lock:(BOOL)lockFlag +{ + NSException *ex; + + ex = [self selectAttributesX:attributes describedByQualifier:qualifier + fetchOrder:fetchOrder lock:lockFlag]; + if (ex == nil) + return YES; + if ([self _isNoRaiseOnModificationException:ex]) + return NO; + [ex raise]; + return NO; +} + - (BOOL)insertRow:(NSDictionary *)_row forEntity:(EOEntity *)_entity { NSException *ex; @@ -306,54 +323,60 @@ /* fetch operations */ -- (BOOL)selectAttributes:(NSArray *)attributes +- (NSException *)selectAttributesX:(NSArray *)attributes describedByQualifier:(EOSQLQualifier *)qualifier fetchOrder:(NSArray *)fetchOrder lock:(BOOL)lockFlag { - EOSQLExpression *sqlexpr = nil; - NSMutableArray *mattrs = (NSMutableArray *)attributes; - NSMutableArray *mfetch = (NSMutableArray *)fetchOrder; - - if (!isOpen) - [[ChannelIsNotOpenedException new] raise]; - - if (attributes == nil) { - [NSException raise:NSInvalidArgumentException - format:@"attributes argument for selectAttributes:" - @"describedByQualifier:fetchOrder:lock: " - @"must not be the nil object"]; - } + NSException *ex; + EOSQLExpression *sqlexpr = nil; + NSMutableArray *mattrs = (NSMutableArray *)attributes; + NSMutableArray *mfetch = (NSMutableArray *)fetchOrder; - if ([self isFetchInProgress]) - [[AdaptorIsFetchingException exceptionWithAdaptor:self] raise]; - - if ([self->adaptorContext transactionNestingLevel] == 0) - [[NoTransactionInProgressException exceptionWithAdaptor:self] raise]; + if (!isOpen) + return [[ChannelIsNotOpenedException new] autorelease]; - if(delegateRespondsTo.willSelectAttributes) { - EODelegateResponse response; + if (attributes == nil) { + return [NSException exceptionWithName:NSInvalidArgumentException + reason: + @"attributes argument for selectAttributes:" + @"describedByQualifier:fetchOrder:lock: " + @"must not be the nil object" + userInfo:nil]; + } + + if ([self isFetchInProgress]) + return [AdaptorIsFetchingException exceptionWithAdaptor:self]; + + if ([self->adaptorContext transactionNestingLevel] == 0) + return [NoTransactionInProgressException exceptionWithAdaptor:self]; + + if (delegateRespondsTo.willSelectAttributes) { + EODelegateResponse response; - mattrs = [[attributes mutableCopy] autorelease]; - mfetch = [[fetchOrder mutableCopy] autorelease]; - - response = [delegate adaptorChannel:self - willSelectAttributes:mattrs - describedByQualifier:qualifier - fetchOrder:mfetch - lock:lockFlag]; - if (response == EODelegateRejects) - return NO; - if (response == EODelegateOverrides) - return YES; + mattrs = [[attributes mutableCopy] autorelease]; + mfetch = [[fetchOrder mutableCopy] autorelease]; + + response = [delegate adaptorChannel:self + willSelectAttributes:mattrs + describedByQualifier:qualifier + fetchOrder:mfetch + lock:lockFlag]; + if (response == EODelegateRejects) { + return [NSException exceptionWithName:@"EODelegateRejects" + reason:@"delegate rejected select" + userInfo:nil]; } + if (response == EODelegateOverrides) + return nil; + } #if 0 #warning DEBUG LOG, REMOVE! - [self logWithFormat:@"fetch qualifier: %@", qualifier]; + [self logWithFormat:@"fetch qualifier: %@", qualifier]; #endif - sqlexpr = [[[self->adaptorContext adaptor] + sqlexpr = [[[self->adaptorContext adaptor] expressionClass] selectExpressionForAttributes:attributes lock:lockFlag @@ -361,18 +384,18 @@ fetchOrder:fetchOrder channel:self]; - if (![self evaluateExpression:[sqlexpr expressionValueForContext:nil]]) - return NO; - - if (delegateRespondsTo.didSelectAttributes) { - [delegate adaptorChannel:self - didSelectAttributes:mattrs - describedByQualifier:qualifier - fetchOrder:mfetch - lock:lockFlag]; - } - - return YES; + ex = [self evaluateExpressionX:[sqlexpr expressionValueForContext:nil]]; + if (ex != nil) + return ex; + + if (delegateRespondsTo.didSelectAttributes) { + [delegate adaptorChannel:self + didSelectAttributes:mattrs + describedByQualifier:qualifier + fetchOrder:mfetch + lock:lockFlag]; + } + return nil; } - (NSArray *)describeResults { diff --git a/sope-gdl1/GDLAccess/EORecordDictionary.m b/sope-gdl1/GDLAccess/EORecordDictionary.m index b839b118..37b289e7 100644 --- a/sope-gdl1/GDLAccess/EORecordDictionary.m +++ b/sope-gdl1/GDLAccess/EORecordDictionary.m @@ -23,7 +23,6 @@ If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id: EORecordDictionary.m 1 2004-08-20 10:38:46Z znek $ #include #include @@ -35,7 +34,6 @@ #import #if LIB_FOUNDATION_LIBRARY -# include # include #else # include diff --git a/sope-gdl1/GDLAccess/README b/sope-gdl1/GDLAccess/README index 9e54000b..aee7ac7b 100644 --- a/sope-gdl1/GDLAccess/README +++ b/sope-gdl1/GDLAccess/README @@ -1,21 +1,21 @@ -# $Id: README 1 2004-08-20 10:38:46Z znek $ - -NOTE: this file is heavily outdated +NOTE: this file is outdated! GNU Database Library Access Layer - MDlink patch Version - Contained code is derived from gdl - GNU Database Library and is therefore - LGPL license. Copyright for gdl has the Free Software Foundation. + Contained code is derived from GDL - GNU Database Library and is therefore + LGPL license. Copyright for GDL has the Free Software Foundation. Changes - There are no EOJoin's anymore (only for compability). EORelationships cannot - be compound and store source and destination themselves. + There are no EOJoin's anymore (only for compability). EORelationships + cannot be compound and store source and destination themselves. No compound primary keys are allowed. Uniquing is always enabled. + Added "abcX" methods which do not raise exceptions but return them. + Static Linking uncomment '#imports' in EOModel.m diff --git a/sope-gdl1/GDLAccess/Version b/sope-gdl1/GDLAccess/Version index bf873749..7087ff32 100644 --- a/sope-gdl1/GDLAccess/Version +++ b/sope-gdl1/GDLAccess/Version @@ -1,3 +1,3 @@ # $Id: Version 1 2004-08-20 10:38:46Z znek $ -SUBMINOR_VERSION:=37 +SUBMINOR_VERSION:=38 diff --git a/sope-gdl1/GDLAccess/common.h b/sope-gdl1/GDLAccess/common.h index e9274af2..bc474eaa 100644 --- a/sope-gdl1/GDLAccess/common.h +++ b/sope-gdl1/GDLAccess/common.h @@ -23,7 +23,6 @@ If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id: common.h 1 2004-08-20 10:38:46Z znek $ #ifndef __common_h__ #define __common_h__ @@ -50,7 +49,6 @@ #endif #if LIB_FOUNDATION_LIBRARY -# import # import #else # include -- 2.39.5