bugGNUstep - Bugs: bug #47619, NSPredicate: aggregate function...

Group
 
 

bug #47619: NSPredicate: aggregate function expressions implemented incorrectly

Submitter:  Niels Grewe <thebeing>
Submitted:  Mon 04 Apr 2016 03:04:40 PM UTC
   
 
Category:  Base/Foundation Severity:  3 - Normal
Item Group:  Bug Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 08 Jun 2016 07:59:31 AM UTC, comment #3: 

Thanks Niels

Richard Frith-Macdonald <CaS>
Group Member
Wed 08 Jun 2016 07:52:59 AM UTC, comment #2: 

It seems to work for me (and matches the Cocoa behaviour). The test case was a tad glitchy because we still support count instead of @count, so it would in fact not test the right thing, but I fixed that.

Niels Grewe <thebeing>
Group Member
Wed 18 May 2016 01:47:39 PM UTC, comment #1: 

I never use NSPredicate and am unfamiliar with this code, but I've tried an update, checking to see if the argument is a single collection object (responds to -objectEnumerator), and if so calculating the result by enumerating the collection contents.
I'm not sure that's the correct behavior though.

Richard Frith-Macdonald <CaS>
Group Member
Mon 04 Apr 2016 03:04:40 PM UTC, original submission:  

The aggregate function expressions (sum, min, max, avg) in base are implemented as vararg functions. This is incorrect with respect to the Cocoa implementation. There they are implemented as single argument functions that take collections as arguments.

In particular, the following evaluates truthy:

    NSArray *a = @[ @{ @"count": @1 }, @{ @"count": @1 } ];
    NSPredicate *p = [NSPredicate predicateWithFormat: @"sum(count) == 2"];
    [p evaluateWithObject: a];

(sorry, literal notation for compactness). On GNUstep it raises an NSInvalidArgumentException (because the array of NSNumbers does not implement -doubleValue).

Niels Grewe <thebeing>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by CaS (Posted a comment)
  • -email is unavailable- added by thebeing (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-06-08 thebeing StatusReady For Test Fixed
        Open/ClosedIn Test Closed
    2016-05-18 CaS StatusNone Ready For Test
        Open/ClosedOpen In Test

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code