Upgrade to 2.1.3 - OrderBy failure #97

Closed
opened 2025-12-29 15:24:36 +01:00 by adam · 2 comments
Owner

Originally created by @netbe on GitHub (Nov 14, 2016).

Hi,

I am upgrading our project to 2.1.3, and seeing some failures like:

❗ [CoreStore: Assertion Failure] DataStack+Observing.swift:90 monitorList
  ↪︎ An 'NSFetchedResultsController' requires a sort information. Specify from a 'OrderBy' clause or any custom 'FetchClause' that provides a sort descriptor.

Most of the time, I see it because the fetchClauses contains OrderBy() only without any argument. Specifying the order then works fine, but not leaving it out

Failed

[Where()]

[Where(), OrderBy()]

Worked

[Where(), OrderBy(.Descending(ManagedPhysician.Keys.fullName.rawValue))]

I am just wondering why the init on OrderBy is then public if it cannot be used or in which case it can be used at all.

Thanks

Originally created by @netbe on GitHub (Nov 14, 2016). Hi, I am upgrading our project to 2.1.3, and seeing some failures like: ``` ❗ [CoreStore: Assertion Failure] DataStack+Observing.swift:90 monitorList ↪︎ An 'NSFetchedResultsController' requires a sort information. Specify from a 'OrderBy' clause or any custom 'FetchClause' that provides a sort descriptor. ``` Most of the time, I see it because the fetchClauses contains OrderBy() only without any argument. Specifying the order then works fine, but not leaving it out **Failed** ```[Where()]``` ```[Where(), OrderBy()]``` **Worked** ```[Where(), OrderBy(.Descending(ManagedPhysician.Keys.fullName.rawValue))]``` I am just wondering why the init on OrderBy is then public if it cannot be used or in which case it can be used at all. Thanks
adam added the discussionwontfix labels 2025-12-29 15:24:36 +01:00
adam closed this issue 2025-12-29 15:24:36 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Nov 15, 2016):

@netbe For ListMonitor, the OrderBy is required to have at least one sort key. Few reasons I left the default initializers public:

  • fetchAll(), deleteAll() also accepts OrderBy clauses, and are perfectly fine with empty sorting
  • NSFetchRequest.predicate and NSFetchRequest.sortDescriptors both accept nil and empty predicate/array. The effect of either is undocumented so I left a way to set both nil and their Where() and OrderBy() empty counterparts
  • Where() and OrderBy() can be used to explicitly express that the predicate and sort order are intentionally set to empty (as opposed to having forgot to set them)
@JohnEstropia commented on GitHub (Nov 15, 2016): @netbe For ListMonitor, the OrderBy is required to have at least one sort key. Few reasons I left the default initializers public: - `fetchAll()`, `deleteAll()` also accepts `OrderBy` clauses, and are perfectly fine with empty sorting - `NSFetchRequest.predicate` and `NSFetchRequest.sortDescriptors` both accept `nil` and empty predicate/array. The effect of either is undocumented so I left a way to set both `nil` and their `Where()` and `OrderBy()` empty counterparts - `Where()` and `OrderBy()` can be used to explicitly express that the predicate and sort order are intentionally set to empty (as opposed to having forgot to set them)
Author
Owner

@netbe commented on GitHub (Nov 17, 2016):

@JohnEstropia thx for the explanation

@netbe commented on GitHub (Nov 17, 2016): @JohnEstropia thx for the explanation
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore#97