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

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #47619: NSPredicate: aggregate function expressions implemented incorrectly

Submitted by:  Niels Grewe <thebeing>
Submitted on:  Mon 04 Apr 2016 03:04:40 PM UTC  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

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

Thanks Niels

Richard Frith-Macdonald <CaS>
Project 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>
Project 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>
Project 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>
Project Member

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 08 Jun 2016 07:52:59 AM UTCthebeingStatusReady For Test=>Fixed
      Open/ClosedIn Test=>Closed
    Wed 18 May 2016 01:47:39 PM UTCCaSStatusNone=>Ready For Test
      Open/ClosedOpen=>In Test

    Back to the top


    Powered by Savane 3.1-cleanup1