bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix GDL2, EOSQLExpression (prepareSelectExpressionWithAttributes)


From: David Ayers
Subject: Re: Fix GDL2, EOSQLExpression (prepareSelectExpressionWithAttributes)
Date: Fri, 24 Jul 2009 19:12:54 +0200

Am Freitag, den 24.07.2009, 15:54 +0800 schrieb Georg Fleischmann:
> here is another fix for [EOSQLExpression - 
> prepareSelectExpressionWithAttributes:] to make aggregate functions  
> like "count(*)" and "sum(amount)" work.
> These functions are set in an attribute's definition and look like  
> that in the EOmodeld:
> 
>          {
>              definition = "count(*)";
>              externalType = int4;
>              isReadOnly = Y;
>              name = countEntries;
>              valueClassName = NSNumber;
>              valueType = i;
>          },
> 
> To make this work I filled a TODO for flattened Attributes (is it  
> correct that these attributes appear flattened?).
> My code adds the definition of the attribute to the listString, but  
> only if it's not a relationship (= contains a dot).
> 
> 
> The second patch in EOExpressionArray changes a hard-coded dot "." to  
> _infix, so that the functions will not end up like "count.(*)" and  
> "sum.(.amount.)" in the SELECT.
> 
> 
> * EOAccess/EOSQLExpression ([EOSQLExpression - 
> prepareSelectExpressionWithAttributes:]):
> set listString for "flattened attributes" with a definition like count 
> (*) or sum(amount)
> * EOAccess/EOExpressionArray (EOExpressionArray - 
> valueForSQLExpression:):
> use _infix instead of "."
> 

Thanks! Minor tweaks and committed.

Cheers,
David

> *** EOAccess/EOSQLExpression.m.old    Wed Jul 22 18:06:02 2009
> --- EOAccess/EOSQLExpression.m        Thu Jul 23 13:46:37 2009
> ***************
> *** 684,692 ****
>        {
>          EOAttribute *attribute = [attributes objectAtIndex: i];
> 
> !       if ([attribute isFlattened])
> !         {
> !           NSEmitTODO();  //TODO???
>              EOFLOGObjectLevelArgs(@"EOSQLExpression", @"flattened  
> attribute=%@",
>                               attribute);
>            }
> --- 684,698 ----
>        {
>          EOAttribute *attribute = [attributes objectAtIndex: i];
> 
> !       if ([attribute isFlattened])  // we have to add definitions  
> that are not relationships
> !         { NSMutableString *listString = [self listString];
> !           NSString *definition = [attribute definition];
> !
> !           if ( [definition rangeOfString:@"."].length == 0 )    // arg
> !             {
> !               [self appendItem: definition
> !                   toListString: listString];
> !             }
>              EOFLOGObjectLevelArgs(@"EOSQLExpression", @"flattened  
> attribute=%@",
>                               attribute);
>            }
> 
> 
> 
> *** EOAccess/EOExpressionArray.m.old  Tue Jan 22 21:57:07 2008
> --- EOAccess/EOExpressionArray.m      Wed Jul 22 17:52:49 2009
> ***************
> *** 365,372 ****
> 
>              relValue = [obj valueForSQLExpression: sqlExpression];
> 
> !           if (i > 0)
> !             [value appendString: @"."];
> 
>              [value appendString: relValue];
>            }
> --- 365,372 ----
> 
>              relValue = [obj valueForSQLExpression: sqlExpression];
> 
> !           if (i > 0 && _infix)
> !               [value appendString: _infix];
> 
>              [value appendString: relValue];
>            }
> 
> 
> 
> _______________________________________________
> Bug-gnustep mailing list
> Bug-gnustep@gnu.org
> http://lists.gnu.org/mailman/listinfo/bug-gnustep
-- 
David Ayers          Fellow of the Free Software Foundation Europe
http://www.fsfe.org                     http://fellowship.fsfe.org






reply via email to

[Prev in Thread] Current Thread [Next in Thread]