Originally created by @jerryga on GitHub (Dec 22, 2020).
Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=134060 "A Core Data error occurred." UserInfo={reason=The fetched object at index 2 has an out of order section name 'Txt. Objects must be sorted by section name'}: file CoreStore/ListPublisher.swift, line 387
Originally created by @jerryga on GitHub (Dec 22, 2020).
Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=134060 "A Core Data error occurred." UserInfo={reason=The fetched object at index 2 has an out of order section name 'Txt. Objects must be sorted by section name'}: file CoreStore/ListPublisher.swift, line 387

adam
added the question label 2025-12-29 18:26:00 +01:00
@jerryga The error is telling you what's missing: Objects must be sorted by section name
You specified typeGroup as your section grouping, but you are ordering them by date. This means the objects with similar typeGroups would not be ordered in a way that they'll appear in the same section. Your first orderBy clause should always be relevant for your sectionBy:
From<Object>().sectionBy(.$typeGroup).orderBy(.ascending(\.$cameraType),// since this is the `Field.Stored` attribute that your `typeGroup` derives from, it should be the first sorting key.ascending(\.$date))
@JohnEstropia commented on GitHub (Dec 22, 2020):
@jerryga The error is telling you what's missing: `Objects must be sorted by section name`
You specified `typeGroup` as your section grouping, but you are ordering them by `date`. This means the objects with similar `typeGroup`s would not be ordered in a way that they'll appear in the same section. Your first `orderBy` clause should always be relevant for your `sectionBy`:
```swift
From<Object>()
.sectionBy(.$typeGroup)
.orderBy(
.ascending(\.$cameraType), // since this is the `Field.Stored` attribute that your `typeGroup` derives from, it should be the first sorting key
.ascending(\.$date)
)
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @jerryga on GitHub (Dec 22, 2020).
Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=134060 "A Core Data error occurred." UserInfo={reason=The fetched object at index 2 has an out of order section name 'Txt. Objects must be sorted by section name'}: file CoreStore/ListPublisher.swift, line 387

@jerryga commented on GitHub (Dec 22, 2020):
@Field.Virtual(
"typeGroup",
customGetter: { object, field in
@jerryga commented on GitHub (Dec 22, 2020):
static let ScanPublisher: ListPublisher = iScanCoreData.dataStack.publishList(
From()
.sectionBy(.$typeGroup)
.orderBy(.ascending(.$date))
@JohnEstropia commented on GitHub (Dec 22, 2020):
@jerryga The error is telling you what's missing:
Objects must be sorted by section nameYou specified
typeGroupas your section grouping, but you are ordering them bydate. This means the objects with similartypeGroups would not be ordered in a way that they'll appear in the same section. Your firstorderByclause should always be relevant for yoursectionBy:@jerryga commented on GitHub (Dec 22, 2020):
@JohnEstropia Thank you very much! You save me time.